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-13127] Typealias does not seem to transmit constraints to extensions #55573

Closed
swift-ci opened this issue Jul 1, 2020 · 0 comments
Closed
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Jul 1, 2020

Previous ID SR-13127
Radar None
Original Reporter GarthSnyder (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate
Environment

This is in Swift 5.3, Xcode 12 beta.

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: 4d67a947e489e53e7164a59f491d1ee0

duplicates:

  • SR-12817 Nested generic typealias extensions apply to the parent type.

Issue Description:

First, some code that does what I would expect:

struct Generic<T> {}
typealias Specific = Generic<Int>
 
extension Generic {
    func identify() { print("Any T") }
}
extension Specific {
    func identify() { print("T is Int") }
}
Generic<String>().identify()  // Any T
Generic<Int>().identify()     // T is Int
Specific().identify()         // T is Int

From this, it seems as if "extension Specific" is correctly interpreted as "extension Generic where T == Int".

However, the mechanism does not seem to generalize properly to typealiases that have only partial constraints:

struct Generic<A, B> {}
typealias Specific<T> = Generic<T, Int>
extension Generic {
    func identify() { print("Any B") }
}
 
extension Specific {
    func identify() { print("B is Int") }  // ERROR: Invalid redeclaration of 'identify()'
}

This error seems to suggest that "extension Specific" is interpreted identically to "extension Generic". The fact that Specific is Generic<_, Int> seems to have gotten lost.

Is this the intended behavior?

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
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
Projects
None yet
Development

No branches or pull requests

1 participant