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

Spurious inference error when return type of generic method requires unchecked conversion to target

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 7u40, 8, 8-repo-lambda
    • Fix Version/s: 8
    • Component/s: tools
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b94
    • Verification:
      Verified

      Description

      This code doesn't compile in JDK 5/6/7:

      import java.util.List;

      interface B { <X> List m(); }

      class Test {
        void test(B ab) { List<?> n = ab.m(); }
      }


      Test.java:26: incompatible types; no instance(s) of type variable(s) X exist so that java.util.List conforms to java.util.List<?>
      found : <X>java.util.List
      required: java.util.List<?>
        void test(B ab) { List<?> n = ab.m(); }
                                          ^
      1 error

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                mcimadamore Maurizio Cimadamore
                Reporter:
                mcimadamore Maurizio Cimadamore
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: