Merged
Conversation
As usual, OrTypes need to be excluded. a.type | b.type is not effectively a singleton. It seems to be an easy trap to fall into. Follow-up to scala#20474
noti0na1
reviewed
May 28, 2024
| val b1: a.type = a | ||
| val b2: a.type & B = a.asInstanceOf[a.type & B] | ||
| val b3: c.type & A = c | ||
| val b4: a.type | c.type = c |
Member
There was a problem hiding this comment.
Can you add the test below for OrType as well?
val b5: a.type | a.type = a
val d5: b5.type = a // ok
Contributor
Author
There was a problem hiding this comment.
I don't think that will work. Have you tried it? I see no strong reason to make it work.
Member
There was a problem hiding this comment.
It works in 3.4.2: https://scastie.scala-lang.org/A6PehvQvRhW2sUPVVtHiuA
I think the atoms is doing all these checks.
Contributor
Author
There was a problem hiding this comment.
Ah, yes, atoms would do it. Bit it's an extreme corner case. Not sure we want to make sure it works in the general case. Because in this case we'd also have to accept
val b6: (a.type & A) | a.type
val d6: b6.type = a // okand I am not sure atoms would help us here.
Contributor
Author
|
I propose we merge without further refinements, since it plugs a recent soundness hole. |
noti0na1
approved these changes
May 28, 2024
WojciechMazur
added a commit
that referenced
this pull request
Jul 9, 2024
Backports #20486 to the LTS branch. PR submitted by the release tooling. [skip ci]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As usual, OrTypes need to be excluded. a.type | b.type is not effectively a singleton. It seems to be an easy trap to fall into.
Follow-up to #20474