typetools / typetools/checker-framework

isVariableTreeDeclaredUsingVar assumes var types don't have start positions, is broken by changes in JDK-8329951

Open Beginner friendly
#7,096 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

isVariableTreeDeclaredUsingVar assumes that the type of a VariableTree declared using var will not have a start position set:

https://github.com/typetools/checker-framework/blob/988f6fc5204337da25d85dc0e7433eaf5d6068c5/javacutil/src/main/java/org/checkerframework/javacutil/TreeUtils.java#L2588-L2591

After an upcoming javac change in https://github.com/openjdk/jdk/commit/e2f736658fbd03d2dc2186dbd9ba9b13b1f1a8ac, start positions are set for types of variables declared using var, so this approach no longer works.

isVariableTreeDeclaredUsingVar could be fixed by also checking for JCVariableDecl#declaredUsingVar

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 in javacutil/src/main/java/org/checkerframework/javacutil/TreeUtils.java at isVariableTreeDeclaredUsingVar, then inspect the JCVariableDecl#declaredUsingVar information mentioned in the issue. Confirm that the method still identifies variables declared with var after javac assigns start positions to their types, and verify the relevant checker-framework behavior against the described JDK change.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
compilers
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.