<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Nov 13, 2016, at 11:43 PM, Fabian Ehrentraud via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class="">

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" class="">

<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
That's an interesting idea without having to write type signatures twice.
<div class=""><br class="">
</div>
<div class="">The different nullability of the absoluteURL is strange indeed - what if I do a guaranteed cast from NSURL to URL, and absoluteURL would have been nil in the original object?</div></div></div></blockquote><div><br class=""></div>Much of the nullability of struct URL changed (for the better) because we removed the reason for it possibly being nil in NSURL: file reference URLs.</div><div><br class=""></div><div>What happens on bridging is that we resolve the file reference URL to a real URL. If this fails, then the struct URL points to a specific invalid URL:</div><div><br class=""></div><div><a href="https://github.com/apple/swift/blob/master/stdlib/public/SDK/Foundation/URL.swift#L1129" class="">https://github.com/apple/swift/blob/master/stdlib/public/SDK/Foundation/URL.swift#L1129</a></div><div><br class=""></div><div>In practice file reference URLs are actually pretty rare. And anyway, if the file reference URL was invalid upon bridging it would have been invalid when you tried to use it from Swift later anyway.</div><div><br class=""></div><div>- Tony</div><div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div class=""><br class="">
</div>
<div class="">Eiher way, I'd really like to know if URL extensions could be bridged too without casting in a future Swift version.</div>
<div class=""><br class="">
</div>
<div class="">&nbsp; -- Fabian</div>
<div class=""><br class="">
<div class=""><br class="">
<div class="">
<blockquote type="cite" class="">
<div class="">On 13 Nov 2016, at 03:45, Dennis Lysenko &lt;<a href="mailto:dennis.s.lysenko@gmail.com" class="">dennis.s.lysenko@gmail.com</a>&gt; wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="ltr" class="">Hmm... would it be possible to define a protocol like "UnifiedURLType", define each of the properties you need to work with inside your extension functions as protocol properties inside the protocol UnifiedURLType&nbsp;{} declaration, create
 an extension UnifiedURLType&nbsp;{} and include doSomething() inside the extension, and then create extensions on both URL and NSURL causing them to conform to UnifiedURLType? (extension URL: UnifiedURLType {}; extension NSURL: UnifiedURLType {})
<div class=""><br class="">
</div>
<div class="">You could try it, but I wouldn't hold my breath, especially if you're planning on using absoluteURL within your extension as something as basic as the type of that variable is already different between the two types.&nbsp;</div>
<div class=""><br class="">
</div>
<div class="">Dennis</div>
</div>
<br class="">
<div class="gmail_quote">
<div dir="ltr" class="">On Fri, Nov 11, 2016 at 3:08 AM Fabian Ehrentraud via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class="">
</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi list,<br class="gmail_msg">
<br class="gmail_msg">
Since Swift 3 there exist overlay structs, e.g. NSURL gets bridged to URL.<br class="gmail_msg">
Unfortunately now extensions on URL are not getting bridged back to ObjC:<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
extension URL {<br class="gmail_msg">
&nbsp; &nbsp; &nbsp; &nbsp; func doSomething() -&gt; URL {<br class="gmail_msg">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return self.absoluteURL<br class="gmail_msg">
&nbsp; &nbsp; &nbsp; &nbsp; }<br class="gmail_msg">
}<br class="gmail_msg">
<br class="gmail_msg">
+ (NSURL *)swiftStructExtensionCaller {<br class="gmail_msg">
&nbsp; &nbsp; &nbsp; &nbsp; NSURL *url = [NSURL URLWithString:@"<a href="https://apple.github.io/swift-evolution/" rel="noreferrer" class="gmail_msg" target="_blank">https://apple.github.io/swift-evolution/</a>"];<br class="gmail_msg">
&nbsp; &nbsp; &nbsp; &nbsp; return [url doSomething];<br class="gmail_msg">
}<br class="gmail_msg">
<br class="gmail_msg">
The compiler does not see the method `doSomething`. Is this on purpose, or something that has yet to be improved?<br class="gmail_msg">
<br class="gmail_msg">
I'm aware that I could write the extension on NSURL, but that would mean a lot of casting on the Swift side.<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
&nbsp; -- Fabian<br class="gmail_msg">
_______________________________________________<br class="gmail_msg">
swift-evolution mailing list<br class="gmail_msg">
<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg">
</blockquote>
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</div>

_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></body></html>