Skip to content

Normalize match types before computing implicit scopes #20081

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

Closed
wants to merge 1 commit into from

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Apr 3, 2024

We now try to reduce match types before computing their contributions to an implicit scope. This avoids problems where joint and separate compilations gave different results, as in #20071 and #15183.

Background: If a match type is reducible to a type R the compiler is free to replace the match type with R. That should not affect the implicit scope computation. Consequently, we have to try to reduce match types before computing their contributions to an implicit scope.

#20071 and #15183 are really the same problem. Both used to compile in sequence and both gave an implicit not found error when two files were compiled together.

In #15183 a weird match type was constructed intentionally, in order to avoid an otherwise necessary given import. That exploited a bug in the compiler which this PR fixes.

Fixes #20071

@odersky odersky marked this pull request as ready for review April 3, 2024 13:17
We now try to reduce match types before computing their contributions to an implicit scope.
This avoids problems where joint and separate compilations gave different results, as in
scala#20071 and scala#15183.

Background: If a match type is reducible to a type R the compiler is free to replace the
match type with R. That should not affect the implicit scope computation. Consequently,
we have to try to reduce match types before computing their contributions to an implicit scope.

scala#20071 and scala#15183 are really the same problem. Both used to compile in sequence and both
gave an implicit not found error when two files were compiled together.

In scala#15183 a weird match type was constructed intentionally, in order to avoid an otherwise
necessary given import. That exploited a bug in the compiler which this PR fixes.
@odersky
Copy link
Contributor Author

odersky commented Apr 3, 2024

duplicate of #20077

@odersky odersky closed this Apr 3, 2024
@dwijnand dwijnand deleted the fix-20071 branch April 9, 2024 13:22
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.

Given leaked in outer scope
1 participant