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
Copy file name to clipboardExpand all lines: test/Parse/try.swift
+5-3Lines changed: 5 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -236,12 +236,14 @@ struct ThingProducer {
236
236
}
237
237
238
238
letoptProducer:ThingProducer?=ThingProducer()
239
-
let _:Int?=try? optProducer?.produceInt() // expected-error {{value of optional type 'Int??' not unwrapped; did you mean to use 'try!' or chain with '?'?}}
239
+
// In Swift 4 mode try? always adds a new level of optionality so suggesting `try!` doesn't really help in these examples.
240
+
let _:Int?=try? optProducer?.produceInt() // expected-error {{cannot convert value of type 'Int??' to specified type 'Int?'}}
240
241
let _:Int=try? optProducer?.produceInt() // expected-error {{cannot convert value of type 'Int??' to specified type 'Int'}}
241
242
let _:String=try? optProducer?.produceInt() // expected-error {{cannot convert value of type 'Int??' to specified type 'String'}}
242
243
let _:Int??=try? optProducer?.produceInt() // good
243
244
244
-
let _:Int?=try? optProducer?.produceIntNoThrowing() // expected-error {{value of optional type 'Int??' not unwrapped; did you mean to use 'try!' or chain with '?'?}}
245
+
let _:Int?=try? optProducer?.produceIntNoThrowing() // expected-error {{cannot convert value of type 'Int??' to specified type 'Int?'}}
246
+
// expected-warning@-1 {{no calls to throwing functions occur within 'try' expression}}
245
247
let _:Int??=try? optProducer?.produceIntNoThrowing() // expected-warning {{no calls to throwing functions occur within 'try' expression}}
246
248
247
249
let _:Int?=(try? optProducer?.produceAny())as?Int // good
let _:Int=try? producer.produceDoubleOptionalInt() // expected-error {{cannot convert value of type 'Int???' to specified type 'Int'}}
258
+
let _:Int=try? producer.produceDoubleOptionalInt() // expected-error {{value of optional type 'Int???' not unwrapped; did you mean to use 'try!' or chain with '?'?}}
257
259
let _:Int?=try? producer.produceDoubleOptionalInt() // expected-error {{value of optional type 'Int???' not unwrapped; did you mean to use 'try!' or chain with '?'?}}
258
260
let _:Int??=try? producer.produceDoubleOptionalInt() // expected-error {{value of optional type 'Int???' not unwrapped; did you mean to use 'try!' or chain with '?'?}}
259
261
let _:Int???=try? producer.produceDoubleOptionalInt() // good
0 commit comments