-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[GSB] When adding same-type requirements pick representative based on… #20646
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// RUN: %target-typecheck-verify-swift | ||
|
||
protocol C { | ||
associatedtype T : Collection where T.Element == Self | ||
} | ||
|
||
protocol V : C, RawRepresentable where RawValue == String {} | ||
|
||
protocol P { | ||
associatedtype A: V | ||
} | ||
|
||
extension P { | ||
func foo<U: Collection>(_ args: U) -> String where U.Element == A { | ||
return args.reduce("", { $1.rawValue }) // Ok | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ protocol P1 { | |
} | ||
|
||
protocol P2 { | ||
associatedtype T // expected-note {{found this candidate}} | ||
associatedtype T // expected-note 2 {{found this candidate}} | ||
} | ||
|
||
// FIXME: This extension's generic signature is still minimized differently from | ||
|
@@ -36,7 +36,7 @@ extension P1 where Self : P2 { | |
// Same as above, but now we have two visible associated types with the same | ||
// name. | ||
protocol P3 { | ||
associatedtype T | ||
associatedtype T // expected-note {{found this candidate}} | ||
} | ||
|
||
// FIXME: This extension's generic signature is still minimized differently from | ||
|
@@ -48,7 +48,7 @@ extension P2 where Self : P3, T == Int { | |
} | ||
|
||
extension P2 where Self : P3 { | ||
func takeT1(_: T) {} | ||
func takeT1(_: T) {} // expected-error {{'T' is ambiguous for type lookup in this context}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel like we've tripped over this specific bug in a number of places, where unqualified lookup is ambiguous but shouldn't be. I suspect your change isn't making it much worse in practice. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good! I'm going to work on other diagnostic... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I recently did some work to fix (some) of these cases. The |
||
func takeT2(_: Self.T) {} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a very nice simplification, thank you!