Scott Christopher
10/20/2020, 5:03 AMeither.eager {...}
seems to need explicit type arguments, while either {...}
does not.
e.g.
fun fn(): Either<Throwable, Boolean> = TODO()
suspend fun example() {
either.eager<Throwable, Boolean> {
val a = !fn()
val b = !fn()
a && b
}
either {
val a = !fn()
val b = !fn()
a && b
}
}
Scott Christopher
10/20/2020, 5:03 AME
kioba
10/21/2020, 9:58 AMeither
and either.eager
with KOTLIN_VERSION=1.4.10
I would assume this is a problem with type inference but didn’t tested on previous versions of Kotlin yet.
Also what you found is not just that but the error highlighting does not indicate missing type with invoke
functions with lambdas but neither of the scopes were able to infer the E
value for me.
The test above shows that IDEA indicates missing type inference with lamda syntaxt but calling explicitly invoke does show an error.kioba
10/21/2020, 10:00 AMScott Christopher
10/21/2020, 10:23 AMkioba
10/21/2020, 10:25 AMkioba
10/21/2020, 10:27 AM