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

Missing check against target-type during applicability inference

XMLWordPrintable

    • b162
    • Verified

        The regression occurs between 9-ea+156 and 9-ea+157, I suspect it's related to JDK-8174249.

        ===
        import java.util.*;
        abstract class T {
          List<String> f(Enumeration e) {
            return newArrayList(forEnumeration(e));
          }

          abstract <T> Iterator<T> forEnumeration(Enumeration<T> e);
          abstract <E> ArrayList<E> newArrayList(Iterator<? extends E> xs);
          abstract <E> ArrayList<E> newArrayList(Iterable<? extends E> xs);
        }
        ===

        $ javac -fullversion T.java
        javac full version "9-ea+156"
        Note: T.java uses unchecked or unsafe operations.
        Note: Recompile with -Xlint:unchecked for details.

        $ javac -fullversion T.java
        javac full version "9-ea+157"
        T.java:4: error: reference to newArrayList is ambiguous
            return newArrayList(forEnumeration(e));
                   ^
          both method <E#1>newArrayList(Iterator<? extends E#1>) in T and method <E#2>newArrayList(Iterable<? extends E#2>) in T match
          where E#1,E#2 are type-variables:
            E#1 extends Object declared in method <E#1>newArrayList(Iterator<? extends E#1>)
            E#2 extends Object declared in method <E#2>newArrayList(Iterable<? extends E#2>)
        Note: T.java uses unchecked or unsafe operations.
        Note: Recompile with -Xlint:unchecked for details.
        1 error

              mcimadamore Maurizio Cimadamore
              cushon Liam Miller-Cushon
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: