File tree 1 file changed +22
-0
lines changed
src/main/java/com/google/jspecify/nullness
1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change 43
43
44
44
import com .sun .source .tree .BinaryTree ;
45
45
import com .sun .source .tree .ClassTree ;
46
+ import com .sun .source .tree .CompilationUnitTree ;
46
47
import com .sun .source .tree .ExpressionTree ;
47
48
import com .sun .source .tree .IdentifierTree ;
48
49
import com .sun .source .tree .LambdaExpressionTree ;
@@ -374,6 +375,27 @@ private NullSpecAnnotatedTypeFactory(
374
375
}
375
376
}
376
377
378
+ /** Too ensure setRoot is called on both worlds exactly once. */
379
+ private boolean settingRoot = false ;
380
+
381
+ /**
382
+ * Ensure setRoot is called on both worlds exactly once whenever it is called on one of the
383
+ * worlds.
384
+ */
385
+ @ Override
386
+ public void setRoot (@ Nullable CompilationUnitTree root ) {
387
+ if (!settingRoot ) {
388
+ settingRoot = true ;
389
+ super .setRoot (root );
390
+ if (withLeastConvenientWorld != this ) {
391
+ withLeastConvenientWorld .setRoot (root );
392
+ } else {
393
+ withMostConvenientWorld .setRoot (root );
394
+ }
395
+ }
396
+ settingRoot = false ;
397
+ }
398
+
377
399
@ Override
378
400
protected void addCheckedCodeDefaults (QualifierDefaults defs ) {
379
401
// TODO: add false for subpackages once overload is added to CF. Shouldn't really matter.
You can’t perform that action at this time.
0 commit comments