More type inference changes

Liam Miller-Cushon cushon at
Wed Feb 3 18:41:40 UTC 2016

I noticed three more javac9 type inference incompatibilities, each of which
only occurs once in the codebase I've been testing against.

1) The following code is rejected by javac9 at head, and accepted by
earlier versions. The first bad revision is 3211.

abstract class Test {

  interface O<A> {}
  interface R<B> {}
  interface S<C> { S<C> t(C x); }
  abstract <D> D a(Class<D> methodCall);
  abstract R<Number> g(O<Number> q, String s);
  abstract <E> S<E> w(E m);

  S<R<Number>> f(R<Number> r) {
    return w(g(a(O.class), a(String.class))).t(r);

error: incompatible types: S<R> cannot be converted to S<R<Number>>
    return w(g(a(O.class), a(String.class))).t(r);

2) This is also rejected at head, and accepted by earlier versions. The
first bad revision is 3030.

abstract class Test {

  interface One<A> {}
  interface Two<B extends Three, C extends Four> {}
  interface Three {}
  interface Four {}
  abstract <D> One<D> h(Class<D> clazz);
  abstract void g(One<? extends Two<Three, Four>> x);

  void f() {

error: incompatible types: One<Two> cannot be converted to One<? extends

3) This one is accepted at head, and also by earlier versions. It was
briefly rejected between 3030 and 3109. Was the fix in 3109 deliberate?

First bad revision:

First good revision:

abstract class Test {

  interface One<G, H extends One<G, H>> {}
  abstract <D, E extends One<D, E>> void g(One<D, E> f);
  abstract <A> One<A, ?> h();

  void f() {

error: method g in class Test cannot be applied to given types;
  required: One<D,E#1>
  found: One<Object,CAP#1>
  reason: inferred type does not conform to upper bound(s)
    inferred: E#2
    upper bound(s): One<Object,E#2>,One<Object,<captured wildcard>>
  where D,E#1,E#2,<captured wildcard> are type-variables:
    D extends Object declared in method <D,E#1>g(One<D,E#1>)
    E#1 extends One<D,E#1> declared in method <D,E#1>g(One<D,E#1>)
    E#2 extends One<Object,<captured wildcard>>
    <captured wildcard> extends One<Object,E#2>
  where CAP#1 is a fresh type-variable:
    CAP#1 extends One<Object,CAP#1> from capture of ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the compiler-dev mailing list