Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Tests involving Map with unbounded wildcards throw LST error #4280

Open
Philzen opened this issue Jun 21, 2024 · 0 comments
Open

🐛 Tests involving Map with unbounded wildcards throw LST error #4280

Philzen opened this issue Jun 21, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@Philzen
Copy link

Philzen commented Jun 21, 2024

This happens on OpenRewrite 8.28.1

rewriteRun-tests on a recipe that rewrites J.MethodInvocation arguments of type Map<?, ?> throw

java.lang.IllegalStateException: LST contains missing or invalid type information
MethodInvocation->Block->MethodDeclaration->Block->ClassDeclaration->CompilationUnit
/*~~(MethodInvocation type is missing or malformed)~~>*/SomeClassWithGenericMethod.someSimilarMethod(map)

for now apparent reason 🤷 – the recipe can be built, installed and run against existing code fine.

This happens on a final pass at org.openrewrite.java.Assertions.assertValidTypes after the before/after assertion has passed – if it doesn't, the tests fail as usual with the diff.

Example

I have assembled the most minimal example was able to unpack here:

  1. lstError_example1_methodInvocationType
  2. lstError_example2_methodInvocationType
  3. lstError_example3_methodInvocationType

With the accompanying Recipe GenericsLstIssue

This may happen with other unbounded wildcard types, needs further investigation.

Workaround

Configuring the RewriteTest#defaults() with

spec -> spec.typeValidationOptions(TypeValidation.none()),

disables the final check which apparently triggers this warning (thanks @knutwannheden for pointing this out).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Backlog
Development

No branches or pull requests

1 participant