// WITH_STDLIB fun foo(a: Result?): T? = bar(a) { it?.getOrThrow() } fun interface FunIFace { fun call(ic: T): R } fun bar(value: T, f: FunIFace): R { return f.call(value) } fun box(): String { var res = foo(Result.success(40))?.plus(2) if (res != 42) return "FAIL $res" res = foo(null) if (res != null) return "FAIL $res" return "OK" }