From 5bfec7f6bc122462e8bf2b8a4ab9e86660d3e92a Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Tue, 23 Jun 2020 16:56:23 +0300 Subject: [PATCH] JVM: don't generate nullability annotations on property delegate fields Such fields are private, so these annotations are redundant. They were incorrect, anyway (property type was used instead of delegate type). --- .../src/org/jetbrains/kotlin/codegen/AnnotationCodegen.java | 4 +++- .../codegen/bytecodeListing/annotations/onProperties.txt | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/AnnotationCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/AnnotationCodegen.java index 2f09b54f99a..05218e42925 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/AnnotationCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/AnnotationCodegen.java @@ -196,7 +196,9 @@ public abstract class AnnotationCodegen { return; } - if (returnType != null && !AsmUtil.isPrimitive(returnType)) { + if (returnType != null && !AsmUtil.isPrimitive(returnType) && + !(descriptor instanceof PropertyDescriptor && ((PropertyDescriptor) descriptor).isDelegated()) + ) { generateNullabilityAnnotation(descriptor.getReturnType(), annotationDescriptorsAlreadyPresent); } } diff --git a/compiler/testData/codegen/bytecodeListing/annotations/onProperties.txt b/compiler/testData/codegen/bytecodeListing/annotations/onProperties.txt index 6c0a8159bad..0b23689f3a7 100644 --- a/compiler/testData/codegen/bytecodeListing/annotations/onProperties.txt +++ b/compiler/testData/codegen/bytecodeListing/annotations/onProperties.txt @@ -2,7 +2,7 @@ public final class A { synthetic final static field $$delegatedProperties: kotlin.reflect.KProperty[] private @AnnField field p: int - private final @AnnDelegate @org.jetbrains.annotations.NotNull field s$delegate: CustomDelegate + private final @AnnDelegate field s$delegate: CustomDelegate private final @AnnField field x: int private field y: int static method (): void