JDK-8029704 : Lambda Spec: Fix subtype inference for a non-parameterized inner class of a generic type
  • Type: Bug
  • Component: specification
  • Sub-Component: language
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2013-12-06
  • Updated: 2014-02-26
  • Resolved: 2013-12-18
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 8
8Fixed
Related Reports
Relates :  
Relates :  
Description
Uses of a class like Inner, below, are not parameterized types (per JLS 4.5).

class Outer<T> {
  abstract class Inner { abstract T get(); }

  static <X> X unwrap(Outer<X>.Inner i) { return i.get(); }

  static void test(Outer<String>.Inner i) {
    unwrap(i).substring(3);
  }

}

But, clearly, subtype inference should treat it just like a parameterized type.  The rules in 18.2.3 should be modified to allow, e.g., x=String to be inferred above.
Comments
Updated text for 18.2.4: Otherwise, if S and T ***are class or interface types with the same erasure, where S has type arguments B1, ..., Bn and T has type arguments A1, ..., An,*** the constraint reduces to the following new constraints: for all i, 1 ��� i ��� n, ���Bi = Ai���.
18-12-2013

Updated text for 18.2.3: Otherwise, the constraint is reduced according to the form of T: - If T is a parameterized class ***or interface type, or an inner class type of a parameterized class or interface type (directly or indirectly), let A1, ..., An be the type arguments appearing in T; among the supertypes (4.10) of S, a corresponding class or interface type is identified, with type arguments B1, ..., Bn. If no such type exists,*** the constraint reduces to false. Otherwise, the constraint reduces to the following new constraints: for all i, 1 ��� i ��� n, ���Bi <= Ai���. - If T is ***any other class or interface type***, then the constraint reduces to true if ***T is among the supertypes of S***, and false otherwise. [This is somewhat awkward, because there doesn't seem to be a related treatment of inner class types in 4.10. See JDK-8030746.]
18-12-2013

Also need to consider the parallel in 18.2.4, Type Equality Constraints.
11-12-2013

Also need to consider inner classes as they relate to the clause "If T is a non-parameterized class or interface type" (does not consider the possibility that T may be an inner class of a parameterized type).
11-12-2013

Reported by Stephan Herrmann on lambda-spec-experts@openjdk.java.net.
06-12-2013