Add regression tests for KT-46890 and other stuff

This commit is contained in:
pyos
2021-06-02 15:30:13 +02:00
committed by teamcityserver
parent ada4c48eba
commit d5d3d9f112
15 changed files with 428 additions and 4 deletions
@@ -0,0 +1,11 @@
// WITH_RUNTIME
// IGNORE_BACKEND: JVM, WASM
interface I<T> {
fun foo(x: T): T
}
class C : I<Result<Any?>> {
override fun foo(x: Result<Any?>) = x
}
fun box() = C().foo(Result.success("OK")).getOrNull()
@@ -0,0 +1,13 @@
// WITH_RUNTIME
// IGNORE_BACKEND: JVM, WASM
interface I<T> {
fun foo(x: T): Any?
}
class C : I<Result<Any?>> {
override fun foo(x: Result<Any?>) = x.getOrNullNoinline()
}
fun <T> Result<T>.getOrNullNoinline() = getOrNull()
fun box() = C().foo(Result.success("OK"))
@@ -0,0 +1,19 @@
// WITH_RUNTIME
// IGNORE_BACKEND: JVM
interface C<T> {
abstract fun foo(x: T): String
}
open class D<T> : C<Result<T>> {
open override fun foo(x: Result<T>): String = "???"
}
class E : D<String>() {
override fun foo(x: Result<String>): String = x.get()
}
fun <T> Result<T>.get(): T = getOrNull()!!
fun <T> C<Result<T>>.bar(x: T) = foo(Result.success(x))
fun box() = E().bar("OK")
@@ -0,0 +1,14 @@
// WITH_RUNTIME
fun <T> Result<T>.get(): T = getOrNull()!!
interface C<T> {
abstract fun Result<T>.foo(): String
}
class D : C<String> {
override fun Result<String>.foo() = get()
}
fun <T> C<T>.bar(x: T) = Result.success(x).foo()
fun box() = D().bar("OK")
@@ -0,0 +1,11 @@
// WITH_RUNTIME
// IGNORE_BACKEND: WASM
interface I<T, V> {
fun foo(x: T): V
}
class C : I<Result<Any?>, Any?> {
override fun foo(x: Result<Any?>) = x.getOrNull()
}
fun box() = (C() as I<Result<Any?>, Any?>).foo(Result.success("OK"))
@@ -0,0 +1,7 @@
// WITH_RUNTIME
// IGNORE_BACKEND: WASM
fun <T> Result<T>.getOrNullNoinline() = getOrNull()
val x = { a: Int, b: Result<String> -> b.getOrNullNoinline() }
fun box() = x(1, Result.success("OK"))