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.
This commit is contained in:
committed by
Space Team
parent
4720a0faa7
commit
19a95f2fb4
@@ -0,0 +1,58 @@
|
||||
// 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"
|
||||
Reference in New Issue
Block a user