Skip to content

Add type as part of target location#972

Open
aosen-xiong wants to merge 9 commits into
eisop:masterfrom
aosen-xiong:add-type-as-location
Open

Add type as part of target location#972
aosen-xiong wants to merge 9 commits into
eisop:masterfrom
aosen-xiong:add-type-as-location

Conversation

@aosen-xiong

@aosen-xiong aosen-xiong commented Nov 7, 2024

Copy link
Copy Markdown
Collaborator

Merge with eisop/jdk#134.

@aosen-xiong

aosen-xiong commented Nov 8, 2024

Copy link
Copy Markdown
Collaborator Author

Hi @wmdietl, do you know how to update the elementcache in

private final Map<Element, AnnotatedTypeMirror> elementCache;
.

It is later retrieved at here.

The expected error did not come up because in the elementCache it does not contain annotation added from DefaultQualifier.

@aosen-xiong

Copy link
Copy Markdown
Collaborator Author

The root cause should be here as the method getTypeDeclarationBounds

atypeFactory.getTypeDeclarationBounds(type.getUnderlyingType());

which does not consider bound in Defaultqualifier annotation like @DefaultQualifier( value = A.class, locations = {TypeUseLocation.TYPE})

@aosen-xiong aosen-xiong self-assigned this Dec 17, 2024
Copilot AI review requested due to automatic review settings May 27, 2026 03:25

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds support for applying @DefaultQualifier at a new TypeUseLocation.TYPE to default top-level class/interface/enum/record types, along with a regression test.

Changes:

  • Introduce TypeUseLocation.TYPE enum constant and documentation.
  • Apply defaults for TYPE in QualifierDefaults using the element cache to detect/avoid conflicting annotations.
  • Add a viewpoint test that exercises invalid annotation interactions with the new TYPE location.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
framework/tests/viewpointtest/DefaultQualifierTest.java Adds a regression test for defaulting behavior at TypeUseLocation.TYPE.
framework/src/main/java/org/checkerframework/framework/util/defaults/QualifierDefaults.java Implements default application logic for the new TYPE location.
framework/src/main/java/org/checkerframework/framework/type/AnnotatedTypeFactory.java Exposes the element cache for use in defaulting logic.
checker-qual/src/main/java/org/checkerframework/framework/qual/TypeUseLocation.java Adds TYPE as a new location and documents its semantics.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread framework/tests/viewpointtest/DefaultQualifierTest.java Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants