diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2020-12-10 17:26:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-10 17:26:25 +0100 |
commit | 0bda744baf91150e477a59756747977475275e46 (patch) | |
tree | bf59e37bdbfc9c6f35feff21e9db1905e0dba5c7 /test/transform/resource/before | |
parent | c14aa6a6988f2bffa260f311b7b283078d8108d9 (diff) | |
parent | db80bb0a2168245dbae2e1ec565a830e92a7c684 (diff) | |
download | lombok-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/before')
-rw-r--r-- | test/transform/resource/before/ExtensionMethodFunctional.java | 18 | ||||
-rw-r--r-- | test/transform/resource/before/ExtensionMethodGeneric.java | 34 |
2 files changed, 50 insertions, 2 deletions
diff --git a/test/transform/resource/before/ExtensionMethodFunctional.java b/test/transform/resource/before/ExtensionMethodFunctional.java index 19983258..a9e7dd9f 100644 --- a/test/transform/resource/before/ExtensionMethodFunctional.java +++ b/test/transform/resource/before/ExtensionMethodFunctional.java @@ -1,10 +1,13 @@ // version 8: -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) +@ExtensionMethod(value = ExtensionMethodFunctional.Extensions.class, suppressBaseMethods = false) class ExtensionMethodFunctional { public void test() { String test = "test"; @@ -12,6 +15,9 @@ class ExtensionMethodFunctional { test.consume(s -> System.out.println("1: " + s), s -> System.out.println("2: " + s)); test.consume(System.out::println, System.out::println); + + Stream.of("a", "b", "c").map(String::toUpperCase).toList(); + List<Integer> i2 = Stream.of("a", "b", "c").map(String::toUpperCase).toList2(); } static class Extensions { @@ -29,5 +35,13 @@ class ExtensionMethodFunctional { 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; + } } } diff --git a/test/transform/resource/before/ExtensionMethodGeneric.java b/test/transform/resource/before/ExtensionMethodGeneric.java new file mode 100644 index 00000000..d44c663b --- /dev/null +++ b/test/transform/resource/before/ExtensionMethodGeneric.java @@ -0,0 +1,34 @@ +import java.util.List; +import java.util.Map; + +import lombok.experimental.ExtensionMethod; + +@ExtensionMethod(ExtensionMethodGeneric.Extensions.class) +class ExtensionMethodGeneric { + public void test() { + List<String> stringList = null; + List<Number> numberList = null; + stringList.test(); + stringList.test(numberList); + stringList.test(stringList).test(numberList); + Integer i = stringList.test2(); + + Map<String, Integer> map = null; + List<String> l = map.test(stringList, numberList); + } + + static class Extensions { + 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; + } + } +} |