-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SR-898] Unresolvable "ambiguous for type lookup" error when using multiple modules #43510
Comments
Needs design. |
Comment by Evan Maloney (JIRA) I've hit this issue as well, and have discovered that it doesn't require the use of generics to trigger it. In my case, I have a package In the case of Normally, I'd be able to refer to one as extension AppleTart.User
{
public var legacyUser: LegacyStore.User {
// implementation
}
} ...I get a compiler error on the extension declaration line: error: 'User' is not a member type of 'AppleTart' Note that the 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. For example, here's the relevant part of my import AppleTart
public typealias AppleTartUser = User And here's my import LegacyStore
public typealias LegacyUser = User I can then use the typealiases to extend either type. For example, here's how I successfully extended extension AppleTartUser
{
public var legacyUser: LegacyStore.User {
// implementation
}
} After circulating the problem above to the Swift-Users mailing list, @belkadan reached out with a (correct) hunch that the underlying problem was that I have a type that has the same name as the module. In fact, the |
Comment by Vladimir Shabanov (JIRA) Please fix. There are problems with importing custom obj-c error classes (descendants of NSError) even from single custom Obj-C framework to Swift app. |
Also see SR-14142 where this missing language feature is causing emitted swiftinterface files to fail to compile. |
Environment
Apple Swift version 2.1.1 (swiftlang-700.1.101.15 clang-700.1.81) / Xcode Version 7.2.1 (7C1002) / iOS 9.2
Additional Detail from JIRA
md5: ea3a4fb46f14a67b99d4cb07142d5803
blocks:
is duplicated by:
Issue Description:
Given two modules with the same type, where one module has a type that has the same name as the module itself with generic parameters it will become impossible to explicitly refer to the type you want.
Example
Module A:
Module B:
The app:
Expected behaviour
Only
ambiguousError
should give an error, the other two error constants should work since the module is specified to prevent ambiguous type errors.What happend instead
The error we get with
B.NoError
isReference to generic type 'B' requires arguments in <...>
. The compiler incorrectly assumes we are referring tostruct B
instead of the module B. This makes it impossible to fix the ambiguity.Workaround
It is possible to work around this by creating a
typealias
in a seperate file where we only import module B and theretypealias BNoError = NoError
then we can use theBNoError
as the type oflet errorB
to work around the issue.The text was updated successfully, but these errors were encountered: