From 46665734a64bc58af5440d401507f127a2088ec4 Mon Sep 17 00:00:00 2001 From: Aosen Xiong Date: Tue, 12 Nov 2024 16:39:56 -0800 Subject: [PATCH] Update the test case and getter method --- .../framework/type/AnnotatedTypeFactory.java | 7 ++++++- .../framework/util/defaults/QualifierDefaults.java | 7 +++++-- framework/tests/viewpointtest/DefaultQualifierTest.java | 3 ++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/framework/src/main/java/org/checkerframework/framework/type/AnnotatedTypeFactory.java b/framework/src/main/java/org/checkerframework/framework/type/AnnotatedTypeFactory.java index 10c053e2515..b0dd326981b 100644 --- a/framework/src/main/java/org/checkerframework/framework/type/AnnotatedTypeFactory.java +++ b/framework/src/main/java/org/checkerframework/framework/type/AnnotatedTypeFactory.java @@ -526,7 +526,7 @@ void checkRep(String aliasName) { * Mapping from an Element to its annotated type; before defaults are applied, just what the * programmer wrote. */ - public final Map elementCache; + private final Map elementCache; /** Mapping from an Element to the source Tree of the declaration. */ private final Map elementToTreeCache; @@ -752,6 +752,11 @@ public AnnotatedTypeFactory(BaseTypeChecker checker) { mergeStubsWithSource = checker.hasOption("mergeStubsWithSource"); } + /** Get the element cache. */ + public Map getElementCache() { + return elementCache; + } + /** * Parse a string in the format {@code * FQN.canonical.Qualifier:FQN.alias1.Qual1,FQN.alias2.Qual2} to a pair of {@code diff --git a/framework/src/main/java/org/checkerframework/framework/util/defaults/QualifierDefaults.java b/framework/src/main/java/org/checkerframework/framework/util/defaults/QualifierDefaults.java index 5e0a5a889cc..5cfaf8efbeb 100644 --- a/framework/src/main/java/org/checkerframework/framework/util/defaults/QualifierDefaults.java +++ b/framework/src/main/java/org/checkerframework/framework/util/defaults/QualifierDefaults.java @@ -1014,12 +1014,15 @@ public Void scan(@FindDistinct AnnotatedTypeMirror t, AnnotationMirror qual) { if (outer.scope != null && outer.scope.getKind().isClass() && isTopLevelType) { AnnotationMirror annotation = outer.qualHierarchy.findAnnotationInHierarchy( - atypeFactory.elementCache.get(outer.scope).getAnnotations(), + atypeFactory + .getElementCache() + .get(outer.scope) + .getAnnotations(), qual); if (annotation == null || outer.qualHierarchy.isSubtypeQualifiersOnly(qual, annotation)) { outer.addAnnotation(t, qual); - atypeFactory.elementCache.put(outer.scope, t); + atypeFactory.getElementCache().put(outer.scope, t); } else { // should report error; } diff --git a/framework/tests/viewpointtest/DefaultQualifierTest.java b/framework/tests/viewpointtest/DefaultQualifierTest.java index f2073d94472..f6b7e3d229e 100644 --- a/framework/tests/viewpointtest/DefaultQualifierTest.java +++ b/framework/tests/viewpointtest/DefaultQualifierTest.java @@ -7,6 +7,7 @@ value = A.class, locations = {TypeUseLocation.TYPE}) public class DefaultQualifierTest { - // :: error: (type.invalid.annotations.on.use) + // :: error: (type.invalid.annotations.on.use) :: error: (super.invocation.invalid) :: warning: + // (inconsistent.constructor.type) @B DefaultQualifierTest() {} }