JDK-8176534 : Missing check against target-type during applicability inference
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2017-03-10
  • Updated: 2017-03-25
  • Resolved: 2017-03-15
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 10 JDK 9
10Fixed 9 b162Fixed
Related Reports
Relates :  
Relates :  
Description
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

Comments
There's a missing check in PartiallyInferredMethodType - if method call is unchecked, there's no check that instantiated method type conforms to expected type.
13-03-2017