Hello everyone!
I have a class structure like this
interface A {
fun foo1(callback: (a: Int)-> Unit)
}
class AImpl : A {
override fun foo1(callback: (a: Int)-> Unit) { return }
fun foo2(callback: (a: Int)-> Unit) { return }
}
class ADelegate(a : A) : A by a
class B {
val a = ADelegate(AImpl())
fun b1() {
a.foo1 {
a.runCatching { }.onFailure { return@foo1 }
}
}
fun b2() {
(a as AImpl).foo2 {
a.runCatching { }.onFailure { return@foo2 }
}
}
}
And I want to be able to call foo2, however even though IDEA can infer that this
inside the foo2 :: runCatching
is ADelegate & AImpl
when compiling it says that return is not allowed inside onFailure
.
For foo1
there is no problem though.
Can anyone give me an insight about the problem?