Minor. Add tests to check returning Result from functions

Mainly, that virtual functions, returning Result, are mangled.
 #KT-45855
This commit is contained in:
Ilmir Usmanov
2021-04-09 19:11:12 +02:00
committed by TeamCityServer
parent 613eda5016
commit bce92d824a
28 changed files with 617 additions and 0 deletions
@@ -0,0 +1,8 @@
// WITH_RUNTIME
// KJS_WITH_FULL_RUNTIME
class C {
fun foo(): Result<String> = Result.success("OK")
}
fun box() = C().foo().getOrThrow()
@@ -0,0 +1,16 @@
// WITH_RUNTIME
// KJS_WITH_FULL_RUNTIME
interface I {
fun foo(): Any
}
class C : I {
override fun foo(): Result<String> = Result.success("OK")
}
fun box(): String {
if (((C() as I).foo() as Result<String>).getOrThrow() != "OK") return "FAIL 1"
return C().foo().getOrThrow()
}
@@ -0,0 +1,15 @@
// WITH_RUNTIME
// KJS_WITH_FULL_RUNTIME
interface I<T> {
fun foo(): T
}
class C : I<Result<String>> {
override fun foo(): Result<String> = Result.success("OK")
}
fun box(): String {
if (((C() as I<Result<String>>).foo() as Result<String>).getOrThrow() != "OK") return "FAIL 1"
return C().foo().getOrThrow()
}
@@ -0,0 +1,16 @@
// WITH_RUNTIME
// KJS_WITH_FULL_RUNTIME
interface I {
fun foo(): Result<String>
}
class C : I {
override fun foo(): Result<String> = Result.success("OK")
}
fun box(): String {
if ((C() as I).foo().getOrThrow() != "OK") return "FAIL 1"
return C().foo().getOrThrow()
}
@@ -0,0 +1,10 @@
// WITH_RUNTIME
// KJS_WITH_FULL_RUNTIME
interface I {
fun foo(): Result<String>
}
fun box() = object : I {
override fun foo() = Result.success("OK")
}.foo().getOrThrow()
@@ -0,0 +1,6 @@
// WITH_RUNTIME
// KJS_WITH_FULL_RUNTIME
fun foo(): Result<String> = Result.success("OK")
fun box() = foo().getOrThrow()