java switch expressions: reverted previous commit on inferring type with null result expressions (IDEA-251801)

appeared to be a javac bug, filed https://mail.openjdk.java.net/pipermail/compiler-dev/2020-September/015075.html

GitOrigin-RevId: 74bb18f3b3d82cdfbbad77a883d826b52549b9ab
This commit is contained in:
Anna Kozlova
2020-10-02 09:20:57 +02:00
committed by intellij-monorepo-bot
parent abf23250c3
commit ee301e1ee9
2 changed files with 26 additions and 13 deletions

View File

@@ -116,12 +116,30 @@ class MyTest {
System.out.println(c.getCanonicalName());
}
static void testNull(int i) {
var v = switch(i) {
case 1 -> "abcd";
default -> null;
interface I {
void m();
}
interface I1 extends I {}
interface I2 extends I {}
static void n(I1 i1, I2 i2, int s) {
var i_ = switch (s) {
case 1 -> i1;
case 2 -> null;
default -> i2;
};
System.out.println(v.<error descr="Cannot resolve method 'substring' in 'Object'">substring</error>(1));
if (i_ != null) {
i_.m();
}
var i__ = switch (s) {
case 2 -> null;
case 1 -> i1;
default -> i2;
};
if (i__ != null) {
i__.m();
}
}
}