Skip to content

Fix Java parser corruption for inferred lambda parameters - #8709

Open
sebastianhaeni wants to merge 2 commits into
openrewrite:mainfrom
sebastianhaeni:fix-java-parser-corruption-for-inferred-lambda-parameters
Open

Fix Java parser corruption for inferred lambda parameters#8709
sebastianhaeni wants to merge 2 commits into
openrewrite:mainfrom
sebastianhaeni:fix-java-parser-corruption-for-inferred-lambda-parameters

Conversation

@sebastianhaeni

@sebastianhaeni sebastianhaeni commented Aug 28, 2026

Copy link
Copy Markdown

What's changed?

What's your motivation?

Anything in particular you'd like reviewers to focus on?

Please review whether hasLombokGeneratedSymbol(node) is the appropriate discriminator across all supported Java parser versions.

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions and best practices (not applicable: this changes parser internals, not a recipe)
  • I've run ./gradlew build locally, and committed any resulting changes to recipes.csv (targeted compatibility tests were run instead)
  • I've formatted the lines I changed, without reformatting code I didn't touch

Comment on lines +1773 to +1774
if (!hasLombokGeneratedSymbol(node)) {
// Inferred lambda parameter types and unresolved types have no source representation.

@timtebeek timtebeek Aug 28, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Cross linking to make review easier:

private static boolean hasLombokGeneratedSymbol(Tree t) {
Tree tree = (t instanceof JCAnnotation) ? ((JCAnnotation) t).getAnnotationType() : t;
Symbol sym = extractSymbol(tree);
if (sym == null) {
return false;
}
return isLombokAnnotationType(sym.getQualifiedName().toString()) ||
sym.getDeclarationAttributes().stream()
.map(a -> a.type.toString())
.anyMatch(ReloadableJava25ParserVisitor::isLombokAnnotationType);
}
private static boolean isLombokAnnotationType(String name) {
return "lombok.val".equals(name) ||
"lombok.var".equals(name) ||
"lombok.Generated".equals(name);
}

@timtebeek

Copy link
Copy Markdown
Member

Thanks a lot for the immediately proposed fix @sebastianhaeni ! I've kicked off CI, but will be out for three weeks after today, so I'll leave it up to colleagues to review and merge. 😅

@timtebeek timtebeek added the bug Something isn't working label Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working java parser

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

Java parser corrupts inferred lambda parameters when type attribution is incomplete

2 participants