changeset 2444:b21c359c1fd1

8041713: Type inference of non-existent method references crashes the compiler Reviewed-by: mcimadamore
author vromero
date Wed, 04 Jun 2014 20:01:13 +0100
parents 62e5d13e3383
children 56b8da5c4eaf
files src/share/classes/com/sun/tools/javac/code/Type.java src/share/classes/com/sun/tools/javac/comp/Attr.java test/tools/javac/generics/diamond/T8041713/DiamondPlusUnexistingMethodRefCrashTest.java test/tools/javac/generics/diamond/T8041713/DiamondPlusUnexistingMethodRefCrashTest.out
diffstat 4 files changed, 32 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/code/Type.java	Mon Jun 02 22:36:40 2014 +0100
+++ b/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/src/share/classes/com/sun/tools/javac/comp/Attr.java	Mon Jun 02 22:36:40 2014 +0100
+++ b/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/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/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