typetools / typetools/checker-framework

Strong assignment doesn't update fields

Open
#1,149 2 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.