aboutsummaryrefslogtreecommitdiff
path: root/test/transform/resource/after-ecj
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2020-12-10 17:26:25 +0100
committerGitHub <noreply@github.com>2020-12-10 17:26:25 +0100
commit0bda744baf91150e477a59756747977475275e46 (patch)
treebf59e37bdbfc9c6f35feff21e9db1905e0dba5c7 /test/transform/resource/after-ecj
parentc14aa6a6988f2bffa260f311b7b283078d8108d9 (diff)
parentdb80bb0a2168245dbae2e1ec565a830e92a7c684 (diff)
downloadlombok-0bda744baf91150e477a59756747977475275e46.tar.gz
lombok-0bda744baf91150e477a59756747977475275e46.tar.bz2
lombok-0bda744baf91150e477a59756747977475275e46.zip
Merge pull request #2658 from Rawi01/extension-method-generic
Reset inference context for extension methods
Diffstat (limited to 'test/transform/resource/after-ecj')
-rw-r--r--test/transform/resource/after-ecj/ExtensionMethodFunctional.java15
-rw-r--r--test/transform/resource/after-ecj/ExtensionMethodGeneric.java35
2 files changed, 48 insertions, 2 deletions
diff --git a/test/transform/resource/after-ecj/ExtensionMethodFunctional.java b/test/transform/resource/after-ecj/ExtensionMethodFunctional.java
index 0190eabb..e847c1f0 100644
--- a/test/transform/resource/after-ecj/ExtensionMethodFunctional.java
+++ b/test/transform/resource/after-ecj/ExtensionMethodFunctional.java
@@ -1,7 +1,10 @@
-import java.util.function.Function;
import java.util.function.Consumer;
+import java.util.function.Function;
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
import lombok.experimental.ExtensionMethod;
-@ExtensionMethod(ExtensionMethodFunctional.Extensions.class) class ExtensionMethodFunctional {
+@ExtensionMethod(value = ExtensionMethodFunctional.Extensions.class,suppressBaseMethods = false) class ExtensionMethodFunctional {
static class Extensions {
Extensions() {
super();
@@ -18,6 +21,12 @@ import lombok.experimental.ExtensionMethod;
consumer[i].accept(o);
}
}
+ public static <T>List<T> toList(Stream<T> stream) {
+ return (List<T>) stream.collect(Collectors.toList());
+ }
+ public static <T, U>List<U> toList2(Stream<T> stream) {
+ return null;
+ }
}
ExtensionMethodFunctional() {
super();
@@ -27,5 +36,7 @@ import lombok.experimental.ExtensionMethod;
test = ExtensionMethodFunctional.Extensions.map(test, (<no type> s) -> ExtensionMethodFunctional.Extensions.reverse(s));
ExtensionMethodFunctional.Extensions.consume(test, (<no type> s) -> System.out.println(("1: " + s)), (<no type> s) -> System.out.println(("2: " + s)));
ExtensionMethodFunctional.Extensions.consume(test, System.out::println, System.out::println);
+ ExtensionMethodFunctional.Extensions.toList(Stream.of("a", "b", "c").map(String::toUpperCase));
+ List<Integer> i2 = ExtensionMethodFunctional.Extensions.toList2(Stream.of("a", "b", "c").map(String::toUpperCase));
}
}
diff --git a/test/transform/resource/after-ecj/ExtensionMethodGeneric.java b/test/transform/resource/after-ecj/ExtensionMethodGeneric.java
new file mode 100644
index 00000000..2bfab9cc
--- /dev/null
+++ b/test/transform/resource/after-ecj/ExtensionMethodGeneric.java
@@ -0,0 +1,35 @@
+import java.util.List;
+import java.util.Map;
+import lombok.experimental.ExtensionMethod;
+@ExtensionMethod(ExtensionMethodGeneric.Extensions.class) class ExtensionMethodGeneric {
+ static class Extensions {
+ Extensions() {
+ super();
+ }
+ public static <T>List<T> test(List<String> obj, List<T> list) {
+ return null;
+ }
+ public static <K, V>K test(Map<String, Integer> obj, K k, V v) {
+ return k;
+ }
+ public static <T>T test(List<T> list) {
+ return null;
+ }
+ public static <T, U>U test2(List<T> list) {
+ return null;
+ }
+ }
+ ExtensionMethodGeneric() {
+ super();
+ }
+ public void test() {
+ List<String> stringList = null;
+ List<Number> numberList = null;
+ ExtensionMethodGeneric.Extensions.test(stringList);
+ ExtensionMethodGeneric.Extensions.test(stringList, numberList);
+ ExtensionMethodGeneric.Extensions.test(ExtensionMethodGeneric.Extensions.test(stringList, stringList), numberList);
+ Integer i = ExtensionMethodGeneric.Extensions.test2(stringList);
+ Map<String, Integer> map = null;
+ List<String> l = ExtensionMethodGeneric.Extensions.test(map, stringList, numberList);
+ }
+} \ No newline at end of file