equal
deleted
inserted
replaced
425 final TypeAnnotationPosition pos) |
425 final TypeAnnotationPosition pos) |
426 { |
426 { |
427 if (annotations.isEmpty()) { |
427 if (annotations.isEmpty()) { |
428 return type; |
428 return type; |
429 } |
429 } |
|
430 // All annotations share the same position |
|
431 for (TypeCompound tc : annotations) { |
|
432 Assert.check(tc.position == pos); |
|
433 } |
430 |
434 |
431 if (type.hasTag(TypeTag.ARRAY)) |
435 if (type.hasTag(TypeTag.ARRAY)) |
432 return rewriteArrayType((ArrayType)type, annotations, pos); |
436 return rewriteArrayType((ArrayType)type, annotations, pos); |
433 |
437 |
434 if (type.hasTag(TypeTag.TYPEVAR)) { |
438 if (type.hasTag(TypeTag.TYPEVAR)) { |
520 } |
524 } |
521 |
525 |
522 if (depth.nonEmpty()) { |
526 if (depth.nonEmpty()) { |
523 // Only need to change the annotation positions |
527 // Only need to change the annotation positions |
524 // if they are on an enclosed type. |
528 // if they are on an enclosed type. |
525 // All annotations share the same position; modify the first one. |
529 pos.location = pos.location.appendList(depth.toList()); |
526 Attribute.TypeCompound a = annotations.get(0); |
|
527 TypeAnnotationPosition p = a.position; |
|
528 p.location = p.location.appendList(depth.toList()); |
|
529 } |
530 } |
530 |
531 |
531 Type ret = typeWithAnnotations(type, enclTy, annotations); |
532 Type ret = typeWithAnnotations(type, enclTy, annotations); |
532 typetree.type = ret; |
533 typetree.type = ret; |
533 return ret; |
534 return ret; |
581 elemType = tmpType.cloneWithMetadata(new TypeMetadata(new TypeMetadata.Annotations(annotations))); |
582 elemType = tmpType.cloneWithMetadata(new TypeMetadata(new TypeMetadata.Annotations(annotations))); |
582 } |
583 } |
583 tomodify.elemtype = elemType; |
584 tomodify.elemtype = elemType; |
584 |
585 |
585 // Update positions |
586 // Update positions |
586 for (TypeCompound tc : annotations) { |
587 pos.location = loc; |
587 if (tc.position == null) |
|
588 tc.position = pos; |
|
589 tc.position.location = loc; |
|
590 } |
|
591 |
588 |
592 return res; |
589 return res; |
593 } |
590 } |
594 |
591 |
595 /** Return a copy of the first type that only differs by |
592 /** Return a copy of the first type that only differs by |
1394 } |
1391 } |
1395 } |
1392 } |
1396 scan(tree.elems); |
1393 scan(tree.elems); |
1397 } |
1394 } |
1398 |
1395 |
1399 |
|
1400 private void findTypeCompoundPosition(JCTree tree, JCTree frame, List<Attribute.TypeCompound> annotations) { |
|
1401 if (!annotations.isEmpty()) { |
|
1402 final TypeAnnotationPosition p = |
|
1403 resolveFrame(tree, frame, frames, currentLambda, 0, new ListBuffer<>()); |
|
1404 for (TypeCompound tc : annotations) |
|
1405 tc.position = p; |
|
1406 } |
|
1407 } |
|
1408 |
|
1409 private void findPosition(JCTree tree, JCTree frame, List<JCAnnotation> annotations) { |
1396 private void findPosition(JCTree tree, JCTree frame, List<JCAnnotation> annotations) { |
1410 if (!annotations.isEmpty()) |
1397 if (!annotations.isEmpty()) |
1411 { |
1398 { |
1412 final TypeAnnotationPosition p = |
1399 final TypeAnnotationPosition p = |
1413 resolveFrame(tree, frame, frames, currentLambda, 0, new ListBuffer<>()); |
1400 resolveFrame(tree, frame, frames, currentLambda, 0, new ListBuffer<>()); |