8029633: Raw inner class constructor ref should not perform diamond inference

Reviewed-by: jlahoda
This commit is contained in:
Vicente Romero 2022-10-20 15:43:10 +00:00
parent 7bc9692a51
commit 6707bfbc15
3 changed files with 32 additions and 1 deletions

View File

@ -3680,7 +3680,9 @@ public class Resolve {
List<Type> typeargtypes, MethodResolutionPhase maxPhase) {
super(referenceTree, names.init, site, argtypes, typeargtypes, maxPhase);
if (site.isRaw()) {
this.site = new ClassType(site.getEnclosingType(), site.tsym.type.getTypeArguments(), site.tsym, site.getMetadata());
this.site = new ClassType(site.getEnclosingType(),
!(site.tsym.isInner() && site.getEnclosingType().isRaw()) ?
site.tsym.type.getTypeArguments() : List.nil(), site.tsym, site.getMetadata());
needsInference = true;
}
}

View File

@ -0,0 +1,24 @@
/*
* @test /nodynamiccopyright/
* @bug 8029633
* @summary Raw inner class constructor ref should not perform diamond inference
* @compile/fail/ref=MethodRefNewInnerRawTest.out -Werror -Xlint:unchecked -XDrawDiagnostics MethodRefNewInnerRawTest.java
*/
import java.util.function.*;
class MethodRefNewInnerRawTest<T> {
class Inner1 {}
class Inner2<U> {}
Supplier<MethodRefNewInnerRawTest.Inner1> s1 = MethodRefNewInnerRawTest.Inner1::new;
Supplier<MethodRefNewInnerRawTest.Inner2> s2 = MethodRefNewInnerRawTest.Inner2::new;
Supplier<MethodRefNewInnerRawTest<T>.Inner1> s3 = MethodRefNewInnerRawTest.Inner1::new;
Supplier<MethodRefNewInnerRawTest<T>.Inner2<String>> s4 = MethodRefNewInnerRawTest.Inner2::new;
static class Outer {
class Inner3<U> {}
Supplier<Outer.Inner3<String>> s5 = Outer.Inner3::new;
}
}

View File

@ -0,0 +1,5 @@
MethodRefNewInnerRawTest.java:16:55: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), MethodRefNewInnerRawTest.Inner1, MethodRefNewInnerRawTest<T>.Inner1
MethodRefNewInnerRawTest.java:17:63: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), MethodRefNewInnerRawTest.Inner2, MethodRefNewInnerRawTest<T>.Inner2<java.lang.String>
- compiler.err.warnings.and.werror
1 error
2 warnings