<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=""><div class="">Hi, Evan. Just a suspicion: do you also have a <i class="">type</i> named AppleTart? In that case you'd be hitting <a href="https://bugs.swift.org/browse/SR-898" class="">SR-898</a>, rather than a specific issue with extensions.</div><div class=""><br class=""></div><div class="">Jordan</div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On Mar 8, 2016, at 14:26, Evan Maloney via swift-users <<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">I recently ran into a situation where I needed to import a symbol with the same name from two different modules, and noticed that the usual Swift technique of disambiguating using the package name doesn't work when used with extensions.<br class=""><br class="">In my case, I have a package 'LegacyStore' and a package 'AppleTart', both of which contain a type named 'User'.<br class=""><br class="">In the case of LegacyStore, User is an Objective-C class, and in the case of AppleTart, User is a Swift struct.<br class=""><br class="">Normally, I'd be able to refer to one as 'LegacyStore.User' and the other as 'AppleTart.User', but when using this notation for an extension:<br class=""><br class=""> extension AppleTart.User<br class=""> {<br class=""> public var legacyUser: LegacyStore.User {<br class=""> // implementation<br class=""> }<br class=""> }<br class=""><br class="">...I get a compiler error on the extension declaration line:<br class=""><br class=""> error: 'User' is not a member type of 'AppleTart'<br class=""><br class="">Note that the 'LegacyStore.User' notation used in the var declaration never triggers a compiler error, so I'm assuming the notation just isn't supported yet in the context of declaring an extension.<br class=""><br class="">Fortunately, there's a (somewhat cumbersome) work-around, which is to create two separate files, one for each module. Within each file import just that one module, and create a typealias for each clashing name using package-qualified name of the type.<br class=""><br class="">For example, here's the relevant part of my AppleTartTypeDisambiguation.swift file:<br class=""><br class=""> import AppleTart<br class=""><br class=""> public typealias AppleTartUser = User<br class=""><br class="">And here's my LegacyStoreTypeDisambiguation.swift file:<br class=""><br class=""> import LegacyStore<br class=""><br class=""> public typealias LegacyUser = User<br class=""><br class="">I can then use the typealiases to extend either type. For example, here's how I successfully extended AppleTart.User:<br class=""><br class=""> extension AppleTartUser<br class=""> {<br class=""> public var legacyUser: LegacyStore.User {<br class=""> // implementation<br class=""> }<br class=""> }<br class=""><br class="">Should the inability to extend a type using the qualified type name be considered a compiler bug? I'm assuming yes. If so, I'll file a ticket.<br class=""><br class="">_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-users<br class=""></div></div></blockquote></div><br class=""></body></html>