You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to write a pattern that would match this method. I have this, which should work, but doesn't:
fully.qualified.X doSomething(fully.qualified.Y)
The pattern suddenly starts to match when I use the specific implementation of Y (let's call it YImpl) which I actually use in the test for the recipe:
Consider a method like default <Number_ extends Number> @NonNull Set<Number_> doSomething(@NonNull Number_ number);. Let's assume this method is declared on an interface com.github.MyInterface.
Further consider we're migrating source code like this: myInterfaceImpl.doSomething(BigDecimal.ONE);
This pattern will not match the code: com.github.MyInterface doSomething(java.lang.Number)
This pattern will match: com.github.MyInterface doSomething(java.math.BigDecimal)
The expected result is that the first pattern will match too.
I'm on rewrite-recipe-bom 3.1.0 and OpenJDK 21 (Temurin).
It is possible that the @NonNull annotations have no effect and can be removed; I have not tried that.
The text was updated successfully, but these errors were encountered:
Thanks for logging the issue as well @triceo . @greg-at-moderne FYI: this might factor in with the work you're looking at for Refaster as well: if the type information incorrectly is pegged to the actual type in method invocations, then matching could fail there as well.
I don't know the details here, but I think it was done this way on purpose so that the method invocation captures the actual types that get substituted for the type parameters. But I've also stumbled over this problem in the past in other contexts and I think it could be useful for the JavaType.Method object of a method invocation with type parameters to reference the JavaType.Method of the method declaration. That would then allow the MethodMatcher to work as expected.
Discussed in #5038
In my Java code, I have an interface
X<A>
with the following method:I am trying to write a pattern that would match this method. I have this, which should work, but doesn't:
The pattern suddenly starts to match when I use the specific implementation of
Y
(let's call itYImpl
) which I actually use in the test for the recipe:To provide a more explicit example:
default <Number_ extends Number> @NonNull Set<Number_> doSomething(@NonNull Number_ number);
. Let's assume this method is declared on an interfacecom.github.MyInterface
.myInterfaceImpl.doSomething(BigDecimal.ONE);
com.github.MyInterface doSomething(java.lang.Number)
com.github.MyInterface doSomething(java.math.BigDecimal)
The expected result is that the first pattern will match too.
I'm on
rewrite-recipe-bom
3.1.0 and OpenJDK 21 (Temurin).It is possible that the
@NonNull
annotations have no effect and can be removed; I have not tried that.The text was updated successfully, but these errors were encountered: