8139245: compiler crashes with exception on int:new method reference and generic method inference

Reviewed-by: mcimadamore
This commit is contained in:
Srikanth Adayapalam 2015-10-12 19:43:44 +05:30
parent 4d32c48daf
commit ac4f8dfdd2
3 changed files with 30 additions and 5 deletions

View file

@ -3215,8 +3215,7 @@ public class Resolve {
findDiamond(env, site, argtypes, typeargtypes, phase.isBoxingRequired(), phase.isVarargsRequired()) :
findMethod(env, site, name, argtypes, typeargtypes,
phase.isBoxingRequired(), phase.isVarargsRequired());
return site.getEnclosingType().hasTag(CLASS) && !hasEnclosingInstance(env, site) ?
new BadConstructorReferenceError(sym) : sym;
return enclosingInstanceMissing(env, site) ? new BadConstructorReferenceError(sym) : sym;
}
@Override
@ -3349,9 +3348,12 @@ public class Resolve {
}
}
boolean hasEnclosingInstance(Env<AttrContext> env, Type type) {
boolean enclosingInstanceMissing(Env<AttrContext> env, Type type) {
if (type.hasTag(CLASS) && type.getEnclosingType().hasTag(CLASS)) {
Symbol encl = resolveSelfContainingInternal(env, type.tsym, false);
return encl != null && !encl.kind.isResolutionError();
return encl == null || encl.kind.isResolutionError();
}
return false;
}
private Symbol resolveSelfContainingInternal(Env<AttrContext> env,

View file

@ -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();
}
}

View file

@ -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