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

Fix #19746: Do not follow param term refs in isConcrete. #20015

Merged
merged 1 commit into from
Apr 4, 2024

Conversation

sjrd
Copy link
Member

@sjrd sjrd commented Mar 25, 2024

Term refs that reference term parameters can be substituted later by more precise ones, which can lead to different instantiations of type captures. They must therefore be considered as non concrete when following baseTypes to captures in variant positions, like we do for type param refs and other substitutable references.

We actually rewrite isConcrete in the process to be more based on an "allow list" of things we know to be concrete, rather than an "exclusion list" of things we know to be non-concrete. That should make it more straightforward to evaluate the validity of the algorithm.

Term refs that reference term parameters can be substituted later
by more precise ones, which can lead to different instantiations
of type captures. They must therefore be considered as non concrete
when following `baseType`s to captures in variant positions, like
we do for type param refs and other substitutable references.

We actually rewrite `isConcrete` in the process to be more based
on an "allow list" of things we know to be concrete, rather than
an "exclusion list" of things we know to be non-concrete. That
should make it more straightforward to evaluate the validity of
the algorithm.
@sjrd sjrd linked an issue Mar 25, 2024 that may be closed by this pull request
@sjrd
Copy link
Member Author

sjrd commented Mar 25, 2024

Huh, I'm surprised this didn't break anything in the (small) community build. 😅

Anyway, seems good to review, then.

@sjrd sjrd requested review from odersky and Gedochao March 25, 2024 18:53
Copy link
Contributor

@odersky odersky left a comment

Choose a reason for hiding this comment

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

LGTM

isConcrete(tp1.underlying)
case tp1: RecType =>
isConcrete(tp1.underlying)
case tp1: AndOrType =>
Copy link
Contributor

Choose a reason for hiding this comment

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

Note to @noti0na1 : This will need to be updated for flexibletypes.

@odersky odersky assigned Gedochao and unassigned odersky and Gedochao Mar 27, 2024
@sjrd sjrd merged commit 0a3497b into scala:main Apr 4, 2024
19 checks passed
@sjrd sjrd deleted the fix-i19746-match-type-unsoundness branch April 4, 2024 14:05
@Kordyjan Kordyjan added this to the 3.5.0 milestone May 10, 2024
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.

Unsound reduction of match types
4 participants