OpenJDK / jdk / jdk
changeset 53036:d5a2a29ca589
8215366: Code quality improvements in com.sun.tools.javac.code.TypeAnnotations
Reviewed-by: mcimadamore, wmdietl, bsrbnd
author | cushon |
---|---|
date | Thu, 13 Dec 2018 10:08:22 -0800 |
parents | 0e5c83bf4ff7 |
children | e84983c2735e |
files | src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotations.java |
diffstat | 1 files changed, 6 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- 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()) {