Skip to content

Don't add duplicates to list - #7893

Open
mernst wants to merge 65 commits into
typetools:masterfrom
mernst:type-inference-8-review-2-3
Open

Don't add duplicates to list#7893
mernst wants to merge 65 commits into
typetools:masterfrom
mernst:type-inference-8-review-2-3

Conversation

@mernst

@mernst mernst commented Jul 30, 2026

Copy link
Copy Markdown
Member

No description provided.

mernst added 30 commits July 25, 2026 13:21
mernst added 16 commits July 30, 2026 07:56
@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The pull request updates type-inference constraint handling. Invocation processing now uses the shared additional-constraint helper. Constraint collection filters null and duplicate entries. Method-reference reduction handles null return types. Dependency calculation skips missing entries. Checked-exception processing reuses annotated thrown types. Qualifier variables emit qualifier-specific constraint kinds. An obsolete commented-out statement is removed.

Possibly related PRs

Suggested reviewers: smillst

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@framework/src/main/java/org/checkerframework/framework/util/typeinference8/constraint/ConstraintSet.java`:
- Line 120: Update the varargs ConstraintSet(Constraint...) constructor to
initialize an empty set and route each supplied constraint through add, matching
the filtering used by constraintSet.forEach(this::add). Ensure duplicates and
null arguments are excluded so the duplicate-free invariant and reduction
behavior are preserved.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 6cd43ec7-1bd5-4f9f-8b94-16fdfeba0902

📥 Commits

Reviewing files that changed from the base of the PR and between ea39f24 and 8747d10.

📒 Files selected for processing (7)
  • framework/src/main/java/org/checkerframework/framework/util/typeinference8/InvocationTypeInference.java
  • framework/src/main/java/org/checkerframework/framework/util/typeinference8/constraint/ConstraintSet.java
  • framework/src/main/java/org/checkerframework/framework/util/typeinference8/constraint/Expression.java
  • framework/src/main/java/org/checkerframework/framework/util/typeinference8/types/AbstractType.java
  • framework/src/main/java/org/checkerframework/framework/util/typeinference8/types/Dependencies.java
  • framework/src/main/java/org/checkerframework/framework/util/typeinference8/types/InferenceFactory.java
  • framework/src/main/java/org/checkerframework/framework/util/typeinference8/types/QualifierVar.java
💤 Files with no reviewable changes (1)
  • framework/src/main/java/org/checkerframework/framework/util/typeinference8/types/AbstractType.java

*/
public void addAll(Collection<? extends Constraint> constraintSet) {
list.addAll(constraintSet);
constraintSet.forEach(this::add);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Apply the same filtering in the varargs constructor.

ConstraintSet(Constraint...) still inserts Arrays.asList(constraints) directly at Lines 82-85. Therefore, new ConstraintSet(c, c) can still violate the duplicate-free invariant documented at Lines 56-59. A null constructor argument can also remain in list and cause a failure during reduction.

Route every constructor element through add.

Proposed fix
 public ConstraintSet(Constraint... constraints) {
   if (constraints != null) {
     list = new ArrayList<>(constraints.length);
-    list.addAll(Arrays.asList(constraints));
+    for (Constraint constraint : constraints) {
+      add(constraint);
+    }
   } else {
     list = new ArrayList<>();
   }
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
constraintSet.forEach(this::add);
public ConstraintSet(Constraint... constraints) {
if (constraints != null) {
list = new ArrayList<>(constraints.length);
for (Constraint constraint : constraints) {
add(constraint);
}
} else {
list = new ArrayList<>();
}
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@framework/src/main/java/org/checkerframework/framework/util/typeinference8/constraint/ConstraintSet.java`
at line 120, Update the varargs ConstraintSet(Constraint...) constructor to
initialize an empty set and route each supplied constraint through add, matching
the filtering used by constraintSet.forEach(this::add). Ensure duplicates and
null arguments are excluded so the duplicate-free invariant and reduction
behavior are preserved.

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.

1 participant