Files
kotlin-fork/compiler/testData/codegen/box/fir/StackOverflowInAnnotationLoader.kt
T
Mikhail Glukhikh 290adda8fc Calculate empty array literal types in FIR2IR instead of deserializer
This commit handles situations when some annotation in deserialized code
has an empty array literal argument [] or even non-empty [something].
Before this commit, we tried to guess a type of this array by "resolving"
the relevant annotation class and looking into the corresponding
parameter. Sometimes it can work, but also it can provoke recursive
resolve e.g. when the annotation class is a nested class in the same scope.
In this commit we changed the behavior in the following way:
- first, for non-empty array literals in deserialized code we just
take the array type from the corresponding array literal element
- second, for empty array literals we no more try to "guess" anything.
Instead we approximate array type as Array<Any>, and later at FIR2IR
stage we use the corresponding parameter type instead. At FIR2IR stage,
everything is already resolved and problems with recursions are no more
possible.

#KT-62598 Fixed
2023-10-31 12:30:29 +00:00

58 lines
912 B
Kotlin
Vendored

// TARGET_BACKEND: JVM_IR
// ISSUE: KT-62598
// MODULE: m1
// FILE: m1.kt
interface Holder {
interface Entry {
@Annotation(value = [""])
fun f()
}
annotation class Annotation(
val value: Array<String>,
)
}
interface ByteHolder {
interface Entry {
@Annotation(value = [1])
fun f()
}
annotation class Annotation(
val value: ByteArray,
)
}
interface HolderWithDefault {
interface Entry {
@Annotation
fun f()
}
annotation class Annotation(
val value: Array<String> = [""],
)
}
interface HolderWithEmpty {
interface Entry {
@Annotation(value = [])
fun f()
}
annotation class Annotation(
val value: Array<String>,
)
}
// MODULE: m2(m1)
// FILE: m2.kt
import Holder
import ByteHolder
import HolderWithDefault
import HolderWithEmpty
fun box() = "OK"