type inference regression related to JDK-8157149

Liam Miller-Cushon cushon at google.com
Mon Oct 17 16:14:46 UTC 2016


javac started rejecting the following program between 9-ea+119 and
9-ea+120. The culprit appears to be JDK-8157149 [1][2]. Was this
intentional?

Thanks,

[1] https://bugs.openjdk.java.net/browse/JDK-8157149
[2] http://hg.openjdk.java.net/jdk9/dev/langtools/rev/a8b7c9938b74

=== Test.java
abstract class Test {
  interface W<A> {}
  abstract <B> B f(W<B> e);
  abstract <C> C g(C b, long i);

  void h(W<Long> i) {
    g("", f(i));
  }
}
===

$ javac Test.java
...
error: method g in class Test cannot be applied to given types;
    g("", f(i));
    ^
  required: C,long
  found: String,Long
  reason: cannot infer type-variable(s) C,B
    (argument mismatch; B cannot be converted to long)
  where C,B are type-variables:
    C extends Object declared in method <C>g(C,long)
    B extends Object declared in method <B>f(W<B>)
1 error
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20161017/3ca041a5/attachment.html>


More information about the compiler-dev mailing list