<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><blockquote style="margin:0px 0px 16px;padding:0px 1em;border-left:0.25em solid rgb(221,221,221);background-color:rgb(255,255,255)"><div style="margin-top:0px;margin-bottom:0px"><font color="#777777" face="-apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol" size="3"><a href="https://github.com/apple/swift-evolution/blob/master/proposals/0140-bridge-optional-to-nsnull.md" target="_blank">https://github.com/apple/<wbr>swift-evolution/blob/master/<wbr>proposals/0140-bridge-<wbr>optional-to-nsnull.md</a></font></div></blockquote><ul style="padding-left:2em;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,blinkmacsystemfont,&quot;segoe ui&quot;,roboto,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px;background-color:rgb(255,255,255)"><li>What is your evaluation of the proposal?</li></ul></div></blockquote><div>I tend to agree with other commenters that NSNull does not seem like an obviously-correct (or -unsurprising) solution to this problem. Rather than getting &quot;unexpectedly found nil&quot; errors like in Swift, this would start causing more obtuse errors about missing methods on NSNull.</div><div><br></div><div>Users could simply be forced to write `?? NSNull()` if they really want to use NSNull.<br></div><div><br></div><div>I do think that a warning/error for Optional&lt;T&gt;-to-Any conversion should be added; something like:</div><div><br></div><div>    - (void)test:(id _Nonnull)arg;</div><div>    let x: Int? = 3</div><div>    test(x)  // passing optional type &#39;Int?&#39; to &#39;Any&#39; parameter uses an opaque wrapper; use &#39;as Any&#39; to silence this warning</div><div><br></div><div>Although, I&#39;m not sure that would be a complete solution, because you could still get around it with generic algorithms. This example is contrived, but:</div><div><br></div><div>    extension Array {</div><div>        func asAnys() -&gt; [Any] {</div><div>            return map { $0 as Any }    // no warning here; $0&#39;s type is Element, not known whether optional or non-optional</div><div>        }</div><div>    }</div><div><br></div><div>It might be nice for this warning to occur *only* when passing values to Obj-C methods. Swift code written using Any would handle them correctly. However, I&#39;m not sure that&#39;s possible, given that the Obj-C importer recently started using Any instead of AnyObject on purpose to make Obj-C code more like Swift code in that way.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><ul style="padding-left:2em;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,blinkmacsystemfont,&quot;segoe ui&quot;,roboto,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px;background-color:rgb(255,255,255)"><li style="margin-top:0.25em">Is the problem being addressed significant enough to warrant a change to Swift?</li></ul></div></blockquote><div>Definitely; the current behavior is surprising and dangerous.</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><ul style="padding-left:2em;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,blinkmacsystemfont,&quot;segoe ui&quot;,roboto,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px;background-color:rgb(255,255,255)"><li style="margin-top:0.25em">Does this proposal fit well with the feel and direction of Swift?</li></ul></div></blockquote><div>Not really; it seems like a Cocoa-ism leaking into the purity/safety of Swift, more so than most bridging behavior, although perhaps I&#39;m only saying this because NSNull is much less commonly used than the most other bridged types.</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><ul style="padding-left:2em;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,blinkmacsystemfont,&quot;segoe ui&quot;,roboto,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px;background-color:rgb(255,255,255)"><li style="margin-top:0.25em">If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?</li></ul></div></blockquote><div>N/A</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><ul style="padding-left:2em;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,blinkmacsystemfont,&quot;segoe ui&quot;,roboto,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px;background-color:rgb(255,255,255)"><li style="margin-top:0.25em">How much effort did you put into your review? A glance, a quick reading, or an in-depth study?</li></ul></div></blockquote><div>A quick reading of the proposal, plus some experimentation in a sample project and discussion with others in Slack about an occurrence of the motivating problem.</div><div><br></div></div></div></div>