Files
kotlin-fork/js/js.translator/testData/box/inlineMultiFile/anonymousObjectInSimilarFunctions.kt
T
Alexey Andreev feb968e66d JS: fix generation of names for local declarations
Local declarations obtain names prefixed with outer function's name.
Only simple name (i.e. without mangling) of outer function used
in this case. This raises a problem in case of inline functions
with object literals. Currently, they are not copied, but exported
from module. Consider two inline functions foo with different
signatures, both declare object literals. In this case both literals
are exported as foo$f, so only one will be accessible from outside.
2017-04-24 18:39:04 +03:00

25 lines
459 B
Kotlin
Vendored

// FILE: a.kt
inline fun foo(x: String): I = object : I {
override fun get(): String = "foo_String($x)"
}
// FILE: b.kt
inline fun foo(x: Int): I = object : I {
override fun get(): String = "foo_Int($x)"
}
// FILE: main.kt
interface I {
fun get(): String
}
fun box(): String {
val a = foo("1").get()
if (a != "foo_String(1)") return "fail1: $a"
val b = foo(2).get()
if (b != "foo_Int(2)") return "fail2: $b"
return "OK"
}