8041713: Type inference of non-existent method references crashes the compiler
authorvromero
Wed, 04 Jun 2014 20:01:13 +0100
changeset 24794 22946bb4c27d
parent 24793 bb58a9f1ae10
child 24795 ff348aab3b54
8041713: Type inference of non-existent method references crashes the compiler Reviewed-by: mcimadamore
langtools/src/share/classes/com/sun/tools/javac/code/Type.java
langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java
langtools/test/tools/javac/generics/diamond/T8041713/DiamondPlusUnexistingMethodRefCrashTest.java
langtools/test/tools/javac/generics/diamond/T8041713/DiamondPlusUnexistingMethodRefCrashTest.out
--- 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<Attribute.TypeCompound> noAnnotations =
         List.nil();
--- 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,
--- /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<T> {
+    DiamondPlusUnexistingMethodRefCrashTest<String> m =
+        new DiamondPlusUnexistingMethodRefCrashTest<>(DiamondPlusUnexistingMethodRefCrashTest::doNotExists);
+}
--- /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