< prev index next >

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

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

*** 2191,2202 **** 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)) { // 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)) --- 2191,2201 ---- final KindSelector pkind = attribArgs(KindSelector.VAL, tree.args, localEnv, argtypesBuf); List<Type> argtypes = argtypesBuf.toList(); List<Type> typeargtypes = attribTypes(tree.typeargs, localEnv); ! 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,2389 **** } // 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(); if (implementing) { cdef.implementing = List.of(clazz); } else { cdef.extending = clazz; --- 2378,2389 ---- } // 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().hasTag(NONE) && ! clazztype.getOriginalType().tsym.isInterface(); if (implementing) { cdef.implementing = List.of(clazz); } else { cdef.extending = clazz;
*** 2411,2421 **** // them. Original arguments have right decorations already. if (isDiamond && pkind.contains(KindSelector.POLY)) { finalargtypes = finalargtypes.map(deferredAttr.deferredCopier); } ! clazztype = 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, --- 2411,2422 ---- // them. Original arguments have right decorations already. if (isDiamond && pkind.contains(KindSelector.POLY)) { finalargtypes = finalargtypes.map(deferredAttr.deferredCopier); } ! 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,5088 **** * 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)) { JCPrimitiveTypeTree prim = (JCPrimitiveTypeTree)md.restype; if (prim.typetag == VOID) restype = syms.voidType; } return new MethodType(List.nil(), restype, --- 5079,5089 ---- * 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 != 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 >