Handling of annotations on delegated property in descriptor loader & stub builder
This commit is contained in:
+11
-2
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.load.kotlin
|
||||
import com.google.protobuf.MessageLite
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.descriptors.SourceElement
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget
|
||||
import org.jetbrains.kotlin.load.java.JvmAbi
|
||||
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
@@ -102,7 +103,14 @@ abstract class AbstractBinaryClassAnnotationAndConstantLoader<A : Any, C : Any,
|
||||
findClassAndLoadMemberAnnotations(container, sig, property = true, field = true)
|
||||
}.orEmpty()
|
||||
|
||||
return loadPropertyAnnotations(propertyAnnotations, fieldAnnotations)
|
||||
// TODO: check delegate presence in some other way
|
||||
return loadPropertyAnnotations(propertyAnnotations, fieldAnnotations,
|
||||
if (fieldSignature?.signature?.contains(JvmAbi.DELEGATED_PROPERTY_NAME_SUFFIX) ?: false) {
|
||||
AnnotationUseSiteTarget.PROPERTY_DELEGATE_FIELD
|
||||
}
|
||||
else {
|
||||
AnnotationUseSiteTarget.FIELD
|
||||
})
|
||||
}
|
||||
|
||||
val signature = getCallableSignature(proto, container.nameResolver, container.typeTable, kind) ?: return emptyList()
|
||||
@@ -117,7 +125,8 @@ abstract class AbstractBinaryClassAnnotationAndConstantLoader<A : Any, C : Any,
|
||||
return findClassAndLoadMemberAnnotations(container, signature)
|
||||
}
|
||||
|
||||
protected abstract fun loadPropertyAnnotations(propertyAnnotations: List<A>, fieldAnnotations: List<A>): List<T>
|
||||
protected abstract fun loadPropertyAnnotations(propertyAnnotations: List<A>, fieldAnnotations: List<A>,
|
||||
fieldUseSiteTarget: AnnotationUseSiteTarget): List<T>
|
||||
|
||||
protected abstract fun transformAnnotations(annotations: List<A>): List<T>
|
||||
|
||||
|
||||
+4
-2
@@ -85,10 +85,12 @@ class BinaryClassAnnotationAndConstantLoaderImpl(
|
||||
|
||||
override fun loadPropertyAnnotations(
|
||||
propertyAnnotations: List<AnnotationDescriptor>,
|
||||
fieldAnnotations: List<AnnotationDescriptor>
|
||||
fieldAnnotations: List<AnnotationDescriptor>,
|
||||
fieldUseSiteTarget: AnnotationUseSiteTarget
|
||||
): List<AnnotationWithTarget> {
|
||||
return propertyAnnotations.map { AnnotationWithTarget(it, null) } +
|
||||
fieldAnnotations.map { AnnotationWithTarget(it, AnnotationUseSiteTarget.FIELD) }
|
||||
fieldAnnotations.map { AnnotationWithTarget(it, fieldUseSiteTarget) }
|
||||
fieldAnnotations.map { AnnotationWithTarget(it, fieldUseSiteTarget) }
|
||||
}
|
||||
|
||||
override fun transformAnnotations(annotations: List<AnnotationDescriptor>): List<AnnotationWithTarget> {
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf
|
||||
|
||||
// The purpose of this class is to hold a unique signature of either a method or a field, so that annotations on a member can be put
|
||||
// into a map indexed by these signatures
|
||||
internal data class MemberSignature private constructor(private val signature: String) {
|
||||
internal data class MemberSignature private constructor(internal val signature: String) {
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun fromMethod(nameResolver: NameResolver, signature: JvmProtoBuf.JvmMethodSignature): MemberSignature {
|
||||
|
||||
Reference in New Issue
Block a user