-
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
Don't optimize explicitly written isInstanceOf tests away. #14715
Conversation
Do it only for tests generated during pattern matching. Fixes scala#14707. See the issue for a rationale of the change.
Alternative for #14709. |
This was quite a rabbit hole. First, I fixed the problem that even explicitly written |
Closed in favor of #14715 |
Closed in favor of alternative #14709 I admit I clicked the self-link, maybe more than once. |
Oops, I meant to close #14709 instead. |
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.
Seb to review, but LGTM
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.
Other than some changes that are apparently in the wrong commit (see below), LGTM.
class TypeTestAlwaysSucceeds(scrutTp: Type, testTp: Type)(using Context) extends SyntaxMsg(TypeTestAlwaysSucceedsID) { | ||
def msg = { | ||
val addendum = | ||
if (scrutTp != testTp) s" is a subtype of ${testTp.show}" | ||
else " is the same as the tested type" | ||
s"The highlighted type test will always succeed since the scrutinee type ${scrutTp.show}" + addendum | ||
} | ||
class TypeTestAlwaysDiverges(scrutTp: Type, testTp: Type)(using Context) extends SyntaxMsg(TypeTestAlwaysDivergesID) { | ||
def msg = | ||
s"This type test will never return a result since the scrutinee type ${scrutTp.show} does not contain any value." |
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.
These changes don't seem to belong to this commit.
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.
They are actually linked to the changes in TypeTestsCasts. We had an error TypeTestAlwaysSucceeds
before but now we have a TypeTestAlwaysDiverges
instead.
Do it only for tests generated during pattern matching.
Fixes #14705.
See the issue for a rationale of the change.