File tree Expand file tree Collapse file tree 1 file changed +23
-4
lines changed Expand file tree Collapse file tree 1 file changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -183,13 +183,32 @@ func test_implicit_cgfloat_conversion() {
183
183
let cgf : CGFloat = 0.0
184
184
185
185
test_to ( d) // Ok (Double -> CGFloat
186
- test_to ( f) // error
186
+ test_to ( f) // expected-error {{cannot convert value of type 'Float' to expected argument type 'CGFloat'}}
187
+ test_to ( d + d) // Ok (Double -> CGFloat for both arguments)
188
+ test_to ( d + cgf) // Ok
189
+ test_to ( d + cgf - d) // Ok
190
+ test_to ( d + cgf - cgf) // Ok (only one choice here to conver `d` to CGFloat)
187
191
188
192
test_from ( cgf) // Ok (CGFloat -> Double)
189
- test_from ( f) // error
193
+ test_from ( f) // expected-error {{cannot convert value of type 'Float' to expected argument type 'Double'}}
194
+ test_from ( cgf + cgf) // Ok (CGFloat -> Double for both arguments)
195
+ test_from ( d + cgf) // Ok
196
+ test_from ( cgf + d - cgf) // Ok
197
+ test_from ( cgf + d - d) // Ok (only one choice here to conver `cgf` to Double)
198
+
199
+ func test_returns_double( _: CGFloat ) -> Double {
200
+ 42.0
201
+ }
202
+
203
+ func test_returns_cgfloat( _: Double ) -> CGFloat {
204
+ 42.0
205
+ }
206
+
207
+ test_to ( test_returns_double ( d) ) // Ok (two implicit conversions here `d` -> CGFloat & result of `test_returns_double` to CGFloat)
208
+ test_from ( test_returns_cgfloat ( cgf) ) // Ok (same as above by in other direction)
190
209
191
210
let _: CGFloat = d // Ok
192
- let _: CGFloat = f // error
211
+ let _: CGFloat = f // expected- error {{cannot convert value of type 'Float' to specified type 'CGFloat'}}
193
212
let _: Double = cgf // Ok
194
- let _: Float = cgf // error
213
+ let _: Float = cgf // expected- error {{cannot convert value of type 'CGFloat' to specified type 'Float'}}
195
214
}
You can’t perform that action at this time.
0 commit comments