Files
kotlin/compiler/testData/codegen/box/constructorCall/inlineFunInLocalClassConstructorCall.kt
Juan Chen 9dd8eda1c9 [FIR]: fix library methods in packages
Library methods such as 'listOf' are resolved
to have the package fragments as their parents,
but JVM expects their containing file classes as parents.
This fix generates those file classes and
uses them as parent replacements for such library methods.
2020-02-20 14:24:02 +03:00

43 lines
784 B
Kotlin
Vendored

// !LANGUAGE: -NormalizeConstructorCalls
// TARGET_BACKEND: JVM
// WITH_RUNTIME
// FILE: test.kt
fun box(): String {
class Local(val i: Int, val j: Int) : Foo() {
init {
log.append("Local.<init>;")
}
}
Local(
logged("i;", 1.let { it }),
logged("j;", 2.let { it })
)
val result = log.toString()
if (result != "Foo.<clinit>;i;j;Foo.<init>;Local.<init>;") return "Fail: '$result'"
return "OK"
}
// FILE: util.kt
val log = StringBuilder()
fun <T> logged(msg: String, value: T): T {
log.append(msg)
return value
}
// FILE: Foo.kt
open class Foo {
init {
log.append("Foo.<init>;")
}
companion object {
init {
log.append("Foo.<clinit>;")
}
}
}