Let's say I have a class FooError that implements a bunch of different interfaces. I can't write a generic that uses FooError as a lower bound somehow, can I? Like I'd love to be able to do
Copy code
inline fun <R> runFOrReturnFooError(f: () -> R): R =
if (someCondition) {
f()
} else {
FooError()
}
such that R is allowed to be any of the interfaces that FooError implements
r
Raphael TEYSSANDIER
05/15/2023, 11:40 PM
Does
inline fun <R : FooError> runFOrReturnFooError(f: () -> R): R