Files
kotlin/compiler/testData/codegen/box/reflection/methodsFromAny/fakeOverrideToString.kt
Alexander Udalov c357967c2c JVM IR: generate Kotlin metadata
Introduce MetadataSource as a way to store the original descriptor for
any element (before any lowerings) and maintain it until the end of the
codegen where it's used in generating the metadata. Note that JVM
signatures written to the metadata are formed from the _resulting_
generated elements, not by mapping the original descriptors.

Some corner cases are not supported yet, namely properties declared in
companion objects, synthetic methods for property annotations,
JvmPackageName, etc.

 #KT-29119 Fixed
2019-02-19 16:37:47 +01:00

29 lines
876 B
Kotlin
Vendored

// IGNORE_BACKEND: JS_IR, JS, NATIVE
// WITH_REFLECT
package test
import kotlin.test.assertEquals
open class A<T> {
fun foo(t: T) {}
}
open class B<U> : A<U>()
class C : B<String>()
fun box(): String {
assertEquals("fun test.A<T>.foo(T): kotlin.Unit", A<Double>::foo.toString())
assertEquals("fun test.B<U>.foo(U): kotlin.Unit", B<Float>::foo.toString())
assertEquals("fun test.C.foo(kotlin.String): kotlin.Unit", C::foo.toString())
val afoo = A::class.members.single { it.name == "foo" }
assertEquals("fun test.A<T>.foo(T): kotlin.Unit", afoo.toString())
val bfoo = B::class.members.single { it.name == "foo" }
assertEquals("fun test.B<U>.foo(U): kotlin.Unit", bfoo.toString())
val cfoo = C::class.members.single { it.name == "foo" }
assertEquals("fun test.C.foo(kotlin.String): kotlin.Unit", cfoo.toString())
return "OK"
}