Skip to content

Commit 54a6b46

Browse files
committed
IRGen: If Objective-C interop is disabled foreign classes should use Swift reference counting
I'm not sure how to write an automated test for this yet. Fixes <rdar://problem/23545207>.
1 parent 37f38c9 commit 54a6b46

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/IRGen/GenMeta.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2941,9 +2941,9 @@ namespace {
29412941
void addValueWitnessTable() {
29422942
ClassDecl *cls = Target;
29432943

2944-
auto type = (cls->checkObjCAncestry() != ObjCClassKind::NonObjC)
2945-
? CanType(this->IGM.Context.TheUnknownObjectType)
2946-
: CanType(this->IGM.Context.TheNativeObjectType);
2944+
auto type = (cls->checkObjCAncestry() != ObjCClassKind::NonObjC
2945+
? this->IGM.Context.TheUnknownObjectType
2946+
: this->IGM.Context.TheNativeObjectType);
29472947
auto wtable = this->IGM.getAddrOfValueWitnessTable(type);
29482948
addWord(wtable);
29492949
}
@@ -4743,7 +4743,11 @@ namespace {
47434743
// Visitor methods.
47444744

47454745
void addValueWitnessTable() {
4746-
auto type = IGM.Context.TheUnknownObjectType;
4746+
// Without Objective-C interop, foreign classes must still use
4747+
// Swift native reference counting.
4748+
auto type = (IGM.ObjCInterop
4749+
? IGM.Context.TheUnknownObjectType
4750+
: IGM.Context.TheNativeObjectType);
47474751
auto wtable = IGM.getAddrOfValueWitnessTable(type);
47484752
addWord(wtable);
47494753
}

0 commit comments

Comments
 (0)