mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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.
18 lines
382 B
Swift
18 lines
382 B
Swift
// RUN: %target-typecheck-verify-swift
|
|
|
|
struct A {
|
|
func foo() {}
|
|
}
|
|
|
|
var a : A?
|
|
var b : A ? // expected-error {{consecutive statements on a line}} {{10-10=;}} expected-error {{expected expression}}
|
|
|
|
var c = a? // expected-error {{'?' must be followed by a call, member lookup, or subscript}}
|
|
var d : ()? = a?.foo()
|
|
|
|
var e : (() -> A)?
|
|
var f = e?()
|
|
|
|
struct B<T> {}
|
|
var g = B<A?>()
|