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

Regression: inference fails to reject incompatible upper bounds

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 9
    • 9
    • tools
    • b112
    • Verified

      The following program erroneously compiles after JDK-8046685:

      import java.util.List;

      class Test {
      <A2 extends A, A> A m(List<? super A2> a2) { return null; }
      <B> B g(B b) { return null; }

      void test() {
      List<Integer> I = null;
      String s = g(m(I));
      }
      }

      This used to give the following error:

      error: incompatible types: inference variable A2 has incompatible upper bounds String,B,Object,Integer,A
      String s = g(m(I));
      ^
        where A2,A,B are type-variables:
          A2 extends A declared in method <A2,A>m(List<? super A2>)
          A extends Object declared in method <A2,A>m(List<? super A2>)
          B extends Object declared in method <B>g(B)
      1 error

            mcimadamore Maurizio Cimadamore
            mcimadamore Maurizio Cimadamore
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: