-
Bug
-
Resolution: Duplicate
-
P5
-
None
-
8
This program doesn't compile when source is set to a value other than 8 (the example is a bit more verbose than necessary, to get better output):
interface Bar<X extends Bar<X>> { }
class Test {
<A extends Bar<A>> void test() {
A result = m();
}
<B extends Bar<B>> B m() {
return null;
}
}
Error:
/opt/JDK/8/re/b40/bin/javac -source 7 Main.java
Main.java:7: error: incompatible types: inferred type does not conform to upper bound(s)
A result = m();
^
inferred: B
upper bound(s): Bar<B>,A
where B,A are type-variables:
B extends A
A extends Bar<A> declared in method <A>test()
1 error
Compiling w/o the -source flag, or with a JDK 7 compiler works w/o issues.
interface Bar<X extends Bar<X>> { }
class Test {
<A extends Bar<A>> void test() {
A result = m();
}
<B extends Bar<B>> B m() {
return null;
}
}
Error:
/opt/JDK/8/re/b40/bin/javac -source 7 Main.java
Main.java:7: error: incompatible types: inferred type does not conform to upper bound(s)
A result = m();
^
inferred: B
upper bound(s): Bar<B>,A
where B,A are type-variables:
B extends A
A extends Bar<A> declared in method <A>test()
1 error
Compiling w/o the -source flag, or with a JDK 7 compiler works w/o issues.
- duplicates
-
JDK-8035713 javac, inconsistent inference output for javac8 -source 7
- Closed