< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java

Print this page
rev 48744 : 8197439: Crash with -XDfind=lambda for anonymous class in anonymous class.
Summary: Ensuring unresolvable anonymous classes are attributed.
Reviewed-by: TBD

@@ -2191,12 +2191,11 @@
         final KindSelector pkind =
             attribArgs(KindSelector.VAL, tree.args, localEnv, argtypesBuf);
         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) ||
                  (((JCVariableDecl) env.tree).mods.flags & Flags.ENUM) == 0 ||
                  ((JCVariableDecl) env.tree).init != tree))

@@ -2379,11 +2378,12 @@
                 }
 
                 // 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);
                 } else {
                     cdef.extending = clazz;

@@ -2411,11 +2411,12 @@
                 // them. Original arguments have right decorations already.
                 if (isDiamond && pkind.contains(KindSelector.POLY)) {
                     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());
                 tree.constructor = sym;
                 tree.constructorType = checkId(tree,

@@ -5078,11 +5079,11 @@
          * instead of UNKNOWN to avoid spurious error messages in lambda
          * bodies (see:JDK-8041704).
          */
         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;
             }
             return new MethodType(List.nil(), restype,
< prev index next >