typetools / typetools/checker-framework

Need for self-reference in dependent type annotations

Open
#4,142 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
1.1k
Forks
440
Avg merge
1d 12h
Merged PRs (30d)
134

Description

The Nullness Checker rejects the following assignments:

    public void copy1(
            HashMap<String, List<@KeyFor("#1") String>> a,
            HashMap<String, List<@KeyFor("#2") String>> b) {
        a = b;  // incorrectly rejected
    }

    public void copy2() {
        HashMap<String, List<@KeyFor("b") String>> b = null;  // OK
        HashMap<String, List<@KeyFor("a") String>> a = b;     // incorrectly rejected
    }

There are numerous other examples in file SelfDependentType.java, which also illustrates other bugs.

To make this type-check seems to require either significantly more sophisticated dependent type standardization at assignments, or a <self> type like that supported by the Lock Checker.

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 reading SelfDependentType.java and the two assignment examples in the issue, then trace how the Nullness Checker standardizes dependent type annotations during assignment checking. Compare the failing cases with the self-reference support mentioned for the Lock Checker. Done means the documented self-referential assignments type-check without regressing the other examples in SelfDependentType.java.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
compilers, devtools
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.