-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Allow Null in isInstanceOf checks #14897
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
Conversation
With -Yexplicit-nulls Null is a class like any other. No reason to treat it specially in type tests. Besides, as scala#14896 shows these type tests might not be user-written. Aside: Going through the issues I have noted much higher-breakage rates than usual in everything that concerns type test optimization and diagnostics. I don't think we can afford much more breakage in this area. In the future, we should try harder to err on the side of caution, which means no second guessing of what the programmer wrote or what a previous phase generated. Default to a runtime test, unless you know with 100% certainty that no possible scenario would be affected by that test's outcome. Fixes scala#14896
I really don't think this is the correct fix. It's been argued and concluded many times over the years that Even with |
I would actually go the other way. We have argued endlessly about |
I've always thought Java's rule that Although it seems a radical departure from the semantics of Java, the JVM, and Scala 2, if I understand correctly the outcome of One remaining question is whether or not this should hold only with |
Ideally, |
But without
all that while |
Yes, I think the only way to explain this is to say that, for the purposes of type tests, |
Setting aside for a moment the debate over |
@griggt Ah yes, I see now. I agree we should treat |
So this has nothing to do with #14896 after all, but is related to nullability. With explicit nulls, the logical thing to do would be this PR + a change that makes type tests against In any case it's better to close this PR now and revisit it once explicit nulls is the default. |
With -Yexplicit-nulls Null is a class like any other. No reason to treat it specially
in type tests.
Aside: Going through the issues I have noted much higher-breakage rates than usual
in everything that concerns type test optimization and diagnostics. I don't think we
can afford much more breakage in this area. In the future, we should try harder to
err on the side of caution, which means no second guessing of what the programmer
wrote or what a previous phase generated. Default to a runtime test, unless you
know with 100% certainty that no possible scenario would be affected by that test's outcome.