From b9594988ea08c41f0f55e6bef67f7d7265b463df Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Wed, 4 Jul 2018 18:48:49 +0200 Subject: [PATCH] Do not read property getter/setter signature if it's empty This has no effect on the correct code currently, but will help in debugging when changing the serialized metadata for properties. For example, if after some change an empty propertySignature extension is written for Property (it's possible for PropertyDescriptor without getter or setter and without backing field), we now won't try to read a missing getter message when loading annotations on property getter. In protobuf, reading a missing message will result not in an exception, but in a "default" message being returned, which makes no sense in our case because it would simply be read as a getter signature with both "name" and "desc" equal to 0 (i.e. the first entry in the string table) --- .../AbstractBinaryClassAnnotationAndConstantLoader.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/kotlin/AbstractBinaryClassAnnotationAndConstantLoader.kt b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/kotlin/AbstractBinaryClassAnnotationAndConstantLoader.kt index 2560ce99c61..fd445d350da 100644 --- a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/kotlin/AbstractBinaryClassAnnotationAndConstantLoader.kt +++ b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/kotlin/AbstractBinaryClassAnnotationAndConstantLoader.kt @@ -387,9 +387,12 @@ abstract class AbstractBinaryClassAnnotationAndConstantLoader { val signature = proto.getExtensionOrNull(propertySignature) ?: return null when (kind) { - AnnotatedCallableKind.PROPERTY_GETTER -> MemberSignature.fromMethod(nameResolver, signature.getter) - AnnotatedCallableKind.PROPERTY_SETTER -> MemberSignature.fromMethod(nameResolver, signature.setter) - AnnotatedCallableKind.PROPERTY -> getPropertySignature(proto, nameResolver, typeTable, true, true) + AnnotatedCallableKind.PROPERTY_GETTER -> + if (signature.hasGetter()) MemberSignature.fromMethod(nameResolver, signature.getter) else null + AnnotatedCallableKind.PROPERTY_SETTER -> + if (signature.hasSetter()) MemberSignature.fromMethod(nameResolver, signature.setter) else null + AnnotatedCallableKind.PROPERTY -> + getPropertySignature(proto, nameResolver, typeTable, true, true) else -> null } }