@@ -57,3 +57,31 @@ struct Witness: OwnershipProto {
5757
5858// CHECK-LABEL: sil private [transparent] [thunk] [ossa] @$s15value_ownership7WitnessVAA14OwnershipProtoA2aDP17elidedPropertyGetSSvgTW :
5959// CHECK-LABEL: sil private [transparent] [thunk] [ossa] @$s15value_ownership7WitnessVAA14OwnershipProtoA2aDP19explicitPropertyGetSSvgTW :
60+
61+ // Check that references to a consuming getter are lowered properly.
62+
63+ func blackHole< T> ( _: T ) { }
64+
65+ // CHECK-LABEL: sil hidden [ossa] @$s15value_ownership25useConsumingGetterGenericyyxAA14OwnershipProtoRzlF : $@convention(thin) <T where T : OwnershipProto> (@in_guaranteed T) -> () {
66+ func useConsumingGetterGeneric< T : OwnershipProto > ( _ t: T ) {
67+ // CHECK: [[FN:%.*]] = witness_method $T, #OwnershipProto.explicitPropertyGet!getter : <Self where Self : OwnershipProto> (__owned Self) -> () -> String : $@convention(witness_method: OwnershipProto) <τ_0_0 where τ_0_0 : OwnershipProto> (@in τ_0_0) -> @owned String
68+ // CHECK-NEXT: apply [[FN]]<T>({{%.*}}) : $@convention(witness_method: OwnershipProto) <τ_0_0 where τ_0_0 : OwnershipProto> (@in τ_0_0) -> @owned String
69+
70+ blackHole ( t. explicitPropertyGet)
71+ }
72+
73+ // CHECK-LABEL: sil hidden [ossa] @$s15value_ownership29useConsumingGetterExistentialyyAA14OwnershipProto_pF : $@convention(thin) (@in_guaranteed OwnershipProto) -> () {
74+ func useConsumingGetterExistential( _ e: OwnershipProto ) {
75+ // CHECK: [[FN:%.*]] = witness_method $@opened("{{.*}}") OwnershipProto, #OwnershipProto.explicitPropertyGet!getter : <Self where Self : OwnershipProto> (__owned Self) -> () -> String, %2 : $*@opened("{{.*}}") OwnershipProto : $@convention(witness_method: OwnershipProto) <τ_0_0 where τ_0_0 : OwnershipProto> (@in τ_0_0) -> @owned String
76+ // CHECK-NEXT: apply [[FN]]<@opened("{{.*}}") OwnershipProto>({{%.*}}) : $@convention(witness_method: OwnershipProto) <τ_0_0 where τ_0_0 : OwnershipProto> (@in τ_0_0) -> @owned String
77+
78+ blackHole ( e. explicitPropertyGet)
79+ }
80+
81+ // CHECK-LABEL: sil hidden [ossa] @$s15value_ownership26useConsumingGetterConcreteyyAA7WitnessVF : $@convention(thin) (@guaranteed Witness) -> () {
82+ func useConsumingGetterConcrete( _ c: Witness ) {
83+ // CHECK: [[FN:%.*]] = function_ref @$s15value_ownership7WitnessV19explicitPropertyGetSSvg : $@convention(method) (@owned Witness) -> @owned String
84+ // CHECK-NEXT: apply [[FN]]({{%.*}}) : $@convention(method) (@owned Witness) -> @owned String
85+
86+ blackHole ( c. explicitPropertyGet)
87+ }
0 commit comments