Cope with missing annotation parameter#691
Merged
keynmol merged 1 commit intosourcegraph:mainfrom Apr 8, 2024
Merged
Conversation
Contributor
|
Hey @Arthurm1 the fix looks as what I'd expect, can you please add the reproducer to snapshot tests? I think this place would fit well: https://github.com/sourcegraph/scip-java/tree/main/tests/minimized/src/main/java/minimized This is the first NPE I've seen in running scip-java across lots of codebases, so a test would be good to prevent regressions. |
4f62b19 to
71126bc
Compare
Contributor
Author
|
@keynmol I've added the test supplied in the reproducer. I've run the snapshot on Windows - hopefully that won't cause issues in matching in the CI |
keynmol
approved these changes
Apr 8, 2024
Contributor
|
Thanks @Arthurm1! I'll do a patch release so that Metals can pull it in. |
Aamanuel01
reviewed
May 23, 2025
Aamanuel01
left a comment
There was a problem hiding this comment.
tests/snapshots/src/main/generated/tests/minimized/src/main/java/minimized/AnnotationsOnParameterizedTypes.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 is a quick fix for #686
When
@SuppressWarnings("unchecked")is used on a class or method, theTreePathScannerwill scan yielding all nodes before scanning the class/method so all those nodes can be used when emitting symbol info e.g. the following nodes for the annotation are all present...But when the annotation is added to a variable then the scanner yields...
then it scans the variable and then the rest of the annotation. I've no idea why it does it in this order. Notice the
valuenode is missing.This PR simply stops the link to
valuebeing added. It's unused anyway sincevaluedoesn't appear in the code and therefore can't be linked to. The reason it's being checked is thatjavacimplicitly adds it during the scan.If the code actually contains
valuee.g.@SuppressWarnings(value = "unchecked")then the annotation is scanned before the variable and adds the link correctly. So I don't think this fix should be an issue.Test plan
I've added no tests for this. Should I add the reproducer code in the issue as a new snapshot test?