Open saagarjha opened 5 years ago
This is not a bug. Here is more information on the change that introduced the difference in behavior: https://swift.org/blog/iuo/
@rudkx, is it possible to provide migration step in this case? (The compiler does not support the old behavior, which would be one complication here.)
Environment
Xcode Version 10.1 beta 2 (10O35n)/macOS Mojave 10.14.1 Beta (18B57c)Additional Detail from JIRA
| | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug | |Assignee | None | |Priority | Medium | md5: 06108f60b3f6ca40049f9b361ff8f20eIssue Description:
I'm not quite sure this is a bug, but we had an issue with this in one of our apps that cropped up after we upgraded the version of Swift. Here's a quick code example that illustrates the problem:
Prior to Swift 4.2 this would print "int" because the Swift would pick
foo(_ int: Int)
by unwrapping the IUO. However, this now prints "any" because bar decays into an optional–so it picksfoo(_ any: Any?)
instead. The actual code was usingNSViewController.dismiss(_🙂
, which has two overloads for a parameter of typeAny?
andNSViewController
, but the underlying issue is the same. Is this a bug? If not, since this is a silent change in behavior, could we get a migration step would detect such usage and offer a warning with a fixit to unwrap the IUO or cast it to the method's type (i.e.foo(bar!)
orfoo(bar as Int)
)?