mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
24 lines
814 B
Swift
24 lines
814 B
Swift
// RUN: %target-swift-frontend -emit-silgen %s | FileCheck %s
|
|
|
|
protocol P {}
|
|
protocol Q {}
|
|
|
|
struct X: P, Q {}
|
|
|
|
func makePQ() -> protocol<P,Q> { return X() }
|
|
|
|
func useP(x: P) { }
|
|
|
|
// CHECK-LABEL: sil hidden @_TF18upcast_existential5PQtoPFT_T_ : $@convention(thin) () -> () {
|
|
func PQtoP() {
|
|
// CHECK: [[PQ_PAYLOAD:%.*]] = open_existential_addr [[PQ:%.*]]#1 : $*protocol<P, Q> to $*[[OPENED_TYPE:@opened(.*) protocol<P, Q>]]
|
|
// CHECK: [[P_PAYLOAD:%.*]] = init_existential_addr [[P:%.*]]#1 : $*P, $[[OPENED_TYPE]]
|
|
// CHECK: copy_addr [take] [[PQ_PAYLOAD]] to [initialization] [[P_PAYLOAD]]
|
|
// CHECK: deinit_existential_addr [[PQ]]#1
|
|
// CHECK-NOT: destroy_addr [[P]]
|
|
// CHECK-NOT: destroy_addr [[P_PAYLOAD]]
|
|
// CHECK-NOT: destroy_addr [[PQ]]
|
|
// CHECK-NOT: destroy_addr [[PQ_PAYLOAD]]
|
|
useP(makePQ())
|
|
}
|