< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotations.java

Print this page

        

*** 75,84 **** --- 75,85 ---- import com.sun.tools.javac.util.ListBuffer; import com.sun.tools.javac.util.Log; import com.sun.tools.javac.util.Names; import static com.sun.tools.javac.code.Kinds.Kind.*; + import com.sun.tools.javac.tree.JCTree; /** * Contains operations specific to processing type annotations. * This class has two functions: * separate declaration from type annotations and insert the type
*** 388,413 **** if (sym.getKind() == ElementKind.PARAMETER || sym.getKind() == ElementKind.LOCAL_VARIABLE || sym.getKind() == ElementKind.RESOURCE_VARIABLE || sym.getKind() == ElementKind.EXCEPTION_PARAMETER) { ! // Make sure all type annotations from the symbol are also ! // on the owner. If the owner is an initializer block, propagate ! // to the type. ! final long ownerFlags = sym.owner.flags(); ! if ((ownerFlags & Flags.BLOCK) != 0) { ! // Store init and clinit type annotations with the ClassSymbol ! // to allow output in Gen.normalizeDefs. ! ClassSymbol cs = (ClassSymbol) sym.owner.owner; ! if ((ownerFlags & Flags.STATIC) != 0) { ! cs.appendClassInitTypeAttributes(typeAnnotations); ! } else { ! cs.appendInitTypeAttributes(typeAnnotations); ! } } else { ! sym.owner.appendUniqueTypeAttributes(sym.getRawTypeAttributes()); } } } // This method has a similar purpose as // {@link com.sun.tools.javac.parser.JavacParser.insertAnnotationsToMostInner(JCExpression, List<JCTypeAnnotation>, boolean)} --- 389,418 ---- if (sym.getKind() == ElementKind.PARAMETER || sym.getKind() == ElementKind.LOCAL_VARIABLE || sym.getKind() == ElementKind.RESOURCE_VARIABLE || sym.getKind() == ElementKind.EXCEPTION_PARAMETER) { ! appendTypeAnnotationsToOwner(sym, typeAnnotations); ! } ! } ! ! private void appendTypeAnnotationsToOwner(Symbol sym, List<Attribute.TypeCompound> typeAnnotations) { ! // Make sure all type annotations from the symbol are also ! // on the owner. If the owner is an initializer block, propagate ! // to the type. ! final long ownerFlags = sym.owner.flags(); ! if ((ownerFlags & Flags.BLOCK) != 0) { ! // Store init and clinit type annotations with the ClassSymbol ! // to allow output in Gen.normalizeDefs. ! ClassSymbol cs = (ClassSymbol) sym.owner.owner; ! if ((ownerFlags & Flags.STATIC) != 0) { ! cs.appendClassInitTypeAttributes(typeAnnotations); } else { ! cs.appendInitTypeAttributes(typeAnnotations); } + } else { + sym.owner.appendUniqueTypeAttributes(typeAnnotations); } } // This method has a similar purpose as // {@link com.sun.tools.javac.parser.JavacParser.insertAnnotationsToMostInner(JCExpression, List<JCTypeAnnotation>, boolean)}
*** 941,954 **** } else { throw new AssertionError("Could not determine position of tree " + tree + " within frame " + frame); } case VARIABLE: ! VarSymbol v = ((JCVariableDecl)frame).sym; if (v.getKind() != ElementKind.FIELD) { ! v.owner.appendUniqueTypeAttributes(v.getRawTypeAttributes()); } switch (v.getKind()) { case LOCAL_VARIABLE: return TypeAnnotationPosition .localVariable(location.toList(), currentLambda, --- 946,960 ---- } else { throw new AssertionError("Could not determine position of tree " + tree + " within frame " + frame); } + case BINDING_PATTERN: case VARIABLE: ! VarSymbol v = frame.hasTag(Tag.BINDINGPATTERN) ? ((JCBindingPattern) frame).symbol : ((JCVariableDecl) frame).sym; if (v.getKind() != ElementKind.FIELD) { ! appendTypeAnnotationsToOwner(v, v.getRawTypeAttributes()); } switch (v.getKind()) { case LOCAL_VARIABLE: return TypeAnnotationPosition .localVariable(location.toList(), currentLambda,
*** 1264,1274 **** separateAnnotationsKinds(tree.vartype, tree.sym.type, tree.sym, pos); } else if (tree.sym.getKind() == ElementKind.ENUM_CONSTANT) { // No type annotations can occur here. } else { // There is nothing else in a variable declaration that needs separation. ! Assert.error("Unhandled variable kind"); } scan(tree.mods); scan(tree.vartype); if (!sigOnly) { --- 1270,1280 ---- separateAnnotationsKinds(tree.vartype, tree.sym.type, tree.sym, pos); } else if (tree.sym.getKind() == ElementKind.ENUM_CONSTANT) { // No type annotations can occur here. } else { // There is nothing else in a variable declaration that needs separation. ! Assert.error("Unhandled variable kind: " + tree.sym.getKind()); } scan(tree.mods); scan(tree.vartype); if (!sigOnly) {
< prev index next >