Closed knutwannheden closed 3 months ago
this is why you basically shouldn’t ever use #{any()}
but rather always specify a type
Even if you provide a type from the project to #{any(com.type.from.Project)}
the parser wont know about it unless a stub is constructed and passed in. The solution we've briefly discussed before is to generate stubs for any types present in the LST.
I believe this has been addressed with
We can reopen if I misunderstood, but given the timelines those seemed to have aligned.
When
JavaTemplate
is used to modify a piece of code and the template contains expressions, where the types are derived from template parameters, which in turn as their type have some other top-level type in the same compilation unit, then the type attribution is missing after the replacement.Here a test case which could be added to
JavaTemplateTest
, which demonstrates the problem. After the replacement theCollections.singletonList()
method invocation has no type (J.MethodInvocation#methodType
isnull
) because the stub generated byBlockStatementTemplateGenerator
didn't contain theT2
type.