Skip to content

Commit 7dc5928

Browse files
committed
Merge pull request #2872 from jckarter/generic-block-sil-verifier
2 parents 01682af + 5e314fa commit 7dc5928

File tree

2 files changed

+12
-18
lines changed

2 files changed

+12
-18
lines changed

lib/SIL/SILVerifier.cpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2809,18 +2809,8 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
28092809
invokeTy->getExtInfo().isPseudogeneric(),
28102810
"invoke function must not take reified generic parameters");
28112811

2812-
if (auto sig = invokeTy->getGenericSignature()) {
2813-
require(sig->getGenericParams().size() ==
2814-
IBSHI->getSubstitutions().size(),
2815-
"instruction must provide substitutions matching invoke "
2816-
"function");
2817-
invokeTy = invokeTy->substGenericArgs(F.getModule(), M,
2818-
IBSHI->getSubstitutions());
2819-
} else {
2820-
require(IBSHI->getSubstitutions().empty(),
2821-
"instruction must not provide substitutions for non-polymorphic "
2822-
"invoke fn");
2823-
}
2812+
invokeTy = checkApplySubstitutions(IBSHI->getSubstitutions(),
2813+
SILType::getPrimitiveObjectType(invokeTy));
28242814

28252815
auto storageParam = invokeTy->getParameters()[0];
28262816
require(storageParam.getConvention() ==

test/SILGen/objc_imported_generic.swift

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public func genericPropertyOnAnyObject(o: AnyObject, b: Bool) -> AnyObject?? {
4444
// CHECK: dynamic_method_br %4 : $@opened([[TAG:.*]]) AnyObject, #GenericClass.propertyThing!getter.1.foreign, bb1
4545
// CHECK: bb1({{%.*}} : $@convention(objc_method) @pseudogeneric (@opened([[TAG]]) AnyObject) -> @autoreleased Optional<AnyObject>):
4646

47-
protocol ThingHolder {
47+
public protocol ThingHolder {
4848
associatedtype Thing
4949

5050
init!(thing: Thing!)
@@ -65,16 +65,20 @@ protocol ThingHolder {
6565
extension GenericClass: ThingHolder {}
6666
#endif
6767

68-
public func genericBlockBridging<T: AnyObject>(x: GenericClass<T>) {
68+
public protocol Ansible: class {
69+
associatedtype Anser: ThingHolder
70+
}
71+
72+
public func genericBlockBridging<T: Ansible>(x: GenericClass<T>) {
6973
let block = x.blockForPerformingOnThings()
7074
x.performBlock(onThings: block)
7175
}
7276

7377
// CHECK-LABEL: sil @_TF21objc_imported_generic20genericBlockBridging
74-
// CHECK: [[BLOCK_TO_FUNC:%.*]] = function_ref @_TTRGRxs9AnyObjectrXFdCb_dx_ax_XFo_ox_ox_
75-
// CHECK: partial_apply [[BLOCK_TO_FUNC]]<T>
76-
// CHECK: [[FUNC_TO_BLOCK:%.*]] = function_ref @_TTRGRxs9AnyObjectrXFo_ox_ox_XFdCb_dx_ax_
77-
// CHECK: init_block_storage_header {{.*}} invoke [[FUNC_TO_BLOCK]]<T>
78+
// CHECK: [[BLOCK_TO_FUNC:%.*]] = function_ref @_TTRGRxs9AnyObjectx21objc_imported_generic7AnsiblerXFdCb_dx_ax_XFo_ox_ox_
79+
// CHECK: partial_apply [[BLOCK_TO_FUNC]]<T, {{.*}}>
80+
// CHECK: [[FUNC_TO_BLOCK:%.*]] = function_ref @_TTRGRxs9AnyObjectx21objc_imported_generic7AnsiblerXFo_ox_ox_XFdCb_dx_ax_
81+
// CHECK: init_block_storage_header {{.*}} invoke [[FUNC_TO_BLOCK]]<T,{{.*}}>
7882

7983
// CHECK-LABEL: sil @_TF21objc_imported_generic20arraysOfGenericParam
8084
public func arraysOfGenericParam<T: AnyObject>(y: Array<T>) {

0 commit comments

Comments
 (0)