Possible bug in javac 8 'legacy' type inference

Liam Miller-Cushon cushon at google.com
Thu Nov 14 09:31:34 PST 2013


The following program compiles with javac 7, and with javac 8 using -source
8.

However, when compiled with javac 8 and -source 7 an inference error is
reported:

incompatible types: inference variable T#1 has incompatible upper bounds
Message<T#2>,Result
    Result result = getThing(key);
                            ^
  where T#1,T#2 are type-variables:
    T#1 extends Message<T#1> declared in method <T#1>getThing(Key)
    T#2 extends Result


Is this a bug, or is javac 8 more accurately reflecting the intent of JLS
15.12.2.7/15.12.2.8?

===

class Message<T extends Message<T>> {}
class Key extends Message<Key> {}
class Result extends Message<Result> {}

abstract class Foo {
  abstract <T extends Message<T>> T getThing(Key key);

  void test(Key key) {
    Result result = getThing(key);
  }
}

===
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20131114/1737bff9/attachment.html 


More information about the compiler-dev mailing list