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

Type inference broken with Interfaces

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      FULL PRODUCT VERSION :


      A DESCRIPTION OF THE PROBLEM :
          public static <T extends List> T newList() {
              return null;
          }

          public static void main(String[] args) {
              String s = newList();
          }
      following code works fine while it should not compile.

               0: invokestatic #4 // Method newList:()Ljava/util/List;
               3: checkcast #5 // class java/lang/String
       the type is inferred correctly but the assignment of a List to String is permitted.

      Only happens to interfaces. changing to a concrete class no longer compiles.

      REGRESSION. Last worked in version 6u45


      REPRODUCIBILITY :
      This bug can be reproduced always.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: