-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add special handling for comparisons with Singleton types #20474
Merged
Conversation
This file contains 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
smarter
approved these changes
May 28, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but this might need equivalent handling in tasty-query /cc @sjrd
I don't think the rule in this PR is correct: class A
class B extends A
def f(a: A, c: A) =
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
val d1: b1.type = a
val d2: b2.type = a // ok
val d3: b3.type = a // error
val d4: b4.type = a // error In 3.4.2: > scala-cli compile -S 3.4 Stest.scala
Compiling project (Scala 3.4.2, JVM (21))
[error] ./Stest.scala:324:21
[error] Found: (a : A)
[error] Required: (b3 : (c : A) & A)
[error] val d3: b3.type = a // error
[error] ^
[error] ./Stest.scala:325:21
[error] Found: (a : A)
[error] Required: (b4 : (a : A) | (c : A))
[error] val d4: b4.type = a // error
[error] ^
Error compiling project (Scala 3.4.2, JVM (21))
Compilation failed cc @sjrd |
odersky
added a commit
to dotty-staging/dotty
that referenced
this pull request
May 28, 2024
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
added a commit
that referenced
this pull request
May 28, 2024
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
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.
Fixes #15030