andylamax
12/30/2022, 6:58 AMFunction1<? super T, ? extends R> is not a functional interface
when passing a lambda argument that is written in common main. Any one else getting this? What version of IDEA are you all using? More on threadandylamax
12/30/2022, 7:00 AMcommonMain/Box.kt
class Box<out T>(val value: T) {
fun <R> map(func: (T) -> R): Box<R> = Box(func(value))
fun <R> flatMap(func: (T) -> Box<R>) = func(value)
}
jvmMain/Bag.kt
class Bag<out T>(val value: T) {
fun <R> map(func: (T) -> R): Bag<R> = Bag(func(value))
fun <R> flatMap(func: (T) -> Bag<R>): Bag<R> = func(value)
}
jvmTest/java
(new Bag(4)).map(it -> "String").flatMap(str -> new Bag(5)); // passes with no problems at all
(new Box(1)).map(it -> "String").flatMap(str -> new Box(4)); // Function1<? super T, ? extends R> is not a functional interface
Alexey Belkov [JB]
01/10/2023, 7:54 AM