Don't add duplicates to list - #7893
Conversation
…into type-inference-8-review
… into type-inference-8-review-2-3
… into type-inference-8-review-2-3
… into type-inference-8-review-2-3
… into type-inference-8-review-2-3
… into type-inference-8-review-2-3
… into type-inference-8-review-2-3
… into type-inference-8-review-2-3
… into type-inference-8-review-2-3
… into type-inference-8-review-2-3
…type-inference-8-review
… into type-inference-8-review-2-3
… into type-inference-8-review-2-3
… into type-inference-8-review-2-3
… into type-inference-8-review-2-3
… into type-inference-8-review-2-3
… into type-inference-8-review-2-3
📝 WalkthroughWalkthroughThe 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: 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
… into type-inference-8-review-2-3
… into type-inference-8-review-2-3
… into type-inference-8-review-2-3
…er-framework into type-inference-8-review-2-3
… into type-inference-8-review-2-3
… into type-inference-8-review-2-3
There was a problem hiding this comment.
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
📒 Files selected for processing (7)
framework/src/main/java/org/checkerframework/framework/util/typeinference8/InvocationTypeInference.javaframework/src/main/java/org/checkerframework/framework/util/typeinference8/constraint/ConstraintSet.javaframework/src/main/java/org/checkerframework/framework/util/typeinference8/constraint/Expression.javaframework/src/main/java/org/checkerframework/framework/util/typeinference8/types/AbstractType.javaframework/src/main/java/org/checkerframework/framework/util/typeinference8/types/Dependencies.javaframework/src/main/java/org/checkerframework/framework/util/typeinference8/types/InferenceFactory.javaframework/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); |
There was a problem hiding this comment.
🎯 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.
| 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.
No description provided.