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

Type inference regression

XMLWordPrintable

    • x86_64
    • generic

      FULL PRODUCT VERSION :
      java full version "9-ea+114"


      ADDITIONAL OS VERSION INFORMATION :
       x86_64 GNU/Linux

      A DESCRIPTION OF THE PROBLEM :
      The attach program is accepted by the JDK 8 javac, but rejected by the JDK 9 javac.

      REGRESSION. Last worked in version 8u92

      ADDITIONAL REGRESSION INFORMATION:
      java full version "1.8.0_92-b14"

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      $ javac Test.java

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I expected the compilation to succeed.
      ACTUAL -
      The compilation failed.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Test.java:7: error: method m in class Test cannot be applied to given types;
          m(Arrays.asList(cs));
          ^
        required: Iterable<? extends Test.C<? super T#1>>
        found: List<Test.C<? super T#2>>
        reason: inference variable T#3 has incompatible bounds
          upper bounds: Test.C<? super CAP#1>,Object
          lower bounds: Test.C<? super T#2>
        where T#1,T#2,T#3 are type-variables:
          T#1 extends Object declared in method <T#1>m(Iterable<? extends Test.C<? super T#1>>)
          T#2 extends Object declared in method <T#2>t(Test.C<? super T#2>...)
          T#3 extends Object declared in method <T#3>asList(T#3...)
        where CAP#1 is a fresh type-variable:
          CAP#1 extends Object super: T#2 from capture of ? super T#2
      Note: Test.java uses unchecked or unsafe operations.
      Note: Recompile with -Xlint:unchecked for details.
      1 error


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.util.Arrays;
      class Test {
        public class C<T> {}
        public static <T> void m(Iterable<? extends C<? super T>> cs) {}
        public static <T> void t(C<? super T>... cs) {
          m(Arrays.<C<? super T>>asList(cs));
          m(Arrays.asList(cs));
        }
      }

      ---------- END SOURCE ----------

            dlsmith Dan Smith
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: