mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-09 08:31:29 +00:00
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.
43 lines
784 B
Kotlin
Vendored
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>;")
|
|
}
|
|
}
|
|
}
|