langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/SymbolMetadata.java
changeset 39600 83ea7c12c164
parent 25874 83c19f00452c
child 42828 cce89649f958
equal deleted inserted replaced
39599:3c7da4996d8c 39600:83ea7c12c164
    24  */
    24  */
    25 
    25 
    26 package com.sun.tools.javac.code;
    26 package com.sun.tools.javac.code;
    27 
    27 
    28 
    28 
       
    29 import com.sun.tools.javac.code.Attribute.TypeCompound;
       
    30 import com.sun.tools.javac.code.Kinds.Kind;
    29 import com.sun.tools.javac.util.Assert;
    31 import com.sun.tools.javac.util.Assert;
    30 import com.sun.tools.javac.util.List;
    32 import com.sun.tools.javac.util.List;
       
    33 import com.sun.tools.javac.util.ListBuffer;
    31 
    34 
    32 /**
    35 /**
    33  * Container for all annotations (attributes in javac) on a Symbol.
    36  * Container for all annotations (attributes in javac) on a Symbol.
    34  *
    37  *
    35  * This class is explicitly mutable. Its contents will change when attributes
    38  * This class is explicitly mutable. Its contents will change when attributes
   140     public void setAttributes(SymbolMetadata other) {
   143     public void setAttributes(SymbolMetadata other) {
   141         if (other == null) {
   144         if (other == null) {
   142             throw new NullPointerException();
   145             throw new NullPointerException();
   143         }
   146         }
   144         setDeclarationAttributes(other.getDeclarationAttributes());
   147         setDeclarationAttributes(other.getDeclarationAttributes());
   145         setTypeAttributes(other.getTypeAttributes());
   148         if ((sym.flags() & Flags.BRIDGE) != 0) {
   146         setInitTypeAttributes(other.getInitTypeAttributes());
   149             Assert.check(other.sym.kind == Kind.MTH);
   147         setClassInitTypeAttributes(other.getClassInitTypeAttributes());
   150             ListBuffer<TypeCompound> typeAttributes = new ListBuffer<>();
       
   151             for (TypeCompound tc : other.getTypeAttributes()) {
       
   152                 // Carry over only contractual type annotations: i.e nothing interior to method body.
       
   153                 if (!tc.position.type.isLocal())
       
   154                     typeAttributes.append(tc);
       
   155             }
       
   156             setTypeAttributes(typeAttributes.toList());
       
   157         } else {
       
   158             setTypeAttributes(other.getTypeAttributes());
       
   159         }
       
   160         if (sym.kind == Kind.TYP) {
       
   161             setInitTypeAttributes(other.getInitTypeAttributes());
       
   162             setClassInitTypeAttributes(other.getClassInitTypeAttributes());
       
   163         }
   148     }
   164     }
   149 
   165 
   150     public SymbolMetadata reset() {
   166     public SymbolMetadata reset() {
   151         attributes = DECL_IN_PROGRESS;
   167         attributes = DECL_IN_PROGRESS;
   152         return this;
   168         return this;