Commit Graph

5 Commits

Author SHA1 Message Date
Mark Lacey
8b55a0f61b SE-0054: Rework diagnostics for IUOs and revise Swift 3 /4 semantics.
For Swift 3 / 4:

Deprecate the spelling "ImplicitlyUnwrappedOptional", emitting a warning
and suggesting "!" in places where they are allowed according to
SE-0054.

In places where SE-0054 disallowed IUOs but we continued to accept them
in previous compilers, emit a warning suggesting "Optional" or "?"  as
an alternative depending on context and treat the IUO as an Optional,
noting this in the diagnostic.

For Swift 5:

Treat "ImplicitlyUnwrappedOptional" as an error, suggesting
"!" in places where they are allowed by SE-0054.

In places where SE-0054 disallowed IUOs, emit an error suggestion
"Optional" or "?" as an alternative depending on context.
2017-11-18 11:41:53 +09:00
Mark Lacey
401d046581 More SE-0054 fixes for Swift version 5.
Fix a couple more places where we should not allow IUOs and add
additional tests for these as well as parallel tests for the long
spelling ImplicitlyUnwrappedOptional.
2017-11-06 20:02:57 -08:00
Mark Lacey
b38d967784 Ban IUOs in more places.
We were allowing them in parens in some contexts, but shouldn't have.

Also added tests for function types and tuple return types to ensure
we're not allowing them in these places.
2017-11-03 18:35:01 -07:00
Mark Lacey
cef6c9463c Fix more places where were allowing IUOs but shouldn't.
My previous commit, f9b82bccb7, failed to
ensure that IUOs could not be nested inside of other types in all
positions.
2017-10-31 18:58:55 -07:00
Mark Lacey
f9b82bccb7 Ban IUOs in illegal positions harder under Swift 5 and later.
SE-0054 specified that the use of implicitly unwrapped optionals was
limited to just a few places, but the implementation at the time did not
completely ban the other uses. This is another attempt to do so, but
it's only on for compilations in Swift 5 mode and later.

For earlier versions, we fall back on the existing implementation.

Fixes: rdar://problem/27707015
2017-10-26 22:21:36 -07:00