This code does not compile:
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) { //<- Object
case 1 -> i1;
case 2 -> null;
default -> i2;
};
if (i_ != null) {
i_.m(); //cannot find symbol m()
}
}
Javac infers Object instead of I, suggesting some issues around handling of `null` in switch expression.
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) { //<- Object
case 1 -> i1;
case 2 -> null;
default -> i2;
};
if (i_ != null) {
i_.m(); //cannot find symbol m()
}
}
Javac infers Object instead of I, suggesting some issues around handling of `null` in switch expression.