Skip to content

Commit 203c304

Browse files
committed
[Test] Add tests for wrapped argument coercions.
1 parent 84123cb commit 203c304

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

test/SILGen/property_wrapper_parameter.swift

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ func simpleWrapperParameterCaller(projection: Projection<Int>) {
5252

5353
testSimpleWrapperParameter($value: projection)
5454
// CHECK: function_ref @$s26property_wrapper_parameter26testSimpleWrapperParameter5valueyAA0F0VySiG_tFACL_SivpfW : $@convention(thin) (Projection<Int>) -> Wrapper<Int>
55+
56+
var x: Int = 10
57+
testSimpleWrapperParameter(value: x)
58+
// CHECK: function_ref @$s26property_wrapper_parameter26testSimpleWrapperParameter5valueyAA0F0VySiG_tFACL_SivpfP : $@convention(thin) (Int) -> Wrapper<Int>
5559
}
5660

5761
// CHECK-LABEL: sil [ossa] @$s26property_wrapper_parameter18testGenericWrapper5valueyAA0F0VyxG_tlF : $@convention(thin) <T> (@in_guaranteed Wrapper<T>) -> ()
@@ -71,6 +75,41 @@ func genericWrapperCaller(projection: Projection<Int>) {
7175

7276
testGenericWrapper($value: projection)
7377
// CHECK: function_ref @$s26property_wrapper_parameter18testGenericWrapper5valueyAA0F0VyxG_tlFACL_xvpfW : $@convention(thin) <τ_0_0> (@in Projection<τ_0_0>) -> @out Wrapper<τ_0_0>
78+
79+
var x: Int = 10
80+
testGenericWrapper(value: x)
81+
// CHECK: function_ref @$s26property_wrapper_parameter18testGenericWrapper5valueyAA0F0VyxG_tlFACL_xvpfP : $@convention(thin) <τ_0_0> (@in τ_0_0) -> @out Wrapper<τ_0_0>
82+
}
83+
84+
@propertyWrapper
85+
public struct AutoClosureWrapper<T> {
86+
public var wrappedValue: T
87+
88+
// CHECK-LABEL: sil [ossa] @$s26property_wrapper_parameter18AutoClosureWrapperV12wrappedValueACyxGxyXK_tcfC : $@convention(method) <T> (@noescape @callee_guaranteed @substituted <τ_0_0> () -> @out τ_0_0 for <T>, @thin AutoClosureWrapper<T>.Type) -> @out AutoClosureWrapper<T>
89+
public init(wrappedValue: @autoclosure () -> T) {
90+
self.wrappedValue = wrappedValue()
91+
}
92+
93+
public var projectedValue: Projection<T> {
94+
Projection(wrappedValue: wrappedValue)
95+
}
96+
97+
public init(projectedValue: Projection<T>) {
98+
self.wrappedValue = projectedValue.wrappedValue
99+
}
100+
}
101+
102+
// CHECK-LABEL: sil hidden [ossa] @$s26property_wrapper_parameter22testAutoClosureWrapper5valueyAA0efG0VyxG_tlF : $@convention(thin) <T> (@in_guaranteed AutoClosureWrapper<T>) -> ()
103+
func testAutoClosureWrapper<T>(@AutoClosureWrapper value: T) {
104+
// property wrapper backing initializer of value #1 in testAutoClosureWrapper<A>(value:)
105+
// CHECK-LABEL: sil private [ossa] @$s26property_wrapper_parameter22testAutoClosureWrapper5valueyAA0efG0VyxG_tlFACL_xvpfP : $@convention(thin) <T> (@noescape @callee_guaranteed @substituted <τ_0_0> () -> @out τ_0_0 for <T>) -> @out AutoClosureWrapper<T>
106+
// CHECK: function_ref @$s26property_wrapper_parameter18AutoClosureWrapperV12wrappedValueACyxGxyXK_tcfC : $@convention(method) <τ_0_0> (@noescape @callee_guaranteed @substituted <τ_0_0> () -> @out τ_0_0 for <τ_0_0>, @thin AutoClosureWrapper<τ_0_0>.Type) -> @out AutoClosureWrapper<τ_0_0>
107+
}
108+
109+
// CHECK-LABEL: sil hidden [ossa] @$s26property_wrapper_parameter24autoClosureWrapperCalleryyF : $@convention(thin) () -> ()
110+
func autoClosureWrapperCaller() {
111+
testAutoClosureWrapper(value: 10)
112+
// CHECK: function_ref @$s26property_wrapper_parameter22testAutoClosureWrapper5valueyAA0efG0VyxG_tlFACL_xvpfP : $@convention(thin) <τ_0_0> (@noescape @callee_guaranteed @substituted <τ_0_0> () -> @out τ_0_0 for <τ_0_0>) -> @out AutoClosureWrapper<τ_0_0>
74113
}
75114

76115
// CHECK-LABEL: sil hidden [ossa] @$s26property_wrapper_parameter33testSimpleClosureWrapperParameteryyF : $@convention(thin) () -> ()

0 commit comments

Comments
 (0)