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-8692] Type aliases in stdlib protocol extensions not considered in generic constraints #51205

Closed
AnthonyLatsis opened this issue Sep 4, 2018 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@AnthonyLatsis
Copy link
Collaborator

Previous ID SR-8692
Radar None
Original Reporter @AnthonyLatsis
Type Bug
Environment

Xcode 9.4.1 (9F2000)

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

md5: c318547b7dea44e767266078f5c0a83d

Issue Description:

extension Collection {
  typealias R = Element
}

func foo<U: Collection, T>(_ arg: U) where U.R == T {}
// 'U' does not have a member type named 'R'; did you mean 'R'?

protocol P {
  associatedtype Foo: Collection
}
extension P { typealias Element = Foo.Element }

func foo<U: P, T>(_ arg: U) where U.Element == T {} // Ok
@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@slavapestov
Copy link
Member

Fixed on main:

x.swift:5:46: error: 'R' was defined in extension of protocol 'Collection' and cannot be referenced from a 'where' clause
func foo<U: Collection, T>(_ arg: U) where U.R == T {}
                                             ^
x.swift:5:25: error: generic parameter 'T' is not used in function signature
func foo<U: Collection, T>(_ arg: U) where U.R == T {}
                        ^
x.swift:13:37: error: 'Element' was defined in extension of protocol 'P' and cannot be referenced from a 'where' clause
func foo<U: P, T>(_ arg: U) where U.Element == T {} // Ok
                                    ^
x.swift:11:25: note: consider moving 'Element' into the definition of protocol 'P'
extension P { typealias Element = Foo.Element }
                        ^
x.swift:13:16: error: generic parameter 'T' is not used in function signature
func foo<U: P, T>(_ arg: U) where U.Element == T {} // Ok

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

2 participants