src/share/classes/com/sun/tools/javac/comp/Annotate.java

changeset 2188
f3ca12d680f3
parent 2136
7f6481e5fe3a
child 2525
2eb010b6cb22
equal deleted inserted replaced
2187:4788eb38cac5 2188:f3ca12d680f3
253 // need to do it again. 253 // need to do it again.
254 Type at = (a.annotationType.type != null ? a.annotationType.type 254 Type at = (a.annotationType.type != null ? a.annotationType.type
255 : attr.attribType(a.annotationType, env)); 255 : attr.attribType(a.annotationType, env));
256 a.type = chk.checkType(a.annotationType.pos(), at, expected); 256 a.type = chk.checkType(a.annotationType.pos(), at, expected);
257 if (a.type.isErroneous()) { 257 if (a.type.isErroneous()) {
258 // Need to make sure nested (anno)trees does not have null as .type
259 attr.postAttr(a);
260
258 if (typeAnnotation) { 261 if (typeAnnotation) {
259 return new Attribute.TypeCompound(a.type, List.<Pair<MethodSymbol,Attribute>>nil(), 262 return new Attribute.TypeCompound(a.type, List.<Pair<MethodSymbol,Attribute>>nil(),
260 new TypeAnnotationPosition()); 263 new TypeAnnotationPosition());
261 } else { 264 } else {
262 return new Attribute.Compound(a.type, List.<Pair<MethodSymbol,Attribute>>nil()); 265 return new Attribute.Compound(a.type, List.<Pair<MethodSymbol,Attribute>>nil());
263 } 266 }
264 } 267 }
265 if ((a.type.tsym.flags() & Flags.ANNOTATION) == 0) { 268 if ((a.type.tsym.flags() & Flags.ANNOTATION) == 0) {
266 log.error(a.annotationType.pos(), 269 log.error(a.annotationType.pos(),
267 "not.annotation.type", a.type.toString()); 270 "not.annotation.type", a.type.toString());
271
272 // Need to make sure nested (anno)trees does not have null as .type
273 attr.postAttr(a);
274
268 if (typeAnnotation) { 275 if (typeAnnotation) {
269 return new Attribute.TypeCompound(a.type, List.<Pair<MethodSymbol,Attribute>>nil(), null); 276 return new Attribute.TypeCompound(a.type, List.<Pair<MethodSymbol,Attribute>>nil(), null);
270 } else { 277 } else {
271 return new Attribute.Compound(a.type, List.<Pair<MethodSymbol,Attribute>>nil()); 278 return new Attribute.Compound(a.type, List.<Pair<MethodSymbol,Attribute>>nil());
272 } 279 }
276 // special case: elided "value=" assumed 283 // special case: elided "value=" assumed
277 args.head = make.at(args.head.pos). 284 args.head = make.at(args.head.pos).
278 Assign(make.Ident(names.value), args.head); 285 Assign(make.Ident(names.value), args.head);
279 } 286 }
280 ListBuffer<Pair<MethodSymbol,Attribute>> buf = 287 ListBuffer<Pair<MethodSymbol,Attribute>> buf =
281 new ListBuffer<Pair<MethodSymbol,Attribute>>(); 288 new ListBuffer<>();
282 for (List<JCExpression> tl = args; tl.nonEmpty(); tl = tl.tail) { 289 for (List<JCExpression> tl = args; tl.nonEmpty(); tl = tl.tail) {
283 JCExpression t = tl.head; 290 JCExpression t = tl.head;
284 if (!t.hasTag(ASSIGN)) { 291 if (!t.hasTag(ASSIGN)) {
285 log.error(t.pos(), "annotation.value.must.be.name.value"); 292 log.error(t.pos(), "annotation.value.must.be.name.value");
286 continue; 293 continue;
302 if (method.owner != a.type.tsym) 309 if (method.owner != a.type.tsym)
303 log.error(left.pos(), "no.annotation.member", left.name, a.type); 310 log.error(left.pos(), "no.annotation.member", left.name, a.type);
304 Type result = method.type.getReturnType(); 311 Type result = method.type.getReturnType();
305 Attribute value = enterAttributeValue(result, assign.rhs, env); 312 Attribute value = enterAttributeValue(result, assign.rhs, env);
306 if (!method.type.isErroneous()) 313 if (!method.type.isErroneous())
307 buf.append(new Pair<MethodSymbol,Attribute> 314 buf.append(new Pair<>((MethodSymbol)method, value));
308 ((MethodSymbol)method, value));
309 t.type = result; 315 t.type = result;
310 } 316 }
311 if (typeAnnotation) { 317 if (typeAnnotation) {
312 if (a.attribute == null || !(a.attribute instanceof Attribute.TypeCompound)) { 318 if (a.attribute == null || !(a.attribute instanceof Attribute.TypeCompound)) {
313 // Create a new TypeCompound 319 // Create a new TypeCompound

mercurial