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()
@@ -0,0 +1,6 @@
// WITH_RUNTIME
class C {
fun foo(): Result<Boolean> = TODO()
}
@@ -0,0 +1,6 @@
@kotlin.Metadata
public final class C {
// source: 'class.kt'
public method <init>(): void
public final @org.jetbrains.annotations.NotNull method foo-d1pmJ48(): java.lang.Object
}
@@ -0,0 +1,10 @@
// WITH_RUNTIME
interface I {
fun foo(): Any
}
class C : I {
override fun foo(): Result<Boolean> = TODO()
}
@@ -0,0 +1,13 @@
@kotlin.Metadata
public final class C {
// source: 'classAnyOverride.kt'
public method <init>(): void
public synthetic bridge method foo(): java.lang.Object
public @org.jetbrains.annotations.NotNull method foo-d1pmJ48(): java.lang.Object
}
@kotlin.Metadata
public interface I {
// source: 'classAnyOverride.kt'
public abstract @org.jetbrains.annotations.NotNull method foo(): java.lang.Object
}
@@ -0,0 +1,10 @@
// WITH_RUNTIME
interface I<T> {
fun foo(): T = TODO()
}
class C : I<Result<Boolean>> {
override fun foo(): Result<Boolean> = TODO()
}
@@ -0,0 +1,21 @@
@kotlin.Metadata
public final class C {
// source: 'classGenericOverride.kt'
public method <init>(): void
public synthetic bridge method foo(): java.lang.Object
public @org.jetbrains.annotations.NotNull method foo-d1pmJ48(): java.lang.Object
}
@kotlin.Metadata
public final class I$DefaultImpls {
// source: 'classGenericOverride.kt'
public static method foo(@org.jetbrains.annotations.NotNull p0: I): java.lang.Object
public final inner class I$DefaultImpls
}
@kotlin.Metadata
public interface I {
// source: 'classGenericOverride.kt'
public abstract method foo(): java.lang.Object
public final inner class I$DefaultImpls
}
@@ -0,0 +1,10 @@
// WITH_RUNTIME
interface I {
fun foo(): Result<Boolean>
}
class C : I {
override fun foo(): Result<Boolean> = TODO()
}
@@ -0,0 +1,12 @@
@kotlin.Metadata
public final class C {
// source: 'classResultOverride.kt'
public method <init>(): void
public @org.jetbrains.annotations.NotNull method foo-d1pmJ48(): java.lang.Object
}
@kotlin.Metadata
public interface I {
// source: 'classResultOverride.kt'
public abstract @org.jetbrains.annotations.NotNull method foo-d1pmJ48(): java.lang.Object
}
@@ -0,0 +1,6 @@
// WITH_RUNTIME
interface I {
fun foo(): Result<Boolean>
}
@@ -0,0 +1,5 @@
@kotlin.Metadata
public interface I {
// source: 'interface.kt'
public abstract @org.jetbrains.annotations.NotNull method foo-d1pmJ48(): java.lang.Object
}
@@ -0,0 +1,3 @@
// WITH_RUNTIME
fun foo(): Result<Boolean> = TODO()
@@ -0,0 +1,5 @@
@kotlin.Metadata
public final class TopLevelKt {
// source: 'topLevel.kt'
public final static @org.jetbrains.annotations.NotNull method foo(): java.lang.Object
}