java switch expressions: infer Object if one of branches has null type (IDEA-241470)

GitOrigin-RevId: 489d3413091cbd1a85348fae0a428e29b287f7e0
This commit is contained in:
Anna Kozlova
2020-05-25 21:31:52 +02:00
committed by intellij-monorepo-bot
parent 6324dc91a2
commit 8aafb282f3
2 changed files with 10 additions and 1 deletions

View File

@@ -116,4 +116,12 @@ class MyTest {
System.out.println(c.getCanonicalName());
}
static void testNull(int i) {
var v = switch(i) {
case 1 -> "abcd";
default -> null;
};
System.out.println(v.<error descr="Cannot resolve method 'substring' in 'Object'">substring</error>(1));
}
}