π Tests involving Map with unbounded wildcards throw LST error
Philzen opened this issue Β· comments
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_methodInvocationType
lstError_example2_methodInvocationType
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
disables the final check which apparently triggers this warning (thanks @knutwannheden for pointing this out).