@@ -5,6 +5,7 @@ struct Wrapper<T> {
5
5
var wrappedValue : T
6
6
var projectedValue : Wrapper { self }
7
7
8
+ // CHECK-LABEl: sil hidden [ossa] @$s22property_wrapper_local7WrapperV12wrappedValueACyxGx_tcfC : $@convention(method) <T> (@in T, @thin Wrapper<T>.Type) -> @out Wrapper<T>
8
9
init ( wrappedValue: T ) {
9
10
self . wrappedValue = wrappedValue
10
11
}
@@ -65,7 +66,7 @@ func testInitialValue() {
65
66
// CHECK-LABEL: sil hidden [ossa] @$s22property_wrapper_local16testInitialValueyyF : $@convention(thin) () -> () {
66
67
67
68
@Wrapper var value : Int = 10
68
- // CHECK: function_ref @$s22property_wrapper_local16testInitialValueyyF5valueL_SivpfP : $@convention(thin) (Int ) -> Wrapper<Int >
69
+ // CHECK: function_ref @$s22property_wrapper_local7WrapperV12wrappedValueACyxGx_tcfC : $@convention(method) <τ_0_0> (@in τ_0_0, @thin Wrapper<τ_0_0>.Type ) -> @out Wrapper<τ_0_0 >
69
70
70
71
value = 15
71
72
// CHECK: function_ref @$s22property_wrapper_local16testInitialValueyyF5valueL_Sivs : $@convention(thin) (Int, @guaranteed { var Wrapper<Int> }) -> ()
@@ -77,15 +78,14 @@ func testInitialValue() {
77
78
// CHECK-NOT: assign_by_wrapper
78
79
79
80
// CHECK: return
80
-
81
- // CHECK-LABEL: sil private [ossa] @$s22property_wrapper_local16testInitialValueyyF5valueL_SivpfP : $@convention(thin) (Int) -> Wrapper<Int> {
82
81
}
83
82
84
83
@propertyWrapper
85
84
enum Lazy < Value> {
86
85
case uninitialized( ( ) -> Value )
87
86
case initialized( Value )
88
87
88
+ // CHECK-LABEL: sil hidden [ossa] @$s22property_wrapper_local4LazyO12wrappedValueACyxGxyXA_tcfC : $@convention(method) <Value> (@owned @callee_guaranteed @substituted <τ_0_0> () -> @out τ_0_0 for <Value>, @thin Lazy<Value>.Type) -> @out Lazy<Value>
89
89
init ( wrappedValue initialValue: @autoclosure @escaping ( ) -> Value ) {
90
90
self = . uninitialized( initialValue)
91
91
}
@@ -111,19 +111,65 @@ func testLocalLazy() {
111
111
// CHECK-LABEL: sil hidden [ossa] @$s22property_wrapper_local13testLocalLazyyyF : $@convention(thin) () -> () {
112
112
113
113
@Lazy var value = " hello! "
114
- // CHECK: [[C:%.*]] = function_ref @$s22property_wrapper_local13testLocalLazyyyFSSycfu_SSycfu0_ : $@convention(thin) () -> @owned String
115
- // CHECK: [[C2:%.*]] = thin_to_thick_function [[C]] : $@convention(thin) () -> @owned String to $@callee_guaranteed () -> @owned String
116
- // CHECK: [[I:%.*]] = function_ref @$s22property_wrapper_local13testLocalLazyyyF5valueL_SSvpfP : $@convention(thin) (@owned @callee_guaranteed () -> @owned String) -> @owned Lazy<String>
117
- //CHECK: apply [[I]]([[C2]])
114
+ // CHECK: function_ref @$s22property_wrapper_local13testLocalLazyyyFSSycfu_ : $@convention(thin) () -> @owned String
115
+ // CHECK: [[I:%.*]] = function_ref @$s22property_wrapper_local4LazyO12wrappedValueACyxGxyXA_tcfC : $@convention(method) <τ_0_0> (@owned @callee_guaranteed @substituted <τ_0_0> () -> @out τ_0_0 for <τ_0_0>, @thin Lazy<τ_0_0>.Type) -> @out Lazy<τ_0_0>
116
+ //CHECK: apply [[I]]<String>
118
117
119
118
_ = value
120
119
// CHECK: function_ref @$s22property_wrapper_local13testLocalLazyyyF5valueL_SSvg : $@convention(thin) (@guaranteed { var Lazy<String> }) -> @owned String
121
120
122
-
123
- // property wrapper backing initializer of value #1 in testLocalLazy()
124
- // CHECK-LABEL: sil private [ossa] @$s22property_wrapper_local13testLocalLazyyyF5valueL_SSvpfP : $@convention(thin) (@owned @callee_guaranteed () -> @owned String) -> @owned Lazy<String> {
125
-
126
121
// getter of value #1 in testLocalLazy()
127
122
// CHECK-LABEL: sil private [ossa] @$s22property_wrapper_local13testLocalLazyyyF5valueL_SSvg : $@convention(thin) (@guaranteed { var Lazy<String> }) -> @owned String {
128
123
// CHECK: function_ref @$s22property_wrapper_local4LazyO12wrappedValuexvg : $@convention(method) <τ_0_0> (@inout Lazy<τ_0_0>) -> @out τ_0_0
129
124
}
125
+
126
+ @propertyWrapper
127
+ struct BoundedNumber < T: Numeric & Comparable > {
128
+ private let min : T
129
+ private let max : T
130
+ var value : T
131
+
132
+ var wrappedValue : T {
133
+ get { value }
134
+ set {
135
+ if value < min {
136
+ value = min
137
+ } else if value > max {
138
+ value = max
139
+ }
140
+ }
141
+ }
142
+
143
+ // CHECK-LABEL: sil hidden [ossa] @$s22property_wrapper_local13BoundedNumberV12wrappedValue3min3maxACyxGx_xxtcfC : $@convention(method) <T where T : Comparable, T : Numeric> (@in T, @in T, @in T, @thin BoundedNumber<T>.Type) -> @out BoundedNumber<T>
144
+ init ( wrappedValue: T , min: T , max: T ) {
145
+ self . min = min
146
+ self . max = max
147
+
148
+ if wrappedValue < min {
149
+ self . value = min
150
+ } else if wrappedValue > max {
151
+ self . value = max
152
+ } else {
153
+ self . value = wrappedValue
154
+ }
155
+ }
156
+ }
157
+
158
+ func testLocalReference( count: Int ) {
159
+ // CHECK-LABEL: sil hidden [ossa] @$s22property_wrapper_local18testLocalReference5countySi_tF : $@convention(thin) (Int) -> ()
160
+
161
+ @BoundedNumber ( min: 0 , max: count) var value = 10
162
+ // CHECK: function_ref @$s22property_wrapper_local13BoundedNumberV12wrappedValue3min3maxACyxGx_xxtcfC : $@convention(method) <τ_0_0 where τ_0_0 : Comparable, τ_0_0 : Numeric> (@in τ_0_0, @in τ_0_0, @in τ_0_0, @thin BoundedNumber<τ_0_0>.Type) -> @out BoundedNumber<τ_0_0>
163
+
164
+ _ = value
165
+ // CHECK: function_ref @$s22property_wrapper_local18testLocalReference5countySi_tF5valueL_Sivg : $@convention(thin) (@guaranteed { var BoundedNumber<Int> }) -> Int
166
+
167
+ value = count
168
+ // CHECK: function_ref @$s22property_wrapper_local18testLocalReference5countySi_tF5valueL_Sivs : $@convention(thin) (Int, @guaranteed { var BoundedNumber<Int> }) -> ()
169
+
170
+ // getter of value #1 in testLocalReference(count:)
171
+ // CHECK: sil private [ossa] @$s22property_wrapper_local18testLocalReference5countySi_tF5valueL_Sivg : $@convention(thin) (@guaranteed { var BoundedNumber<Int> }) -> Int
172
+
173
+ // setter of value #1 in testLocalReference(count:)
174
+ // CHECK: sil private [ossa] @$s22property_wrapper_local18testLocalReference5countySi_tF5valueL_Sivs : $@convention(thin) (Int, @guaranteed { var BoundedNumber<Int> }) -> ()
175
+ }
0 commit comments