Skip to content

Commit

Permalink
Update the test case and getter method
Browse files Browse the repository at this point in the history
  • Loading branch information
Ao-senXiong committed Nov 13, 2024
1 parent 6bfedba commit 4666573
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Element, AnnotatedTypeMirror> elementCache;
private final Map<Element, AnnotatedTypeMirror> elementCache;

/** Mapping from an Element to the source Tree of the declaration. */
private final Map<Element, Tree> elementToTreeCache;
Expand Down Expand Up @@ -752,6 +752,11 @@ public AnnotatedTypeFactory(BaseTypeChecker checker) {
mergeStubsWithSource = checker.hasOption("mergeStubsWithSource");
}

/** Get the element cache. */
public Map<Element, AnnotatedTypeMirror> getElementCache() {
return elementCache;
}

/**
* Parse a string in the format {@code
* FQN.canonical.Qualifier:FQN.alias1.Qual1,FQN.alias2.Qual2} to a pair of {@code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion framework/tests/viewpointtest/DefaultQualifierTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
}

0 comments on commit 4666573

Please sign in to comment.