8215366: Code quality improvements in com.sun.tools.javac.code.TypeAnnotations
authorcushon
Thu, 13 Dec 2018 10:08:22 -0800
changeset 53036 d5a2a29ca589
parent 53035 0e5c83bf4ff7
child 53037 e84983c2735e
8215366: Code quality improvements in com.sun.tools.javac.code.TypeAnnotations Reviewed-by: mcimadamore, wmdietl, bsrbnd
src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotations.java
--- 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())
             {