-
Bug
-
Resolution: Fixed
-
P4
-
repo-valhalla
-
generic
-
generic
JEP 401 (https://openjdk.java.net/jeps/401) states:
// --
An abstract class can similarly be declared to implement either IdentityObject or PrimitiveObject; or, if it declares a field, an instance initializer, a non-empty constructor, or a synchronized method, it implicitly implements IdentityObject (perhaps with a warning). Otherwise, the abstract class extends neither interface and can be extended by both kinds of concrete classes.
// --
So this code should compile:
public abstract class X {
int f;
void foo(X x) {
IdentityObject i = x;
}
}
but as of now we get:
X.java:4: error: incompatible types: X cannot be converted to IdentityObject
IdentityObject i = x;
^
1 error
// --
An abstract class can similarly be declared to implement either IdentityObject or PrimitiveObject; or, if it declares a field, an instance initializer, a non-empty constructor, or a synchronized method, it implicitly implements IdentityObject (perhaps with a warning). Otherwise, the abstract class extends neither interface and can be extended by both kinds of concrete classes.
// --
So this code should compile:
public abstract class X {
int f;
void foo(X x) {
IdentityObject i = x;
}
}
but as of now we get:
X.java:4: error: incompatible types: X cannot be converted to IdentityObject
IdentityObject i = x;
^
1 error