openrewrite / openrewrite/rewrite
🐛 Tests involving Map with unbounded wildcards throw LST error
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 3.7k
- Forks
- 570
- Avg merge
- 13h 12m
- Merged PRs (30d)
- 261
Description
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:
lstError_example1_methodInvocationTypelstError_example2_methodInvocationTypelstError_example3_methodInvocationType
With the accompanying Recipe GenericsLstIssue
This may happen with other unbounded wildcard types, needs further investigation.
Workaround
Configuring the RewriteTest#defaults() with
disables the final check which apparently triggers this warning (thanks @knutwannheden for pointing this out).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the three linked examples and inspect the final org.openrewrite.java.Assertions.assertValidTypes check, comparing it with the RewriteTest#defaults() workaround referenced from MethodParamPadTest.java. Trace why MethodInvocation type information is missing for unbounded wildcard Map arguments, then add a regression test showing the examples pass without disabling validation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- compilers, testing-qa
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100