src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java
changeset 48931 b25eb74ec283
parent 48721 ef3557eb4306
child 49887 39446351e625
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Thu Feb 22 11:16:43 2018 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Wed Feb 21 17:07:12 2018 +0100
@@ -2193,8 +2193,7 @@
         List<Type> argtypes = argtypesBuf.toList();
         List<Type> typeargtypes = attribTypes(tree.typeargs, localEnv);
 
-        // If we have made no mistakes in the class type...
-        if (clazztype.hasTag(CLASS)) {
+        if (clazztype.hasTag(CLASS) || clazztype.hasTag(ERROR)) {
             // Enums may not be instantiated except implicitly
             if ((clazztype.tsym.flags_field & Flags.ENUM) != 0 &&
                 (!env.tree.hasTag(VARDEF) ||
@@ -2381,7 +2380,8 @@
                 // If we already errored, be careful to avoid a further avalanche. ErrorType answers
                 // false for isInterface call even when the original type is an interface.
                 boolean implementing = clazztype.tsym.isInterface() ||
-                        clazztype.isErroneous() && clazztype.getOriginalType().tsym.isInterface();
+                        clazztype.isErroneous() && !clazztype.getOriginalType().hasTag(NONE) &&
+                        clazztype.getOriginalType().tsym.isInterface();
 
                 if (implementing) {
                     cdef.implementing = List.of(clazz);
@@ -2413,7 +2413,8 @@
                     finalargtypes = finalargtypes.map(deferredAttr.deferredCopier);
                 }
 
-                clazztype = cdef.sym.type;
+                clazztype = clazztype.hasTag(ERROR) ? types.createErrorType(cdef.sym.type)
+                                                    : cdef.sym.type;
                 Symbol sym = tree.constructor = rs.resolveConstructor(
                         tree.pos(), localEnv, clazztype, finalargtypes, typeargtypes);
                 Assert.check(!sym.kind.isResolutionError());
@@ -5080,7 +5081,7 @@
          */
         private Type dummyMethodType(JCMethodDecl md) {
             Type restype = syms.unknownType;
-            if (md != null && md.restype.hasTag(TYPEIDENT)) {
+            if (md != null && md.restype != null && md.restype.hasTag(TYPEIDENT)) {
                 JCPrimitiveTypeTree prim = (JCPrimitiveTypeTree)md.restype;
                 if (prim.typetag == VOID)
                     restype = syms.voidType;