-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[BUG] ExtensionMethod for generic types does not work with generic parameters in ecj #2648
Comments
I added some code to copy generic information which seems to break this example: |
Was about to send a PR to remove the block but finally figured out what I tried to solve: import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import lombok.experimental.ExtensionMethod;
@ExtensionMethod(ExtensionMethodGeneric.Extensions.class)
class ExtensionMethodGeneric {
public void test() {
Stream.of("a", "b", "c").map(String::toUpperCase).toList();
}
static class Extensions {
public static <T> List<T> toList(Stream<T> stream) {
return (List<T>) stream.collect(Collectors.toList());
}
}
} |
…formation copy In Java >= 8 ecj uses the inference context to resolve the generic information. This one is already set before lombok tries rewrite the method call. Simply copying the information does not cover all the different cases but reseting the inference contexts and running type inference again does.
Describe the bug
Adding extension methods for generic types seems to be broken if there also is a generic parameter. I think I broke this while working a bunch of other bugs. I will try to fix this myself...
To Reproduce
Expected behavior
It compiles without any error as it does if you call the extension method by hand.
Version info:
Additional context
This is a simplified example, there might be more problems if you use more complex generic stuff.
The text was updated successfully, but these errors were encountered: