Load annotations of const properties from multifile classes

Rework backing field generation logic in PropertyCodegen to switch the
ClassBuilder instance for a multifile part to that of the corresponding facade
class. This became needed because multifile parts, and their metadata, are
generated _before_ the multifile facade class and otherwise we would never
record that there's a synthetic '$annotations' method for a const val and would
not write that to the protobuf message for the property.

See also bad83200

 #KT-10892 Fixed
This commit is contained in:
Alexander Udalov
2016-03-23 18:55:40 +03:00
parent 6924d883eb
commit a8bebeb48d
14 changed files with 150 additions and 61 deletions
@@ -1,4 +1,4 @@
// WITH_RUNTIME
// WITH_REFLECT
// FILE: 1.kt
import a.OK
@@ -6,12 +6,10 @@ import a.OK
fun box(): String {
val okRef = ::OK
// TODO: see KT-10892
// val annotations = okRef.annotations
// val numAnnotations = annotations.size
// if (numAnnotations != 1) {
// return "Failed, annotations: $annotations"
// }
val annotations = okRef.annotations
if (annotations.size != 1) {
return "Failed, annotations: $annotations"
}
return okRef.get()
}
@@ -0,0 +1,8 @@
@file:JvmMultifileClass
@file:JvmName("Test")
package test
annotation class Anno(val value: String)
@Anno(constant)
const val constant = "OK"
@@ -0,0 +1,10 @@
package test
@test.Anno(value = "OK") public const val constant: kotlin.String = "OK"
public fun <get-constant>(): kotlin.String
public final annotation class Anno : kotlin.Annotation {
/*primary*/ public constructor Anno(/*0*/ value: kotlin.String)
public final val value: kotlin.String
public final fun <get-value>(): kotlin.String
}