File tree Expand file tree Collapse file tree 5 files changed +35
-4
lines changed Expand file tree Collapse file tree 5 files changed +35
-4
lines changed Original file line number Diff line number Diff line change @@ -1254,7 +1254,6 @@ void IRGenModule::emitSILWitnessTable(SILWitnessTable *wt) {
1254
1254
// / Generic functions and protocol witnesses carry polymorphic parameters.
1255
1255
bool irgen::hasPolymorphicParameters (CanSILFunctionType ty) {
1256
1256
switch (ty->getRepresentation ()) {
1257
- case SILFunctionTypeRepresentation::CFunctionPointer:
1258
1257
case SILFunctionTypeRepresentation::Block:
1259
1258
// Should never be polymorphic.
1260
1259
assert (!ty->isPolymorphic () && " polymorphic C function?!" );
@@ -1265,6 +1264,7 @@ bool irgen::hasPolymorphicParameters(CanSILFunctionType ty) {
1265
1264
case SILFunctionTypeRepresentation::Method:
1266
1265
return ty->isPolymorphic ();
1267
1266
1267
+ case SILFunctionTypeRepresentation::CFunctionPointer:
1268
1268
case SILFunctionTypeRepresentation::ObjCMethod:
1269
1269
// May be polymorphic at the SIL level, but no type metadata is actually
1270
1270
// passed.
Original file line number Diff line number Diff line change @@ -17,8 +17,11 @@ typedef NSObject<IAMProto> * IAMProto_t;
17
17
void mutateSomeState (IAMProto_t)
18
18
__attribute__((swift_name(" IAMProto.mutateSomeState(self:)" )));
19
19
20
- void mutateSomeStateWithOtherProto (IAMProto_t, IAMProto_t other)
21
- __attribute__((swift_name(" IAMProto.mutateSomeState(self:otherProto:)" )));
20
+ void mutateSomeStateWithParameter (IAMProto_t, NSInteger )
21
+ __attribute__((swift_name(" IAMProto.mutateSomeState(self:withParameter:)" )));
22
+
23
+ void mutateSomeStateWithFirstParameter (NSInteger , IAMProto_t)
24
+ __attribute__((swift_name(" IAMProto.mutateSomeState(withFirstParameter:self:)" )));
22
25
23
26
int getSomeValue (IAMProto_t)
24
27
__attribute__((swift_name(" getter:IAMProto.someValue(self:)" )));
Original file line number Diff line number Diff line change 58
58
// PRINT-PROTO-NEXT: typealias IAMProto_t = IAMProto
59
59
// PRINT-PROTO-NEXT: extension IAMProto {
60
60
// PRINT-PROTO-NEXT: func mutateSomeState()
61
- // PRINT-PROTO-NEXT: func mutateSomeState(otherProto other: IAMProto_t!)
61
+ // PRINT-PROTO-NEXT: func mutateSomeState(withParameter _: Int)
62
+ // PRINT-PROTO-NEXT: func mutateSomeState(withFirstParameter _: Int)
62
63
// PRINT-PROTO-NEXT: var someValue: Int32
63
64
// PRINT-PROTO-NEXT: }
64
65
Original file line number Diff line number Diff line change 1
1
// RUN: %target-swift-frontend -emit-ir -verify -I %S/../IDE/Inputs/custom-modules %s
2
+ // REQUIRES: objc_interop
2
3
3
4
sil_stage canonical
4
5
@@ -9,6 +10,7 @@ import ImportAsMember
9
10
sil @IAMStruct1CreateSimple : $@convention(c) () -> Struct1
10
11
sil @IAMStruct1Rotate : $@convention(c) (@in Struct1, Double) -> Struct1
11
12
sil @IAMStruct1SetAltitude : $@convention(c) (@inout Struct1, Double) -> ()
13
+ sil @mutateSomeState : $@convention(c) <τ_0_0 where τ_0_0 : IAMProto> (τ_0_0) -> ()
12
14
13
15
sil @invoke_methods : $@convention(thin) (Double) -> () {
14
16
entry(%z : $Double):
@@ -23,3 +25,14 @@ entry(%z : $Double):
23
25
dealloc_stack %c : $*Struct1
24
26
return undef : $()
25
27
}
28
+
29
+ // CHECK-LABEL: define void @invoke_protocol_methods(%objc_object*)
30
+ sil @invoke_protocol_methods : $@convention(thin) (IAMProto) -> () {
31
+ entry(%z : $IAMProto):
32
+ %a = open_existential_ref %z : $IAMProto to $@opened("01234567-89AB-CDEF-0123-000000000000") IAMProto
33
+ %b = function_ref @mutateSomeState : $@convention(c) <τ_0_0 where τ_0_0 : IAMProto> (τ_0_0) -> ()
34
+ // CHECK: [[CAST:%.*]] = bitcast %objc_object* %0 to i8*
35
+ // CHECK: call void @mutateSomeState(i8* [[CAST]])
36
+ apply %b<@opened("01234567-89AB-CDEF-0123-000000000000") IAMProto>(%a) : $@convention(c) <τ_0_0 where τ_0_0 : IAMProto> (τ_0_0) -> ()
37
+ return undef : $()
38
+ }
Original file line number Diff line number Diff line change @@ -237,3 +237,17 @@ public func bar(x: Double) {
237
237
c ( )
238
238
}
239
239
240
+ // CHECK-LABEL: sil @_TF10cf_members16importAsProtocolFPSo8IAMProto_T_
241
+ public func importAsProtocol( x: IAMProto_t ) {
242
+ // CHECK: function_ref @mutateSomeState : $@convention(c) <τ_0_0 where τ_0_0 : IAMProto> (τ_0_0) -> ()
243
+ x. mutateSomeState ( )
244
+ // CHECK: function_ref @mutateSomeStateWithParameter : $@convention(c) <τ_0_0 where τ_0_0 : IAMProto> (τ_0_0, Int) -> ()
245
+ x. mutateSomeState ( withParameter: 0 )
246
+ // CHECK: function_ref @mutateSomeStateWithFirstParameter : $@convention(c) <τ_0_0 where τ_0_0 : IAMProto> (Int, τ_0_0) -> ()
247
+ x. mutateSomeState ( withFirstParameter: 0 )
248
+
249
+ // CHECK: function_ref @getSomeValue : $@convention(c) <τ_0_0 where τ_0_0 : IAMProto> (τ_0_0) -> Int32
250
+ let y = x. someValue
251
+ // CHECK: function_ref @setSomeValue : $@convention(c) <τ_0_0 where τ_0_0 : IAMProto> (τ_0_0, Int32) -> Int32
252
+ x. someValue = y
253
+ }
You can’t perform that action at this time.
0 commit comments