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

type inference regression

    XMLWordPrintable

Details

    • Bug
    • Resolution: Not an Issue
    • P3
    • None
    • 9
    • tools
    • x86_64
    • linux

    Description

      FULL PRODUCT VERSION :
      java full version "1.9.0-ea-b80"


      ADDITIONAL OS VERSION INFORMATION :
      x86_64 GNU/Linux

      A DESCRIPTION OF THE PROBLEM :
      The JDK 9 javac fails to perform type inference on the attached program.

      REGRESSION. Last worked in version 8u60

      ADDITIONAL REGRESSION INFORMATION:
      java full version "1.8.0_60-ea-b21"

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      $ javac -source 7 -target 7 Test.java


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

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      warning: [options] bootstrap class path not set in conjunction with -source 1.7
      Test.java:11: error: incompatible types: Map<Object,CAP#1> cannot be converted to Map<Object,String>
          return h(g(xs, new F<String, Object>() {}));
                  ^
        where CAP#1 is a fresh type-variable:
          CAP#1 extends String from capture of ? extends String
      1 error
      1 warning


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.util.Map;

      abstract class Test {
        interface F<A, V> {}

        abstract <K, V> Map<K, V> g(Iterable<V> xs, F<? super V, K> f);

        abstract <K, V> Map<K, V> h(Map<? extends K, ? extends V> xs);

        Map<Object, String> f(Iterable<? extends String> xs) {
          return h(g(xs, new F<String, Object>() {}));
        }
      }

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

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: