29 |
29 |
30 import javax.tools.JavaFileObject; |
30 import javax.tools.JavaFileObject; |
31 |
31 |
32 import com.sun.tools.javac.comp.Annotate; |
32 import com.sun.tools.javac.comp.Annotate; |
33 import com.sun.tools.javac.comp.AttrContext; |
33 import com.sun.tools.javac.comp.AttrContext; |
|
34 import com.sun.tools.javac.code.Attribute.TypeCompound; |
|
35 import com.sun.tools.javac.code.Kinds; |
34 import com.sun.tools.javac.comp.Env; |
36 import com.sun.tools.javac.comp.Env; |
35 import com.sun.tools.javac.util.*; |
37 import com.sun.tools.javac.util.*; |
36 import com.sun.tools.javac.util.Assert; |
38 import com.sun.tools.javac.util.Assert; |
37 import com.sun.tools.javac.util.List; |
39 import com.sun.tools.javac.util.List; |
|
40 import com.sun.tools.javac.util.ListBuffer; |
38 import com.sun.tools.javac.util.Log; |
41 import com.sun.tools.javac.util.Log; |
39 import com.sun.tools.javac.util.Pair; |
42 import com.sun.tools.javac.util.Pair; |
40 import static com.sun.tools.javac.code.Kinds.PCK; |
43 import static com.sun.tools.javac.code.Kinds.PCK; |
41 |
44 |
42 /** |
45 /** |
150 public void setAttributes(SymbolMetadata other) { |
153 public void setAttributes(SymbolMetadata other) { |
151 if (other == null) { |
154 if (other == null) { |
152 throw new NullPointerException(); |
155 throw new NullPointerException(); |
153 } |
156 } |
154 setDeclarationAttributes(other.getDeclarationAttributes()); |
157 setDeclarationAttributes(other.getDeclarationAttributes()); |
155 setTypeAttributes(other.getTypeAttributes()); |
158 if ((sym.flags() & Flags.BRIDGE) != 0) { |
156 setInitTypeAttributes(other.getInitTypeAttributes()); |
159 Assert.check(other.sym.kind == Kinds.MTH); |
157 setClassInitTypeAttributes(other.getClassInitTypeAttributes()); |
160 ListBuffer<TypeCompound> typeAttributes = new ListBuffer<>(); |
|
161 for (TypeCompound tc : other.getTypeAttributes()) { |
|
162 // Carry over only contractual type annotations: i.e nothing interior to method body. |
|
163 if (!tc.position.type.isLocal()) |
|
164 typeAttributes.append(tc); |
|
165 } |
|
166 setTypeAttributes(typeAttributes.toList()); |
|
167 } else { |
|
168 setTypeAttributes(other.getTypeAttributes()); |
|
169 } |
|
170 if (sym.kind == Kinds.TYP) { |
|
171 setInitTypeAttributes(other.getInitTypeAttributes()); |
|
172 setClassInitTypeAttributes(other.getClassInitTypeAttributes()); |
|
173 } |
158 } |
174 } |
159 |
175 |
160 public void setDeclarationAttributesWithCompletion(final Annotate.AnnotateRepeatedContext<Attribute.Compound> ctx) { |
176 public void setDeclarationAttributesWithCompletion(final Annotate.AnnotateRepeatedContext<Attribute.Compound> ctx) { |
161 Assert.check(pendingCompletion() || (!isStarted() && sym.kind == PCK)); |
177 Assert.check(pendingCompletion() || (!isStarted() && sym.kind == PCK)); |
162 this.setDeclarationAttributes(getAttributesForCompletion(ctx)); |
178 this.setDeclarationAttributes(getAttributesForCompletion(ctx)); |