8215366: Code quality improvements in com.sun.tools.javac.code.TypeAnnotations
Reviewed-by: mcimadamore, wmdietl, bsrbnd
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotations.java Tue Dec 11 10:23:15 2018 -0800
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotations.java Thu Dec 13 10:08:22 2018 -0800
@@ -427,6 +427,10 @@
if (annotations.isEmpty()) {
return type;
}
+ // All annotations share the same position
+ for (TypeCompound tc : annotations) {
+ Assert.check(tc.position == pos);
+ }
if (type.hasTag(TypeTag.ARRAY))
return rewriteArrayType((ArrayType)type, annotations, pos);
@@ -522,10 +526,7 @@
if (depth.nonEmpty()) {
// Only need to change the annotation positions
// if they are on an enclosed type.
- // All annotations share the same position; modify the first one.
- Attribute.TypeCompound a = annotations.get(0);
- TypeAnnotationPosition p = a.position;
- p.location = p.location.appendList(depth.toList());
+ pos.location = pos.location.appendList(depth.toList());
}
Type ret = typeWithAnnotations(type, enclTy, annotations);
@@ -583,11 +584,7 @@
tomodify.elemtype = elemType;
// Update positions
- for (TypeCompound tc : annotations) {
- if (tc.position == null)
- tc.position = pos;
- tc.position.location = loc;
- }
+ pos.location = loc;
return res;
}
@@ -1396,16 +1393,6 @@
scan(tree.elems);
}
-
- private void findTypeCompoundPosition(JCTree tree, JCTree frame, List<Attribute.TypeCompound> annotations) {
- if (!annotations.isEmpty()) {
- final TypeAnnotationPosition p =
- resolveFrame(tree, frame, frames, currentLambda, 0, new ListBuffer<>());
- for (TypeCompound tc : annotations)
- tc.position = p;
- }
- }
-
private void findPosition(JCTree tree, JCTree frame, List<JCAnnotation> annotations) {
if (!annotations.isEmpty())
{