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.
42 lines
858 B
Kotlin
Vendored
42 lines
858 B
Kotlin
Vendored
// TARGET_BACKEND: JVM
|
|
// WITH_RUNTIME
|
|
// KOTLIN_CONFIGURATION_FLAGS: CONSTRUCTOR_CALL_NORMALIZATION_MODE=enable
|
|
// FILE: test.kt
|
|
fun box(): String {
|
|
Foo(
|
|
logged("i", listOf(1, 2, 3).map { it + 1 }.first()),
|
|
logged("j",
|
|
Foo(
|
|
logged("k", listOf(1, 2, 3).map { it + 1 }.first()),
|
|
null
|
|
)
|
|
)
|
|
)
|
|
|
|
val result = log.toString()
|
|
if (result != "ik<clinit><init>j<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
|
|
class Foo(i: Int, j: Foo?) {
|
|
init {
|
|
log.append("<init>")
|
|
}
|
|
|
|
companion object {
|
|
init {
|
|
log.append("<clinit>")
|
|
}
|
|
}
|
|
}
|