Files
kotlin-fork/compiler/testData/codegen/box/fir/StackOverflowInAnnotationLoader.kt
T
Mikhail Glukhikh 19a95f2fb4 K2: swap heuristics in AnnotationLoader (related to KT-62598)
Before this commit, we first tried to guess a type of array literal
in deserialized annotation (it's a strange heuristics which can
lead to SOE and maybe not needed at all, see KT-62598, KT-62929),
and then, if unsuccessful, took the type from the first literal element,
if any. Since the second heuristic is much more clear, safe, and
understandable, in this commit they were swapped.

This commit does not fix KT-62598 in general case,
but decreases a set of cases when it can occur to
empty array literals only.
See the commented line at the end of the added test.
2023-10-31 12:30:29 +00:00

59 lines
952 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
// This line still provokes SOE in K2
//import HolderWithEmpty
fun box() = "OK"