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

Detect case where two alternatives are the same after widening ExprTypes #18787

Merged
merged 4 commits into from
Oct 30, 2023

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Oct 29, 2023

In implicit or extension method search we might get two alternatives that are different but that point to the same singleton type after widening ExprTypes. In that case we can arbitrarily pick one of them instead of declaring an ambiguity.

Fixes #18768

In implicit or extension method search we might get two alternatives that are different
but that point to the same singleton type after widening ExprTypes. In that case we can
arbitrarily pick one of them instead of declaring an ambiguity.

Fixes scala#18768
@benhutchison
Copy link
Contributor

TY for the fix 🙏

@odersky
Copy link
Contributor Author

odersky commented Oct 30, 2023

@benhutchison You are very welcome! The good minimization helped a lot.

Copy link
Member

@dwijnand dwijnand left a comment

Choose a reason for hiding this comment

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

LGTM, just some performance questions. Shall we run benchmarks seeing as we're adding the usage of =:= and widening to what was originally just int and boolean comparison?

if (winsType2) 0 else 1
if winsType1 && winsType2
&& alt1.widenExpr =:= alt2.widenExpr
&& alt1.widenExpr.isStable
Copy link
Member

Choose a reason for hiding this comment

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

Check is isStable first, for performance?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, good idea.

@odersky
Copy link
Contributor Author

odersky commented Oct 30, 2023

I think with the swap in conditions you suggested there are no worries about performance anymore. Merging

@odersky odersky merged commit 6dbdc74 into scala:main Oct 30, 2023
18 checks passed
@odersky odersky deleted the fix-18768 branch October 30, 2023 18:28
@Kordyjan Kordyjan added this to the 3.4.0 milestone Dec 20, 2023
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.

Ambiguous Extension Method when Exported
4 participants