Skip to content

Commit 85891c9

Browse files
committed
[Test] Add tests for wrapped parameters in initializers.
1 parent 9500381 commit 85891c9

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

test/SILGen/property_wrapper_parameter.swift

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,76 @@ func genericWrapperCaller(projection: Projection<Int>) {
8181
// CHECK: function_ref @$s26property_wrapper_parameter18testGenericWrapper5valueyAA0F0VyxG_tlFACL_xvpfP : $@convention(thin) <τ_0_0> (@in τ_0_0) -> @out Wrapper<τ_0_0>
8282
}
8383

84+
@propertyWrapper
85+
struct ImplementationDetail<T> {
86+
var wrappedValue: T
87+
88+
// CHECK-LABEL: sil hidden [ossa] @$s26property_wrapper_parameter20ImplementationDetailV12wrappedValueACyxGx_tcfC : $@convention(method) <T> (@in T, @thin ImplementationDetail<T>.Type) -> @out ImplementationDetail<T>
89+
init(wrappedValue: T) {
90+
self.wrappedValue = wrappedValue
91+
}
92+
}
93+
94+
95+
struct TestStructInit {
96+
// property wrapper backing initializer of number #1 in TestStructInit.init(number:message:)
97+
// CHECK-LABEL: sil private [ossa] @$s26property_wrapper_parameter14TestStructInitV6number7messageAcA7WrapperVySiG_SStcfcADL_SivpfP : $@convention(thin) (Int) -> Wrapper<Int>
98+
99+
// property wrapper init from projected value of number #1 in TestStructInit.init(number:message:)
100+
// CHECK-LABEL: sil private [ossa] @$s26property_wrapper_parameter14TestStructInitV6number7messageAcA7WrapperVySiG_SStcfcADL_SivpfW : $@convention(thin) (Projection<Int>) -> Wrapper<Int>
101+
102+
// CHECK-LABEL: sil hidden [ossa] @$s26property_wrapper_parameter14TestStructInitV6number7messageAcA7WrapperVySiG_SStcfC : $@convention(method) (Wrapper<Int>, @owned String, @thin TestStructInit.Type) -> TestStructInit
103+
init(@Wrapper number: Int, @ImplementationDetail message: String) {
104+
// CHECK: debug_value %0 : $Wrapper<Int>, let, name "_number"
105+
// CHECK: debug_value %1 : $String, let, name "message"
106+
// CHECK: alloc_stack $ImplementationDetail<String>
107+
// CHECK" function_ref @$s26property_wrapper_parameter20ImplementationDetailV12wrappedValueACyxGx_tcfC : $@convention(method) <τ_0_0> (@in τ_0_0, @thin ImplementationDetail<τ_0_0>.Type) -> @out ImplementationDetail<τ_0_0>
108+
109+
_ = number
110+
_ = _number
111+
112+
_ = message
113+
_ = _message
114+
115+
// getter of number #1 in TestStructInit.init(number:message:)
116+
// CHECK-LABEL: sil private [ossa] @$s26property_wrapper_parameter14TestStructInitV6number7messageAcA7WrapperVySiG_SStcfcADL_Sivg : $@convention(thin) (Wrapper<Int>) -> Int
117+
118+
// getter of message #1 in TestStructInit.init(number:message:)
119+
// CHECK-LABEL: sil private [ossa] @$s26property_wrapper_parameter14TestStructInitV6number7messageAcA7WrapperVySiG_SStcfcAEL_SSvg : $@convention(thin) (@guaranteed ImplementationDetail<String>) -> @owned String
120+
}
121+
}
122+
123+
class TestClassInit {
124+
// property wrapper backing initializer of number #1 in TestClassInit.init(number:message:)
125+
// CHECK-LABEL: sil private [ossa] @$s26property_wrapper_parameter13TestClassInitC6number7messageAcA7WrapperVySiG_SStcfcADL_SivpfP : $@convention(thin) (Int) -> Wrapper<Int>
126+
127+
// property wrapper init from projected value of number #1 in TestClassInit.init(number:message:)
128+
// CHECK-LABEL: sil private [ossa] @$s26property_wrapper_parameter13TestClassInitC6number7messageAcA7WrapperVySiG_SStcfcADL_SivpfW : $@convention(thin) (Projection<Int>) -> Wrapper<Int>
129+
130+
// TestClassInit.__allocating_init(number:message:)
131+
// CHECK-LABEL: sil hidden [exact_self_class] [ossa] @$s26property_wrapper_parameter13TestClassInitC6number7messageAcA7WrapperVySiG_SStcfC : $@convention(method) (Wrapper<Int>, @owned String, @thick TestClassInit.Type) -> @owned TestClassInit
132+
// CHECK-NOT: alloc_stack $ImplementationDetail<String>
133+
134+
// CHECK-LABEL: sil hidden [ossa] @$s26property_wrapper_parameter13TestClassInitC6number7messageAcA7WrapperVySiG_SStcfc : $@convention(method) (Wrapper<Int>, @owned String, @owned TestClassInit) -> @owned TestClassInit
135+
init(@Wrapper number: Int, @ImplementationDetail message: String) {
136+
// CHECK: debug_value %0 : $Wrapper<Int>, let, name "_number"
137+
// CHECK: debug_value %1 : $String, let, name "message"
138+
// CHECK: alloc_stack $ImplementationDetail<String>
139+
140+
_ = number
141+
_ = _number
142+
143+
_ = message
144+
_ = _message
145+
146+
// getter of number #1 in TestClassInit.init(number:message:)
147+
// CHECK-LABEL: sil private [ossa] @$s26property_wrapper_parameter13TestClassInitC6number7messageAcA7WrapperVySiG_SStcfcADL_Sivg : $@convention(thin) (Wrapper<Int>) -> Int
148+
149+
// getter of message #1 in TestClassInit.init(number:message:)
150+
// CHECK-LABEL: sil private [ossa] @$s26property_wrapper_parameter13TestClassInitC6number7messageAcA7WrapperVySiG_SStcfcAEL_SSvg : $@convention(thin) (@guaranteed ImplementationDetail<String>) -> @owned String
151+
}
152+
}
153+
84154
@propertyWrapper
85155
public struct AutoClosureWrapper<T> {
86156
public var wrappedValue: T

0 commit comments

Comments
 (0)