Don't know if it's me doing something wrong, but I got an
Either
and I want to do
isLeft()
on it and I expect then inside the lambda that the variable would be smart-cast to the left type, but it's just not doing so for me.
Jumping to the definition of the
isLeft()
it takes me to this:
@Deprecated(
RedundantAPI + "Use isLeft()",
ReplaceWith("isLeft()")
)
@JsName("_isLeft")
internal abstract val isLeft: Boolean
With the
public fun isLeft(): Boolean {
contract {
returns(true) implies (this@Either is Left<A>)
returns(false) implies (this@Either is Right<B>)
}
return this@Either is Left<A>
}
Being right there below it, very pretty, non deprecated and with the contract along with it. But it looks like it auto-picks the wrong one and I don't get any of those goodies 😰
Is this a known problem, or is there a way for me to somehow force it to use the function instead of the abstract val which it automatically picks somehow?