Skip to content

Commit 7423d0a

Browse files
Fix super context calls
1 parent c9bed7a commit 7423d0a

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

gen/objcgen.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ LLConstant *ObjCState::getClassRoTable(ClassDeclaration *decl) {
457457
LLGlobalVariable *protocolList = nullptr;
458458
LLGlobalVariable *methodList = nullptr;
459459

460-
if (auto baseMethods = createMethodList(decl, false)) {
460+
if (auto baseMethods = createMethodList(decl)) {
461461
methodList = getOrCreate(objcGetClassMethodListSymbol(name, meta), baseMethods->getType(), OBJC_SECNAME_CONST);
462462
methodList->setInitializer(baseMethods);
463463
}
@@ -569,7 +569,7 @@ LLConstant *ObjCState::getClassRef(ClassDeclaration *decl) {
569569
return it->second;
570570
}
571571

572-
auto retval = getOrCreate("OBJC_CLASSLIST_REFERENCES_$_", getOpaquePtrType(), OBJC_SECNAME_CLASSREFS);
572+
auto retval = makeGlobal("OBJC_CLASSLIST_REFERENCES_$_", getOpaquePtrType(), OBJC_SECNAME_CLASSREFS);
573573
classRefs[className] = retval;
574574
this->retain(retval);
575575
return retval;

gen/objcgen.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ class ObjCState {
177177
// used in method lists.
178178
ObjcMap<FuncDeclaration *, ObjcMethodInfo> methods;
179179
LLConstant *createMethodInfo(FuncDeclaration *decl);
180-
LLConstant *createMethodList(ClassDeclaration *decl, bool optional);
180+
LLConstant *createMethodList(ClassDeclaration *decl, bool optional = false);
181181

182182
// class_t and class_ro_t generation.
183183
ObjcMap<ClassDeclaration *, ObjcClassInfo> classes;
@@ -200,7 +200,7 @@ class ObjCState {
200200
LLConstant *createProtocolList(ClassDeclaration *decl);
201201

202202
// Private helpers
203-
ObjcList<FuncDeclaration *> getMethodsForType(ClassDeclaration *decl, bool optional);
203+
ObjcList<FuncDeclaration *> getMethodsForType(ClassDeclaration *decl, bool optional = false);
204204

205205
ObjcList<LLConstant *> retainedSymbols;
206206
void retain(LLConstant *symbol);

gen/tocall.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -738,16 +738,17 @@ class ImplicitArgumentsBuilder {
738738
if (objccall && directcall) {
739739

740740
// ... or a Objective-c direct call argument
741-
if (auto parentfd = dfnval->func->isFuncDeclaration()) {
742-
if (auto cls = parentfd->parent->isClassDeclaration()) {
741+
if (auto func = dfnval->func->isFuncDeclaration()) {
742+
if (auto klass = func->isThis()->isClassDeclaration()) {
743743

744744
// Create obj_super struct with (this, <class ref>)
745745
auto obj_super = DtoAggrPair(
746746
DtoBitCast(dfnval->vthis, argtype),
747-
gIR->objc.deref(cls, getOpaquePtrType()),
747+
gIR->objc.deref(klass, getOpaquePtrType()),
748748
"super"
749749
);
750750

751+
751752
// Allocate and store obj_super struct into a new variable.
752753
auto clsaddr = DtoRawAlloca(obj_super->getType(), 16, "super");
753754
DtoStore(obj_super, clsaddr);

0 commit comments

Comments
 (0)