Using ImplicitlyUnwrappedOptional in v3.4 compatibility

foundation

(Sebastian Shanus) #1

This might be a silly question, but would the proposal to abolish Implicitly Unwrapped Optionals (https://github.com/apple/swift-evolution/blob/master/proposals/0054-abolish-iuo.md) cause IUOs to get removed when compiling a swift 4 target that depends on swift 3? Or did IUOs possibly also get removed in v3.4 as the proposal suggests, although I can't seem to find anything that supports or negates this.

For example, say we have an app target that compiles with swift v4 that depends on a target A which compiles with swift 3, the following code fails to compile inside Target A containing:

#if !swift(>=4.1.50)
extension ImplicitlyUnwrappedOptional {
...
}
#endif

The compiler throws "ImplicitlyUnwrappedOptional has been renamed to Optional", even though the target Swift Language Version is v3 where IUOs supposedly still are acceptable.


(Jordan Rose) #2

Check out "Reimplementation of Implicitly Unwrapped Optionals" on the Swift project blog. You're right, it is a source breakā€¦but the compiler didn't actually let you use the methods you defined on the IUO anyway, so it was considered an acceptable one. If it's protocols you were using, you can move them over to Optional and everything will be fine.


(Sebastian Shanus) #3

Ah I see. Thanks for the explanation!