# HG changeset patch # User vromero # Date 1401908473 -3600 # Node ID 22946bb4c27d3fc2e384b1ed55eedde74f132fa8 # Parent bb58a9f1ae106c4f577d2009eb0d0950c7cb0bee 8041713: Type inference of non-existent method references crashes the compiler Reviewed-by: mcimadamore diff -r bb58a9f1ae10 -r 22946bb4c27d langtools/src/share/classes/com/sun/tools/javac/code/Type.java --- a/langtools/src/share/classes/com/sun/tools/javac/code/Type.java Mon Jun 02 22:36:40 2014 +0100 +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Type.java Wed Jun 04 20:01:13 2014 +0100 @@ -72,13 +72,28 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { /** Constant type: no type at all. */ - public static final JCNoType noType = new JCNoType(); + public static final JCNoType noType = new JCNoType() { + @Override + public String toString() { + return "none"; + } + }; /** Constant type: special type to be used during recovery of deferred expressions. */ - public static final JCNoType recoveryType = new JCNoType(); + public static final JCNoType recoveryType = new JCNoType(){ + @Override + public String toString() { + return "recovery"; + } + }; /** Constant type: special type to be used for marking stuck trees. */ - public static final JCNoType stuckType = new JCNoType(); + public static final JCNoType stuckType = new JCNoType() { + @Override + public String toString() { + return "stuck"; + } + }; public static final List noAnnotations = List.nil(); diff -r bb58a9f1ae10 -r 22946bb4c27d langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java Mon Jun 02 22:36:40 2014 +0100 +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java Wed Jun 04 20:01:13 2014 +0100 @@ -2060,7 +2060,7 @@ tree.constructor = constructor.baseSymbol(); final TypeSymbol csym = clazztype.tsym; - ResultInfo diamondResult = new ResultInfo(MTH, newMethodTemplate(resultInfo.pt, argtypes, typeargtypes), new Check.NestedCheckContext(resultInfo.checkContext) { + ResultInfo diamondResult = new ResultInfo(pkind, newMethodTemplate(resultInfo.pt, argtypes, typeargtypes), new Check.NestedCheckContext(resultInfo.checkContext) { @Override public void report(DiagnosticPosition _unused, JCDiagnostic details) { enclosingContext.report(tree.clazz, diff -r bb58a9f1ae10 -r 22946bb4c27d langtools/test/tools/javac/generics/diamond/T8041713/DiamondPlusUnexistingMethodRefCrashTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/generics/diamond/T8041713/DiamondPlusUnexistingMethodRefCrashTest.java Wed Jun 04 20:01:13 2014 +0100 @@ -0,0 +1,11 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8041713 + * @summary Type inference of non-existent method references crashes the compiler + * @compile/fail/ref=DiamondPlusUnexistingMethodRefCrashTest.out -XDrawDiagnostics DiamondPlusUnexistingMethodRefCrashTest.java + */ + +public class DiamondPlusUnexistingMethodRefCrashTest { + DiamondPlusUnexistingMethodRefCrashTest m = + new DiamondPlusUnexistingMethodRefCrashTest<>(DiamondPlusUnexistingMethodRefCrashTest::doNotExists); +} diff -r bb58a9f1ae10 -r 22946bb4c27d langtools/test/tools/javac/generics/diamond/T8041713/DiamondPlusUnexistingMethodRefCrashTest.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/generics/diamond/T8041713/DiamondPlusUnexistingMethodRefCrashTest.out Wed Jun 04 20:01:13 2014 +0100 @@ -0,0 +1,2 @@ +DiamondPlusUnexistingMethodRefCrashTest.java:10:55: compiler.err.invalid.mref: kindname.method, (compiler.misc.cant.resolve.location.args: kindname.method, doNotExists, , , (compiler.misc.location: kindname.class, DiamondPlusUnexistingMethodRefCrashTest, null)) +1 error