[fixes #3402] Delay replacement of extension methods in arguments

This commit is contained in:
Rawi01 committed 2023-04-16 14:14:26 +02:00
1 parent 3f51b25ac9
commit 4edd8a42d6
7 files changed
+109 -1

No files matched your search

@@ -0,0 +1,33 @@
import java.util.function.Function;
import lombok.experimental.ExtensionMethod;
public @ExtensionMethod(value = ExtensionMethodInLambda.Extensions.class) class ExtensionMethodInLambda {
static class Extensions {
Extensions() {
super();
}
public static <T, R>R map(T value, Function<T, R> mapper) {
return mapper.apply(value);
}
public static String reverse(String string) {
return new StringBuilder(string).reverse().toString();
}
public static String trim(Integer integer) {
return "0";
}
}
public ExtensionMethodInLambda() {
super();
}
public void testSimple() {
String test = "test";
test = ExtensionMethodInLambda.Extensions.map(test, (<no type> s) -> ExtensionMethodInLambda.Extensions.reverse(s));
}
public void testSameName() {
String test = "test";
test = ExtensionMethodInLambda.Extensions.map(test, (<no type> s) -> s.trim());
}
public void testArgumentOfInvalidMethod() {
String test = "test";
test.invalid((<no type> s) -> s.reverse());
}
}