[swift-evolution] Swift Extensions on Overlay Structs

Fabian Ehrentraud Fabian.Ehrentraud at willhaben.at
Fri Nov 11 02:08:40 CST 2016


Hi list,

Since Swift 3 there exist overlay structs, e.g. NSURL gets bridged to URL.
Unfortunately now extensions on URL are not getting bridged back to ObjC:


extension URL {
	func doSomething() -> URL {
		return self.absoluteURL
	}
}

+ (NSURL *)swiftStructExtensionCaller {
	NSURL *url = [NSURL URLWithString:@"https://apple.github.io/swift-evolution/"];
	return [url doSomething];
}

The compiler does not see the method `doSomething`. Is this on purpose, or something that has yet to be improved?

I'm aware that I could write the extension on NSURL, but that would mean a lot of casting on the Swift side.


  -- Fabian


More information about the swift-evolution mailing list