-
Bug
-
Resolution: Fixed
-
P5
-
5.0
Steve Sides points out that the compiler generates a strange compound type for this program:
interface I { }
class X { }
class A extends X implements I { }
class B extends X implements I { }
class Test {
void test(A a, B b) {
X x = (a.hashCode() == b.hashCode()) ? a : b;
}
}
Test.java:7: incompatible types
found : java.lang.Object&I&X
required: X
X x = (a.hashCode() == b.hashCode()) ? a : b;
^
1 error
The compound type should have been X&I and the assignment should have succeded.
###@###.### 2004-07-30
interface I { }
class X { }
class A extends X implements I { }
class B extends X implements I { }
class Test {
void test(A a, B b) {
X x = (a.hashCode() == b.hashCode()) ? a : b;
}
}
Test.java:7: incompatible types
found : java.lang.Object&I&X
required: X
X x = (a.hashCode() == b.hashCode()) ? a : b;
^
1 error
The compound type should have been X&I and the assignment should have succeded.
###@###.### 2004-07-30
- duplicates
-
JDK-6278798 Inferred lub contains two classes
- Closed
-
JDK-6348492 Compiler erroneously reports incompatible types in code using the ?: operator
- Closed
- relates to
-
JDK-6215213 crash: java.lang.AssertionError at com.sun.tools.javac.code.Types.containedBy(Types.java:792)
- Closed
-
JDK-5079756 Conditional operator misinterprets/mixes up access modifiers for polymorph
- Closed