Skip to content

[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

Merged
merged 3 commits into from
Nov 27, 2018

Conversation

xedin
Copy link
Contributor

@xedin xedin commented Nov 16, 2018

… canonical order

Instead of trying to order based on the "nested depth", let's
always prefer canonical ordering of type parameters when it comes
to picking representative equivalence class.

Resolves: rdar://problem/45957015

@xedin xedin requested a review from DougGregor November 16, 2018 21:16
@xedin
Copy link
Contributor Author

xedin commented Nov 16, 2018

@swift-ci please test source compatibility

unsigned nestingDepth2 = T2->getNestingDepth();
if (nestingDepth2 < nestingDepth1) {
// Pick representative based on the canonical ordering of the type parameters.
if (compareDependentTypes(depType2, depType1) < 0) {
Copy link
Member

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!

@@ -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}}
Copy link
Member

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good! I'm going to work on other diagnostic...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recently did some work to fix (some) of these cases. The extension Foo where Self : Bar looks like yet another one, though...

… canonical order

Instead of trying to order based on the "nested depth", let's
always prefer canonical ordering of type parameters when it comes
to picking representative equivalence class.

Resolves: rdar://problem/45957015
@xedin
Copy link
Contributor Author

xedin commented Nov 24, 2018

@DougGregor This patch is ready for you to take another look, I made it so duplicate same-type diagnostics are now produces in source order even if canonical ordering is completely different.

@xedin
Copy link
Contributor Author

xedin commented Nov 24, 2018

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - ce2ef435711b2ea092dc023a00db0a39691ee153

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - ce2ef435711b2ea092dc023a00db0a39691ee153

@xedin
Copy link
Contributor Author

xedin commented Nov 24, 2018

@swift-ci please smoke test Linux platform

Instead of using `std::sort`, transform source-ordered edge vector
to reference `IntercomponentEdge *` instead of their indices in
`intercomponentEdges` vector and use `llvm::array_pod_sort` to sort them.
@xedin
Copy link
Contributor Author

xedin commented Nov 26, 2018

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - ab3d1f5

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - ab3d1f5

@xedin
Copy link
Contributor Author

xedin commented Nov 26, 2018

@swift-ci please test source compatibility

@xedin xedin merged commit d2d8f70 into swiftlang:master Nov 27, 2018
@DougGregor
Copy link
Member

How interesting! This pull request broke the tests I just tried to add for https://bugs.swift.org/browse/SR-8767, which had been fixed on master before that (hence my attempt at merging #20795). I wonder if we were getting lucky, or if there's something deeper that we didn't notice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants