Skip to content

Commit 0c808b0

Browse files
committed
Add the AnyObject special case to the SIL parser's conformance logic.
1 parent bac0bad commit 0c808b0

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

lib/Parse/ParseSIL.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1429,6 +1429,12 @@ static bool allowAbstractConformance(Parser &P, Type subReplacement,
14291429
if (!subReplacement->hasDependentProtocolConformances())
14301430
return false;
14311431

1432+
// AnyObject is implicitly conformed to by anything with a class bound.
1433+
if (proto->isSpecificProtocol(KnownProtocolKind::AnyObject) &&
1434+
subReplacement->isAnyClassReferenceType()) {
1435+
return true;
1436+
}
1437+
14321438
if (auto archetype = subReplacement->getAs<ArchetypeType>()) {
14331439
return isImpliedBy(proto, archetype->getConformsTo());
14341440
}

test/SIL/Parser/basic.sil

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1419,7 +1419,6 @@ else:
14191419
return %3void : $()
14201420
} // CHECK: {{^}$}}
14211421

1422-
14231422
// CHECK-LABEL: sil_vtable Foo {
14241423
// CHECK: #Foo.subscript!getter.1: _TFC3tmp3Foog9subscriptFTVs5Int32S1__S1_
14251424
// CHECK: #Foo.subscript!setter.1: _TFC3tmp3Foos9subscriptFTVs5Int32S1__S1_

test/SIL/Parser/basic_objc.sil

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,11 @@ entry(%a : $@objc_metatype SomeClass.Type, %b : $@objc_metatype SomeClassProtoco
3232
return %z : $(AnyObject, AnyObject)
3333
}
3434

35+
sil @requires_any_object : $@convention(thin) <T: AnyObject> (@owned T) -> ()
36+
37+
sil @foo : $@convention(thin) (@owned ObjCProto) -> () {
38+
entry(%a : $ObjCProto):
39+
%f = function_ref @requires_any_object : $@convention(thin) <T: AnyObject> (@owned T) -> ()
40+
%0 = apply %f<ObjCProto>(%a) : $@convention(thin) <T: AnyObject> (@owned T) -> ()
41+
return %0 : $()
42+
}

0 commit comments

Comments
 (0)