mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-17 17:44:40 +02:00
8139245: compiler crashes with exception on int:new method reference and generic method inference
Reviewed-by: mcimadamore
This commit is contained in:
parent
4d32c48daf
commit
ac4f8dfdd2
3 changed files with 30 additions and 5 deletions
|
@ -3215,8 +3215,7 @@ public class Resolve {
|
||||||
findDiamond(env, site, argtypes, typeargtypes, phase.isBoxingRequired(), phase.isVarargsRequired()) :
|
findDiamond(env, site, argtypes, typeargtypes, phase.isBoxingRequired(), phase.isVarargsRequired()) :
|
||||||
findMethod(env, site, name, argtypes, typeargtypes,
|
findMethod(env, site, name, argtypes, typeargtypes,
|
||||||
phase.isBoxingRequired(), phase.isVarargsRequired());
|
phase.isBoxingRequired(), phase.isVarargsRequired());
|
||||||
return site.getEnclosingType().hasTag(CLASS) && !hasEnclosingInstance(env, site) ?
|
return enclosingInstanceMissing(env, site) ? new BadConstructorReferenceError(sym) : sym;
|
||||||
new BadConstructorReferenceError(sym) : sym;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -3349,9 +3348,12 @@ public class Resolve {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean hasEnclosingInstance(Env<AttrContext> env, Type type) {
|
boolean enclosingInstanceMissing(Env<AttrContext> env, Type type) {
|
||||||
Symbol encl = resolveSelfContainingInternal(env, type.tsym, false);
|
if (type.hasTag(CLASS) && type.getEnclosingType().hasTag(CLASS)) {
|
||||||
return encl != null && !encl.kind.isResolutionError();
|
Symbol encl = resolveSelfContainingInternal(env, type.tsym, false);
|
||||||
|
return encl == null || encl.kind.isResolutionError();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Symbol resolveSelfContainingInternal(Env<AttrContext> env,
|
private Symbol resolveSelfContainingInternal(Env<AttrContext> env,
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
/**
|
||||||
|
* @test /nodynamiccopyright/
|
||||||
|
* @bug 8139245
|
||||||
|
* @summary compiler crashes with exception on int:new method reference and generic method inference
|
||||||
|
* @compile/fail/ref=MethodRefIntColonColonNewTest.out -XDrawDiagnostics MethodRefIntColonColonNewTest.java
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class MethodRefIntColonColonNewTest {
|
||||||
|
|
||||||
|
interface SAM<T> {
|
||||||
|
T m(T s);
|
||||||
|
}
|
||||||
|
|
||||||
|
static <T> SAM<T> infmethod(SAM<T> t) { return t; }
|
||||||
|
|
||||||
|
public static void main(String argv[]) {
|
||||||
|
SAM<Object> s = infmethod(int::new);
|
||||||
|
s.m();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
MethodRefIntColonColonNewTest.java:17:35: compiler.err.type.found.req: int, (compiler.misc.type.req.class.array)
|
||||||
|
MethodRefIntColonColonNewTest.java:18:10: compiler.err.cant.apply.symbol: kindname.method, m, java.lang.Object, compiler.misc.no.args, kindname.interface, MethodRefIntColonColonNewTest.SAM<T>, (compiler.misc.arg.length.mismatch)
|
||||||
|
2 errors
|
Loading…
Add table
Add a link
Reference in a new issue