typetools / typetools/checker-framework

Nullness Checker unsoundly (?) assumes that method returns non-null value, despite -AuseConservativeDefaultsForUncheckedCode

Open
#4,079 4 comments 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

A repro is included in https://github.com/VirtusLab/git-machete-intellij-plugin/pull/672/files. I can provide a more stripped-down repro if needed.

In a nutshell, I have a piece like that:

      // org.eclipse.jgit.revwalk.RevWalk walk;
      @Nullable RevCommit mergeBase = walk.next();
      LOG.debug(() -> "Detected merge base for " + c1.getHash().getHashString() + " and " + c2.getHash().getHashString()
          + " is " + mergeBase.getId().getName());

Clearly, calling mergeBase.getId() should not be allowed... yet the compilation passes without an error.

RevWalk#next is declared as:

	public RevCommit next() throws MissingObjectException,
			IncorrectObjectTypeException, IOException {
		return pending.next();
	}

I've also added -AuseConservativeDefaultsForUncheckedCode=+bytecode, to no avail :/

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 with the linked git-machete-intellij-plugin pull-request reproducer and the Nullness Checker treatment of org.eclipse.jgit.revwalk.RevWalk#next. Check how -AuseConservativeDefaultsForUncheckedCode=+bytecode affects the inferred return nullness. Done means the reproducer no longer compiles without a nullness error, with a regression test if the project provides a suitable location.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.