typetools / typetools/checker-framework
Strong assignment doesn't update fields
Open
Nobody has claimed this yet.
Dataflow
False Positive (false warning or imprecision)
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 440
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 134
Description
Consider the following example from the nullness checker:
import org.checkerframework.checker.nullness.qual.*;
class ObjectAssignment {
@Nullable Object o;
static void test_nullness(ObjectAssignment a, ObjectAssignment b) {
a.o = new Object();
b = a;
int k = b.o.hashCode(); // issues a warning
int j = a.o.hashCode(); // does not issue a warning
}
}
This also occurs in other checkers (e.g. Index). In general, if an object a with field f is assigned (i.e. a = b), then a.f should have the same type as b.f.
Contributor guide
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.
Research direction
Start by reproducing the nullness-checker example from the issue, then inspect how assignments are handled in the nullness and Index checkers. Done means assigning one object to another updates the selected object's field types consistently, so the example and analogous Index cases produce the expected warnings.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100