@@ -113,9 +113,6 @@ public class NullnessNoInitAnnotatedTypeFactory
113113 private final ExecutableElement mapGet =
114114 TreeUtils .getMethod ("java.util.Map" , "get" , 1 , processingEnv );
115115
116- // High-level optimization: cache entire addComputedTypeAnnotations processing flow
117- private final java .util .Set <String > fullyProcessedTrees = new java .util .HashSet <>();
118-
119116 // List is in alphabetical order. If you update it, also update
120117 // ../../../../../../../../docs/manual/nullness-checker.tex
121118 // and make a pull request for variables NONNULL_ANNOTATIONS and BASE_COPYABLE_ANNOTATIONS in
@@ -486,19 +483,6 @@ protected void replacePolyQualifier(AnnotatedTypeMirror lhsType, Tree context) {
486483 }
487484 }
488485
489- @ Override
490- protected void addComputedTypeAnnotations (Tree tree , AnnotatedTypeMirror type ) {
491- if (tree != null && tree instanceof NewClassTree ) {
492- String treeKey = tree .toString ();
493- if (fullyProcessedTrees .contains (treeKey )) {
494- return ;
495- }
496- fullyProcessedTrees .add (treeKey );
497- }
498-
499- super .addComputedTypeAnnotations (tree , type );
500- }
501-
502486 @ Override
503487 protected NullnessNoInitAnalysis createFlowAnalysis () {
504488 return new NullnessNoInitAnalysis (checker , this );
@@ -750,8 +734,9 @@ public Void visitUnary(UnaryTree tree, AnnotatedTypeMirror type) {
750734 // explicit nullable annotations are left intact for the visitor to inspect.
751735 @ Override
752736 public Void visitNewClass (NewClassTree tree , AnnotatedTypeMirror type ) {
753- // The constructor return type should already be NONNULL, so in most cases this will do
754- // nothing.
737+ if (type .hasEffectiveAnnotation (NONNULL )) {
738+ return null ;
739+ }
755740 type .addMissingAnnotation (NONNULL );
756741 return null ;
757742 }
@@ -761,7 +746,9 @@ public Void visitNewClass(NewClassTree tree, AnnotatedTypeMirror type) {
761746 @ Override
762747 public Void visitNewArray (NewArrayTree tree , AnnotatedTypeMirror type ) {
763748 super .visitNewArray (tree , type );
764- type .addMissingAnnotation (NONNULL );
749+ if (!type .hasEffectiveAnnotation (NONNULL )) {
750+ type .addMissingAnnotation (NONNULL );
751+ }
765752 return null ;
766753 }
767754
0 commit comments