-
Bug
-
Resolution: Fixed
-
P4
-
repo-valhalla
-
None
-
generic
-
generic
Thanks to Maurizio for reporting this:
// -- X.java
sealed interface Foo permits Bar { }
primitive class Bar implements Foo { }
class Test {
void test(Object o) {
Foo foo = (Foo)o;
}
}
$javac -g X.java
X.java:6: error: incompatible types: Object cannot be converted to Foo
Foo foo = (Foo)o;
^
1 error
Error goes away if interface is not sealed.
// -- X.java
sealed interface Foo permits Bar { }
primitive class Bar implements Foo { }
class Test {
void test(Object o) {
Foo foo = (Foo)o;
}
}
$javac -g X.java
X.java:6: error: incompatible types: Object cannot be converted to Foo
Foo foo = (Foo)o;
^
1 error
Error goes away if interface is not sealed.