-
Bug
-
Resolution: Fixed
-
P2
-
None
-
Verified
A raw type that is a non-static member type of another raw type (see JLS 4.8) cannot be used with diamond inference. A method reference to such a raw type's constructor should simply use the raw constructor rather than trying to infer a parameterization.
Example:
class Outer<T> {
class Inner1 {}
class Inner2<U> {}
Supplier<Outer.Inner1> s1 = Outer.Inner1::new; // ok
Supplier<Outer.Inner2> s2 = Outer.Inner2::new; // ok
Supplier<Outer<T>.Inner1> s3 = Outer.Inner1::new; // unchecked conversion
Supplier<Outer<T>.Inner2<String>> s4 = Outer.Inner2::new; // unchecked conversion
}
Example:
class Outer<T> {
class Inner1 {}
class Inner2<U> {}
Supplier<Outer.Inner1> s1 = Outer.Inner1::new; // ok
Supplier<Outer.Inner2> s2 = Outer.Inner2::new; // ok
Supplier<Outer<T>.Inner1> s3 = Outer.Inner1::new; // unchecked conversion
Supplier<Outer<T>.Inner2<String>> s4 = Outer.Inner2::new; // unchecked conversion
}
- relates to
-
JDK-8029633 Raw inner class constructor ref should not perform diamond inference
-
- Resolved
-