Skip to content

handle unresolved annotation parameter tree differences#191

Merged
Strum355 merged 1 commit into
mainfrom
nsc/unresolved-annotation-fix186
Apr 27, 2021
Merged

handle unresolved annotation parameter tree differences#191
Strum355 merged 1 commit into
mainfrom
nsc/unresolved-annotation-fix186

Conversation

@Strum355

Copy link
Copy Markdown
Contributor

In certain situations when an annotation symbol cannot be resolved, the tree types of parameters are not JCAssign.
This PR addresses the cast exceptions caused by this.

The SignatureFormatter is also modified to accept the new semanticdb output but from what I have seen, the codepaths arent reached for those unresolved annotations (typically getting the __root__/ symbol).

Closes #186

@olafurpg olafurpg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 It would be nice to have a targeted test case, if only to validate that we can test code with compile errors. However, I'm OK with merging this without tests. It's always good to get rid of unsafe casts

import java.util.*;
import java.util.stream.Collectors;

import static com.sourcegraph.semanticdb_javac.Debugging.pprint;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove

@Strum355

Copy link
Copy Markdown
Contributor Author

Tried recreating the issue in an isolated case, but even there I would get a JCAssign tree 😞

@Strum355 Strum355 force-pushed the nsc/unresolved-annotation-fix186 branch from 91f60be to c6b83d0 Compare April 27, 2021 13:15
@Strum355 Strum355 merged commit b1a204a into main Apr 27, 2021
@Strum355 Strum355 deleted the nsc/unresolved-annotation-fix186 branch April 27, 2021 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ClassCastException: com.sun.tools.javac.tree.JCTree$JCLiteral cannot be cast to com.sun.tools.javac.tree.JCTree$JCAssign

2 participants