Fix incorrect copy-paste during proto messages refactoring
Annotations on properties should be loaded not when the message is Property (this happens for getters/setters as well), but when the kind is explicitly set to PROPERTY. Also restore construction of JVM signatures for constructors
This commit is contained in:
+19
-18
@@ -84,28 +84,26 @@ public abstract class AbstractBinaryClassAnnotationAndConstantLoader<A : Any, C
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun loadCallableAnnotations(container: ProtoContainer, proto: MessageLite, kind: AnnotatedCallableKind): List<T> {
|
override fun loadCallableAnnotations(container: ProtoContainer, proto: MessageLite, kind: AnnotatedCallableKind): List<T> {
|
||||||
return when (proto) {
|
if (kind == AnnotatedCallableKind.PROPERTY) {
|
||||||
is ProtoBuf.Constructor, is ProtoBuf.Function -> {
|
proto as ProtoBuf.Property
|
||||||
val signature = getCallableSignature(proto, container.nameResolver, kind) ?: return emptyList()
|
|
||||||
transformAnnotations(findClassAndLoadMemberAnnotations(container, proto, signature))
|
|
||||||
}
|
|
||||||
is ProtoBuf.Property -> {
|
|
||||||
val nameResolver = container.nameResolver
|
|
||||||
val syntheticFunctionSignature = getPropertySignature(proto, nameResolver, synthetic = true)
|
|
||||||
val fieldSignature = getPropertySignature(proto, nameResolver, field = true)
|
|
||||||
|
|
||||||
val propertyAnnotations = syntheticFunctionSignature?.let { sig ->
|
val nameResolver = container.nameResolver
|
||||||
findClassAndLoadMemberAnnotations(container, proto, sig)
|
val syntheticFunctionSignature = getPropertySignature(proto, nameResolver, synthetic = true)
|
||||||
} ?: listOf()
|
val fieldSignature = getPropertySignature(proto, nameResolver, field = true)
|
||||||
|
|
||||||
val fieldAnnotations = fieldSignature?.let { sig ->
|
val propertyAnnotations = syntheticFunctionSignature?.let { sig ->
|
||||||
findClassAndLoadMemberAnnotations(container, proto, sig, isStaticFieldInOuter(proto))
|
findClassAndLoadMemberAnnotations(container, proto, sig)
|
||||||
} ?: listOf()
|
}.orEmpty()
|
||||||
|
|
||||||
loadPropertyAnnotations(propertyAnnotations, fieldAnnotations)
|
val fieldAnnotations = fieldSignature?.let { sig ->
|
||||||
}
|
findClassAndLoadMemberAnnotations(container, proto, sig, isStaticFieldInOuter(proto))
|
||||||
else -> emptyList()
|
}.orEmpty()
|
||||||
|
|
||||||
|
return loadPropertyAnnotations(propertyAnnotations, fieldAnnotations)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val signature = getCallableSignature(proto, container.nameResolver, kind) ?: return emptyList()
|
||||||
|
return transformAnnotations(findClassAndLoadMemberAnnotations(container, proto, signature))
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract fun loadPropertyAnnotations(propertyAnnotations: List<A>, fieldAnnotations: List<A>): List<T>
|
protected abstract fun loadPropertyAnnotations(propertyAnnotations: List<A>, fieldAnnotations: List<A>): List<T>
|
||||||
@@ -299,6 +297,9 @@ public abstract class AbstractBinaryClassAnnotationAndConstantLoader<A : Any, C
|
|||||||
|
|
||||||
private fun getCallableSignature(proto: MessageLite, nameResolver: NameResolver, kind: AnnotatedCallableKind): MemberSignature? {
|
private fun getCallableSignature(proto: MessageLite, nameResolver: NameResolver, kind: AnnotatedCallableKind): MemberSignature? {
|
||||||
return when {
|
return when {
|
||||||
|
proto is ProtoBuf.Constructor && proto.hasExtension(constructorSignature) -> {
|
||||||
|
MemberSignature.fromMethod(nameResolver, proto.getExtension(constructorSignature))
|
||||||
|
}
|
||||||
proto is ProtoBuf.Function && proto.hasExtension(methodSignature) -> {
|
proto is ProtoBuf.Function && proto.hasExtension(methodSignature) -> {
|
||||||
MemberSignature.fromMethod(nameResolver, proto.getExtension(methodSignature))
|
MemberSignature.fromMethod(nameResolver, proto.getExtension(methodSignature))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user