| // RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -primary-file %s -emit-ir | %FileCheck %s |
| sil_stage canonical |
| |
| public protocol P {} |
| public class C : P {} |
| public class D<T : P> {} |
| class E {} |
| |
| public protocol Observable { |
| associatedtype Result |
| func subscribe<T: Observer>(o: T) -> () |
| } |
| |
| public protocol Observer { |
| associatedtype Result |
| } |
| |
| sil hidden @witness_method : $@convention(thin) <S where S : Observable><O where O : Observer, S.Result == O.Result> (@in S) -> @owned @callee_owned (@in O) -> () { |
| bb0(%0 : $*S): |
| %1 = witness_method $S, #Observable.subscribe!1 : $@convention(witness_method) <τ_0_0 where τ_0_0 : Observable><τ_1_0 where τ_1_0 : Observer, τ_0_0.Result == τ_1_0.Result> (@in τ_1_0, @in_guaranteed τ_0_0) -> () |
| %2 = partial_apply %1<S, O>(%0) : $@convention(witness_method) <τ_0_0 where τ_0_0 : Observable><τ_1_0 where τ_1_0 : Observer, τ_0_0.Result == τ_1_0.Result> (@in τ_1_0, @in_guaranteed τ_0_0) -> () |
| return %2 : $@callee_owned (@in O) -> () |
| } |
| |
| // CHECK-LABEL: define internal %GC23partial_apply_forwarder1DCS_1C_* @_TPA_unspecialized_uncurried(%swift.refcounted* |
| // CHECK: [[TYPE:%.*]] = call %swift.type* @_TMaC23partial_apply_forwarder1C() |
| // CHECK: [[CAST:%.*]] = bitcast %swift.refcounted* %0 to %C23partial_apply_forwarder1E* |
| // CHECK: [[CALL:%.*]] = call %C23partial_apply_forwarder1D* @unspecialized_uncurried(%swift.type* [[TYPE]], i8** getelementptr inbounds ([0 x i8*], [0 x i8*]* @_TWPC23partial_apply_forwarder1CS_1PS_, i32 0, i32 0), %C23partial_apply_forwarder1E* [[CAST]]) |
| |
| sil hidden @specialized_curried : $@convention(thin) (@owned E) -> @owned @callee_owned () -> @owned D<C> { |
| bb0(%0 : $E): |
| %1 = function_ref @unspecialized_uncurried : $@convention(method) <τ_0_0 where τ_0_0 : P> (@guaranteed E) -> @owned D<τ_0_0> |
| %2 = partial_apply %1<C>(%0) : $@convention(method) <τ_0_0 where τ_0_0 : P> (@guaranteed E) -> @owned D<τ_0_0> |
| return %2 : $@callee_owned () -> @owned D<C> |
| } |
| |
| sil hidden_external @unspecialized_uncurried : $@convention(method) <τ_0_0 where τ_0_0 : P> (@guaranteed E) -> @owned D<τ_0_0> |
| |
| |
| // CHECK-LABEL: define internal void @_TPA_takingP(%swift.refcounted* |
| // CHECK: [[CONTEXT:%.*]] = alloca %swift.refcounted* |
| // CHECK: [[TYPE:%.*]] = call %swift.type* @_TMaC23partial_apply_forwarder1C |
| // CHECK: store %swift.refcounted* %0, %swift.refcounted** [[CONTEXT]] |
| // CHECK: [[CAST:%.*]] = bitcast %swift.refcounted** [[CONTEXT]] to %swift.opaque* |
| // CHECK: call void @takingP(%swift.type* [[TYPE]], i8**{{.*}}_TWPC23partial_apply_forwarder1CS_1PS_{{.*}}, %swift.opaque* {{.*}} [[CAST]] |
| // CHECK: ret |
| sil hidden_external @takingP : $@convention(method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> () |
| |
| sil hidden @reabstract_context : $@convention(thin) (@owned C) -> () { |
| bb0(%0 : $C): |
| %6 = alloc_stack $C |
| store %0 to %6 : $*C |
| %8 = function_ref @takingP : $@convention(method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> () |
| %9 = partial_apply %8<C>(%6) : $@convention(method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> () |
| dealloc_stack %6 : $*C |
| strong_release %9 : $@callee_owned() -> () |
| %10 = tuple () |
| return %10 : $() |
| } |
| |
| sil_vtable C {} |
| sil_vtable D {} |
| sil_vtable E {} |
| sil_witness_table C: P module main {} |