Navigation Menu

Skip to content
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-5933] Cannot import public typealias #48492

Open
swift-ci opened this issue Sep 19, 2017 · 4 comments
Open

[SR-5933] Cannot import public typealias #48492

swift-ci opened this issue Sep 19, 2017 · 4 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself feature A feature request or implementation

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-5933
Radar None
Original Reporter aaroncrespo (JIRA User)
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, LanguageFeatureRequest
Assignee None
Priority Medium

md5: df21125d11b7876e33ef301be36c2cb7

Issue Description:

// fails
import typealias Foundation.Decimal.RoundingMode
// ok
import struct Foundation.Decimal

The spec says this should be possible

import-declarationattributes­opt­import­import-kind­opt­import-path­
import-kindtypealias­ struct­ class­ enum­ protocol­ let­ var­ func­
import-pathimport-path-identifier­ import-path-identifier­.­import-path­
import-path-identifieridentifier­ operator­
@belkadan
Copy link
Contributor

Something matching the grammar doesn't mean it does what you want it to. All components of an import path except the last are treated as module components at the moment.

@belkadan
Copy link
Contributor

I think the only sensible behavior for this would be to introduce RoundingMode into the top-level scope, which would be enough of a new feature to need the Swift Evolution Process.

@swift-ci
Copy link
Collaborator Author

Comment by aaron crespo (JIRA)

Thanks for commenting @belkadan this was just a minimal example of the import side of it. The usage side also has some quirks.

Similarly:

// ExposesSpecialString Module
public typelias SpecialString = String

public func format(specialString: SpecialString) {}

Has some very different behaviors:

import ExposesSpecialString
// SpecialString is in the name space now
// vs
import typealias ExposesSpecialString.SpecialString
// usually an error

Some open source Libraries under some circumstances support this. I'm not sure if some shadowing or namespace collisions are happening. EX: "import typealias RxSwift.Single".

Usually tho top level type aliases that aren't importable.

@belkadan
Copy link
Contributor

I'm not sure what you mean by "usually an error". The latter is supposed to work. If you have a test case where it doesn't, please attach it!

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself feature A feature request or implementation
Projects
None yet
Development

No branches or pull requests

2 participants