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 use @ExtensionMethod annotation to add some methods to collections.
I declare an extension method filter() for List<T> but Lombok tries to apply this method to Stream<T> type.
How to reproduce
import java.util.Arrays;
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Stream;
import lombok.experimental.ExtensionMethod;
@ExtensionMethod(Main.ExtensionMethods.class)
public class Main
{
public static class ExtensionMethods
{
public static <T> Stream<T> filter(List<T> list, Predicate<? super T> predicate)
{
return list.stream().filter(predicate);
}
}
public static void main(String[] args)
{
List<Integer> list = Arrays.asList(1, 2, 3);
Stream<Integer> stream = list.filter(i -> true);
Stream<Integer> itWorks = stream.filter(i -> true);
Stream<Integer> itDoesntWork = list.filter(i -> true).filter(i -> true);
}
}
Expected behavior
It should work.
Actual behavior
Lombok returns the following error during a compilation process:
error: method filter in class ExtensionMethods cannot be applied to given types;
required: List<T>,Predicate<? super T>
found: Stream<Integer>,(i)->true
reason: no instance(s) of type variable(s) T exist so that Stream<T> conforms to List<T>
where T is a type-variable:
T extends Object declared in method <T>filter(List<T>,Predicate<? super T>)
1 error
Version info:
Lombok version: I tried two versions – 16.16, 18.18
Platform Gradle, IntelliJ IDEA,
JVM: 1.8.0_252 (Amazon.com Inc. 25.252-b09), 11.0.7 (Amazon.com Inc. 11.0.7+10-LTS)
The text was updated successfully, but these errors were encountered:
Rawi01
added a commit
to Rawi01/lombok
that referenced
this issue
Feb 7, 2021
I use
@ExtensionMethod
annotation to add some methods to collections.I declare an extension method
filter()
forList<T>
but Lombok tries to apply this method toStream<T>
type.How to reproduce
Expected behavior
It should work.
Actual behavior
Lombok returns the following error during a compilation process:
Version info:
16.16
,18.18
1.8.0_252 (Amazon.com Inc. 25.252-b09)
,11.0.7 (Amazon.com Inc. 11.0.7+10-LTS)
The text was updated successfully, but these errors were encountered: