Case label does not refine a boxed switch selector
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- java
- Domain
- testing-qa
Research direction
Start with CFGTranslationPhaseOne.buildSelector and CFAbstractTransfer.visitCase, then trace how boxed switch selectors are represented in the control-flow graph. Run the Value Checker command from the issue with the supplied SwitchCaseRefinement.java input and compare boxed and primitive cases. Done means both assignments pass and case-constant refinements reach the boxed selector for checkers that use this transfer.
Written by the indexing model from the issue text.
Description
A case label refines a primitive switch selector, but not a boxed one.
Input
import org.checkerframework.common.value.qual.IntVal;
public class SwitchCaseRefinement {
void boxed(Integer i) {
switch (i) {
case 1:
@IntVal(1) Integer j = i;
break;
default:
break;
}
}
void primitive(int i) {
switch (i) {
case 1:
@IntVal(1) int j = i;
break;
default:
break;
}
}
}
Command
javac -processor org.checkerframework.common.value.ValueChecker SwitchCaseRefinement.java
Actual output
SwitchCaseRefinement.java:7: error: [assignment] incompatible types in assignment.
@IntVal(1) Integer j = i;
^
found : Integer
required: @IntVal(1L) Integer
1 error
Expected output
No error. In the body of case 1, i is 1, just as in method primitive.
Cause
CFGTranslationPhaseOne.buildSelector unboxes a boxed selector, so the expression of the selector assignment is the artificial i.intValue() call rather than i. CFAbstractTransfer.visitCase refines assign.getExpression() and assign.getTarget(), so the refinement goes to the i.intValue() call and to the synthetic selector variable, but not to i. The same applies to every checker that refines on equality with a case constant.
A fix could refine the expression that the unboxing converts, as well as the unboxed expression.
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 440
- Avg merge
- 3d 6h
- Merged PRs (30d)
- 84
Getting set up
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from typetools/checker-framework
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
typetools/checker-framework#8043 ·
Maintainers usually reply within 2 days
-
Enforce `@TargetLocations`Possibly taken @w3lld1 claimed this 64 days ago. Open
Difficulty 1/5 Under an hour Newbie friendliness 85/100
typetools/checker-framework#8042 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
typetools/checker-framework#7096 · 1 comment ·
Maintainers usually reply within 2 days
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
typetools/checker-framework#8483 ·
Maintainers usually reply within 2 days
-
Difficulty 5/5 Over a week Newbie friendliness 15/100
typetools/checker-framework#8475 ·
Maintainers usually reply within 2 days
All issues in typetools/checker-framework
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
NationalSecurityAgency/ghidra#10155 ·
Maintainers usually reply within 2 days
-
bug web-ui
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
jenkinsci/jenkins#27705 · 3 comments ·
Maintainers usually reply within 1 day
-
mod bug
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
elmital/FixMCStats#65 · 3 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
googleads/googleads-mobile-flutter#1541 ·
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
Julow/Unexpected-Keyboard#1490 ·
Maintainers usually reply within 4 days