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
structBadDiagnosis {
vara: A? = A()
varb: B {
a.flatMap(B.init(a:))
/// Cannot convert return expression of type 'B?' to return type 'B'/// fixit: Insert ' as! B'
}
}
structA { }
structB {
init(a: A) { }
}
Using the provided fixit:
structBadDiagnosis {
vara: A? = A()
varb: B {
a.flatMap(B.init(a:)) as! B/// Forced cast of 'B' to same type has no effect/// fixit: Remove 'as! B'
}
}
structA { }
structB {
init(a: A) { }
}
The fixits directly oppose each other.
The fixit should suggest to force unwrap the value:
a.flatMap(B.init(a:))!
or suggest making b an optional value:
varb: B?
The text was updated successfully, but these errors were encountered:
The correct warning for ` a.flatMap(B.init(a: )) as![]( Bshould be forced cast from 'B?' to 'B' only unwraps optionals; did you mean to use ')'?` with a fix-it for replace `as![]( Bwith)`. This is another mishandled edge case from migrating some conditional cast diagnostics from application to the fix format...
Also, I think we can do some extra work in the `cannot convert` error fix-it to be as you suggested, I'll take a look at this as soon as possible
Environment
MacOS 11.6
Swift version 5.5-dev
Xcode 13.0
Additional Detail from JIRA
md5: 08f9b38fc783fb8ad25eb5408181fa0c
Issue Description:
Example code:
Using the provided fixit:
The fixits directly oppose each other.
The fixit should suggest to force unwrap the value:
or suggest making b an optional value:
The text was updated successfully, but these errors were encountered: