Inference of recursive types
Liam Miller-Cushon
cushon at google.com
Fri Feb 14 17:07:44 PST 2014
Hi -
Sorry if this has already been discussed, but I ran into a difference in
behaviour between javac8 -source 7/-target 7 and both javac7 and javac8
-source 8/-target 8.
The following program compiles with everything except javac8 -source
7/-target 7.
Is this an intentional change? Having to make g's type parameter explicit
feels like a regression.
===
class Test {
static class One<T> {}
static class Two extends One<Two> {}
<T extends One<T>> T f(T a, String s) {
T t = g(s);
return t;
}
static <U extends One<U>> U g(String s) {
throw new RuntimeException();
}
}
===
Test.java:6: error: incompatible types: inference variable U#1 has
incompatible upper bounds One<U#2>,T
T t = g(s);
^
where U#1,U#2,T are type-variables:
U#1 extends One<U#1> declared in method <U#1>g(String)
U#2 extends T
T extends One<T> declared in method <T>f(T,String)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20140214/5361e27f/attachment.html
More information about the compiler-dev
mailing list