I have the below test class in my java code:
Function<? super Either<? extends Object, ? extends Object>, ? super Either<? extends Object, ? extends Object>> test = new Function<Either<Integer, Integer>, Either<Integer, Integer>>() {
@Override
public Either<Integer, Integer> apply(Either<Integer, Integer> integers) {
return integers;
}
}
Documentation for Either can be found here: http://static.javadoc.io/io.javaslang/javaslang/2.0.2/javaslang/control/Either.html.
But I get the following compile error (Java 8)
Error:(77, 129) java: incompatible types:
<anonymous java.util.function.Function<javaslang.control.Either<java.lang.Integer,java.lang.Integer>,javaslang.control.Either<java.lang.Integer,java.lang.Integer>>>
cannot be converted to
java.util.function.Function<? super javaslang.control.Either<? extends java.lang.Object,? extends java.lang.Object>,? super javaslang.control.Either<? extends java.lang.Object,? extends java.lang.Object>>
I am new to Java and am not sure what is wrong here. Any help is much appreciated.
I understand this code does not make sense and that is not how I am using it really. I am actually trying to pass a Function to an internal library. But I should not be getting that compile error where Either cannot be converted to ? super Either
Thanks!!