Minor. Add tests with returning inline class from SAM adapter
This commit is contained in:
+24
@@ -0,0 +1,24 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_RUNTIME
|
||||
// FULL_RUNTIME
|
||||
|
||||
// FILE: ResultHandler.java
|
||||
|
||||
import kotlin.Result;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface ResultHandler<T> {
|
||||
Result<T> onResult();
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
@Suppress("RESULT_CLASS_IN_RETURN_TYPE")
|
||||
fun doSmth(resultHandler: ResultHandler<Boolean>): Result<Boolean> {
|
||||
return resultHandler.onResult()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val res = doSmth { Result.success(true) }
|
||||
return if (res.isSuccess) "OK" else "FAIL"
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// WITH_RUNTIME
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// IGNORE_BACKEND: WASM
|
||||
// IGNORE_BACKEND: JVM
|
||||
|
||||
inline class Result<T>(val isSuccess: Boolean)
|
||||
|
||||
fun interface ResultHandler<T> {
|
||||
fun onResult(): Result<T>
|
||||
}
|
||||
|
||||
fun doSmth(resultHandler: ResultHandler<Boolean>): Result<Boolean> {
|
||||
return resultHandler.onResult()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var res = doSmth { Result(true) }
|
||||
return if (res.isSuccess) "OK" else "FAIL"
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// WITH_RUNTIME
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// IGNORE_BACKEND: JVM
|
||||
// IGNORE_BACKEND: WASM
|
||||
|
||||
fun interface ResultHandler<T> {
|
||||
@Suppress("RESULT_CLASS_IN_RETURN_TYPE")
|
||||
fun onResult(): Result<T>
|
||||
}
|
||||
|
||||
@Suppress("RESULT_CLASS_IN_RETURN_TYPE")
|
||||
fun doSmth(resultHandler: ResultHandler<Boolean>): Result<Boolean> {
|
||||
return resultHandler.onResult()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var res = doSmth { Result.success(true) }
|
||||
return if (res.isSuccess) "OK" else "FAIL 1"
|
||||
}
|
||||
Reference in New Issue
Block a user