You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some of these are currently failing. For example:
```swift
// expected-error {{cannot convert value of type 'Int??' to specified type 'Int'}}
let _: Int = try? producer.produceDoubleOptionalInt()
```
This actually produces this warning:
```
value of optional type 'Int?' not unwrapped; did you mean to use 'try!' or chain with '?'?
```
Note that the value in question is not an `Int?`, so a suggestion of `try!` here is inappropriate.
(And, due to the change in semantics of 'try?', wouldn't change anything anyway.)
let _:Int=try? optProducer?.produceInt() // expected-error {{value of optional type 'Int?' not unwrapped; did you mean to use 'try!' or chain with '?'?}}
242
+
let _:String=try? optProducer?.produceInt() // expected-error {{cannot convert value of type 'Int?' to specified type 'String'}}
243
+
let _:Int?=try? optProducer?.produceIntNoThrowing() // expected-warning {{no calls to throwing functions occur within 'try' expression}}
244
+
245
+
let _:Int??=try? optProducer?.produceInt() // This was the expected type before Swift 5, but this still works; just adds more optional-ness
246
+
247
+
let _:Int?=(try? optProducer?.produceAny())as?Int // good
248
+
let _:Int?=try? optProducer?.produceAny()as?Int // good
249
+
let _:Int??=try? optProducer?.produceAny()as?Int // good
250
+
let _:String=try? optProducer?.produceAny()as?Int // expected-error {{cannot convert value of type 'Int?' to specified type 'String'}}
251
+
252
+
let _:Int?=try? optProducer?.produceDoubleOptionalInt() // expected-error {{value of optional type 'Int??' not unwrapped; did you mean to use 'try!' or chain with '?'?}}
253
+
let _:String=try? optProducer?.produceDoubleOptionalInt() // expected-error {{cannot convert value of type 'Int??' to specified type 'String'}}
254
+
let _:String=try? optProducer?.produceDoubleOptionalInt() // expected-error {{cannot convert value of type 'Int??' to specified type 'String'}}
255
+
256
+
letproducer=ThingProducer()
257
+
258
+
let _:Int=try? producer.produceDoubleOptionalInt() // expected-error {{cannot convert value of type 'Int??' to specified type 'Int'}}
259
+
let _:Int?=try? producer.produceDoubleOptionalInt() // expected-error {{value of optional type 'Int??' not unwrapped; did you mean to use 'try!' or chain with '?'?}}
260
+
let _:Int??=try? producer.produceDoubleOptionalInt() // good
261
+
let _:Int???=try? producer.produceDoubleOptionalInt() // good
262
+
let _:String=try? producer.produceDoubleOptionalInt() // expected-error {{cannot convert value of type 'Int??' to specified type 'String'}}
0 commit comments