8329951: var
emits deprecation warnings that do not point to the file or position
#23683
+33
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes a bug that causes certain warnings to be emitted without source file location information.
Consider this example:
the compiler outputs this:
but it should instead output this:
The bug happens because the "synthetic" type that is installed dynamically for implicitly typed variables is not given a source code position. This makes some sense (?) because that type doesn't literally appear in the variable declaration; however, certain error messages expect to be able to point to the type portion of a variable declaration, so it also causes this bug (and presumably similar variants). To fix this, we just copy the position of the variable declaration itself to the synthetic type.
However, this change necessitated another change: The fix for JDK-8200199 added back in 2018 relies on the fact that the position of an implicitly typed variable is always null, so this change breaks that fix. But since then, a new method
JCVariableDecl.declaredUsingVar()
was added, so we can just use that test instead. This also makes the code a little clearer.Progress
Issue
var
emits deprecation warnings that do not point to the file or position (Bug - P4)Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/23683/head:pull/23683
$ git checkout pull/23683
Update a local copy of the PR:
$ git checkout pull/23683
$ git pull https://git.openjdk.org/jdk.git pull/23683/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 23683
View PR using the GUI difftool:
$ git pr show -t 23683
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/23683.diff
Using Webrev
Link to Webrev Comment