Files
swift-mirror/test/Parse/optional.swift
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

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?>()