// RUN: %target-sil-opt %s | %target-sil-opt | %FileCheck %s sil_stage canonical import Swift struct S { var x: Int let y: String var z: C } class C { final var x: Int final let y: String final var z: S init() var overridable: Int { get set } } protocol P {} protocol Q {} protocol R {} struct Gen { var x: A let y: B var z: C } // CHECK-LABEL: sil shared @stored_properties sil shared @stored_properties : $@convention(thin) () -> () { entry: // CHECK: keypath $WritableKeyPath, (root $S; stored_property #S.x : $Int) %a = keypath $WritableKeyPath, (root $S; stored_property #S.x : $Int) // CHECK: keypath $ReferenceWritableKeyPath, (root $C; stored_property #C.x : $Int) %b = keypath $ReferenceWritableKeyPath, (root $C; stored_property #C.x : $Int) // CHECK: keypath $KeyPath, (root $S; stored_property #S.y : $String) %c = keypath $KeyPath, (root $S; stored_property #S.y : $String) // CHECK: keypath $ReferenceWritableKeyPath, (root $S; stored_property #S.z : $C; stored_property #C.x : $Int) %d = keypath $ReferenceWritableKeyPath, (root $S; stored_property #S.z : $C; stored_property #C.x : $Int) return undef : $() } // CHECK-LABEL: sil shared @stored_properties_generic sil shared @stored_properties_generic : $@convention(thin) () -> () { entry: // CHECK: keypath $WritableKeyPath, D>, <τ_0_0, τ_0_1, τ_0_2 where {{.*}}> (root $Gen<τ_0_0, τ_0_1, τ_0_2>; stored_property #Gen.x : $τ_0_0) %a = keypath $WritableKeyPath, D>, (root $Gen; stored_property #Gen.x : $G) // CHECK: keypath $KeyPath, E>, <τ_0_0, τ_0_1, τ_0_2 where {{.*}}> (root $Gen<τ_0_0, τ_0_1, τ_0_2>; stored_property #Gen.y : $τ_0_1) %b = keypath $KeyPath, E>, (root $Gen; stored_property #Gen.y : $H) return undef : $() } sil @id_a : $@convention(thin) () -> () sil @get_s_int : $@convention(thin) (@in S, @thick S.Type) -> @out Int sil @set_s_int : $@convention(thin) (@in Int, @in S, @thick S.Type) -> () sil @get_c_int : $@convention(thin) (@in C, @thick C.Type) -> @out Int sil @set_c_int : $@convention(thin) (@in Int, @in C, @thick C.Type) -> () sil @get_fns_fnc : $@convention(thin) (@in @callee_owned (@in S) -> @out S, @thick ((S) -> S).Type) -> @out @callee_owned (@in C) -> @out C sil @set_fns_fnc : $@convention(thin) (@in @callee_owned (@in C) -> @out C, @in @callee_owned (@in S) -> @out S, @thick ((S) -> S).Type) -> () // CHECK-LABEL: sil shared @computed_properties sil shared @computed_properties : $@convention(thin) () -> () { entry: // CHECK: keypath $KeyPath, (root $S; gettable_property $Int, id @id_a : $@convention(thin) () -> (), getter @get_s_int : $@convention(thin) (@in S, @thick S.Type) -> @out Int) %a = keypath $KeyPath, (root $S; gettable_property $Int, id @id_a : $@convention(thin) () -> (), getter @get_s_int : $@convention(thin) (@in S, @thick S.Type) -> @out Int) // CHECK: keypath $WritableKeyPath, (root $S; settable_property $Int, id @id_a : $@convention(thin) () -> (), getter @get_s_int : $@convention(thin) (@in S, @thick S.Type) -> @out Int, setter @set_s_int : $@convention(thin) (@in Int, @in S, @thick S.Type) -> ()) %b = keypath $WritableKeyPath, (root $S; settable_property $Int, id @id_a : $@convention(thin) () -> (), getter @get_s_int : $@convention(thin) (@in S, @thick S.Type) -> @out Int, setter @set_s_int : $@convention(thin) (@in Int, @in S, @thick S.Type) -> ()) // CHECK: keypath $WritableKeyPath<(S) -> S, (C) -> C>, (root $(S) -> S; settable_property $(C) -> C, id @id_a : $@convention(thin) () -> (), getter @get_fns_fnc : $@convention(thin) (@in @callee_owned (@in S) -> @out S, @thick ((S) -> S).Type) -> @out @callee_owned (@in C) -> @out C, setter @set_fns_fnc : $@convention(thin) (@in @callee_owned (@in C) -> @out C, @in @callee_owned (@in S) -> @out S, @thick ((S) -> S).Type) -> ()) %c = keypath $WritableKeyPath<(S) -> S, (C) -> C>, (root $(S) -> S; settable_property $(C) -> C, id @id_a : $@convention(thin) () -> (), getter @get_fns_fnc : $@convention(thin) (@in @callee_owned (@in S) -> @out S, @thick ((S) -> S).Type) -> @out @callee_owned (@in C) -> @out C, setter @set_fns_fnc : $@convention(thin) (@in @callee_owned (@in C) -> @out C, @in @callee_owned (@in S) -> @out S, @thick ((S) -> S).Type) -> ()) // CHECK: keypath $WritableKeyPath, (root $C; settable_property $Int, id #C.overridable!getter.1 : (C) -> () -> Int, getter @get_c_int : $@convention(thin) (@in C, @thick C.Type) -> @out Int, setter @set_c_int : $@convention(thin) (@in Int, @in C, @thick C.Type) -> ()) %d = keypath $WritableKeyPath, (root $C; settable_property $Int, id #C.overridable!getter.1 : (C) -> () -> Int, getter @get_c_int : $@convention(thin) (@in C, @thick C.Type) -> @out Int, setter @set_c_int : $@convention(thin) (@in Int, @in C, @thick C.Type) -> ()) return undef : $() } sil @get_gen_a : $@convention(thin) (@in Gen) -> @out X1 sil @set_gen_a : $@convention(thin) (@in X2, @in Gen) -> () // CHECK-LABEL: sil shared @computed_properties_generic sil shared @computed_properties_generic : $@convention(thin) () -> () { entry: // CHECK: keypath $KeyPath, D>, <τ_0_0, τ_0_1, τ_0_2 where τ_0_0 : P, τ_0_1 : Q, τ_0_2 : R> (root $Gen<τ_0_0, τ_0_1, τ_0_2>; settable_property $τ_0_0, id @id_a : $@convention(thin) () -> (), getter @get_gen_a : $@convention(thin) <τ_0_0, τ_0_1, τ_0_2 where τ_0_0 : P, τ_0_1 : Q, τ_0_2 : R> (@in Gen<τ_0_0, τ_0_1, τ_0_2>) -> @out τ_0_0, setter @set_gen_a : $@convention(thin) <τ_0_0, τ_0_1, τ_0_2 where τ_0_0 : P, τ_0_1 : Q, τ_0_2 : R> (@in τ_0_0, @in Gen<τ_0_0, τ_0_1, τ_0_2>) -> ()) %a = keypath $KeyPath, D>, (root $Gen; settable_property $G, id @id_a : $@convention(thin) () -> (), getter @get_gen_a : $@convention(thin) (@in Gen) -> @out X3, setter @set_gen_a : $@convention(thin) (@in X4, @in Gen) -> ()) return undef : $() }