Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8185655

type inference regression after JDK-8175235

    XMLWordPrintable

Details

    Description

      The following program is accepted by 9-ea+160 and rejected by 9-ea+161. Was this a deliberate change? The likely culprit appears to be JDK-8175235.

      ===
      import java.util.List;
      import java.util.function.Function;

      abstract class T {

        Iterable<Integer> test(Iterable<String> xs, Function<String, List<? extends Number>> f) {
          return (Iterable) g(h(i(xs, f)));
        }

        abstract <T> Iterable<T> g(Iterable<T> xs);
        abstract <T> Iterable<T> h(Iterable<? extends Iterable<? extends T>> xs);
        abstract <F, T> Iterable<T> i(Iterable<F> xs, Function<? super F, ? extends T> f);
      }
      ===

      $ javac -fullversion T.java
      javac full version "9-ea+160"
      Note: T.java uses unchecked or unsafe operations.
      Note: Recompile with -Xlint:unchecked for details.

      $ javac -fullversion T.java
      javac full version "9-ea+161"
      T.java:7: error: incompatible types: inference variable T has incompatible bounds
          return (Iterable) g(h(i(xs, f)));
                             ^
          upper bounds: Iterable<? extends CAP#1>,Object
          lower bounds: List<? extends Number>
        where T,F are type-variables:
          T extends Object declared in method <F,T>i(Iterable<F>,Function<? super F,? extends T>)
          F extends Object declared in method <F,T>i(Iterable<F>,Function<? super F,? extends T>)
        where CAP#1 is a fresh type-variable:
          CAP#1 extends Number from capture of ? extends Number

      Attachments

        Issue Links

          Activity

            People

              vromero Vicente Arturo Romero Zaldivar
              cushon Liam Miller-Cushon
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated: