[K2] Use file name as one of parameters to extract evaluated const

It is not enough to store evaluated constants only by
<startOffset, endOffset> pair. We need to consider case there constant
can be located in different files with the same offset but with
different values.

#KT-57928 Fixed
#KT-57929 Fixed
This commit is contained in:
Ivan Kylchik
2023-04-11 12:56:59 +02:00
committed by Space Team
parent 8cc8e54a9f
commit c00c7ffbe0
13 changed files with 123 additions and 100 deletions
@@ -4,8 +4,7 @@ annotation class Key(val value: String)
object Messanger {
const val DEFAULT_TEXT = <!EVALUATED("OK")!>"OK"<!>
// Note: second `EVALUATED` from `message$default`
fun message(@Key(value = <!EVALUATED("OK"), EVALUATED("OK")!>DEFAULT_TEXT<!>) text: String = <!EVALUATED("OK")!>DEFAULT_TEXT<!>): String {
fun message(@Key(value = <!EVALUATED("OK")!>DEFAULT_TEXT<!>) text: String = <!EVALUATED("OK")!>DEFAULT_TEXT<!>): String {
return text
}
}
@@ -50,17 +50,16 @@ enum class SomeEnum {
B;
}
// TODO: can be uncommented after fix KT-57135
//@field:BinaryAnnotation("Str" + "ing")
//var x: Int = 5
@field:BinaryAnnotation("Str" <!EVALUATED("String")!>+ "ing"<!>)
var x: Int = 5
//object Delegate {
// operator fun getValue(instance: Any?, property: Any) : String = ""
// operator fun setValue(instance: Any?, property: Any, value: String) {}
//}
//
//@delegate:BinaryAnnotation("Str" + "ing")
//val p: String by Delegate
object Delegate {
operator fun getValue(instance: Any?, property: Any) : String = ""
operator fun setValue(instance: Any?, property: Any, value: String) {}
}
@delegate:BinaryAnnotation("Str" <!EVALUATED("String")!>+ "ing"<!>)
val p: String by Delegate
// 7. VALUE_PARAMETER
@@ -70,6 +69,19 @@ fun foo(@BinaryAnnotation("Str" <!EVALUATED("String")!>+ "ing"<!>) a: Int) { }
val @receiver:BinaryAnnotation("Str" <!EVALUATED("String")!>+ "ing"<!>) String.a: Int
get() = 0
class WithConstructorArgumentAnnotation(
@BinaryAnnotation("Str" <!EVALUATED("String")!>+ "ing"<!>)
val a: Int
)
@setparam:BinaryAnnotation("Str" <!EVALUATED("String")!>+ "ing"<!>)
var setParamProp: Int = 0
get() = field + 1
set(x: Int) { field = x * 2 }
var mutablePropWithAnnotationOnSetterParam = 0
set(@BinaryAnnotation("Str" <!EVALUATED("String")!>+ "ing"<!>) x: Int) { field = x * 2 }
// 9. FUNCTION
@BinaryAnnotation("Str" <!EVALUATED("String")!>+ "ing"<!>)
fun bar() {}
@@ -7,7 +7,7 @@
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.BINARY)
annotation class AnnotationWithDefault(val str: String = "Str" + "ing")
annotation class AnnotationWithDefault(val str: String = "Str" <!EVALUATED("String")!>+ "ing"<!>)
@AnnotationWithDefault()
class A