Merge use-site targeted annotations into corresponding Annotations
Add PropertyDescriptor.backingField/delegateField to store annotations on the field directly in an otherwise almost empty descriptor instance, instead of storing them with use-sites in the corresponding property descriptor. Instead of AnnotationWithTarget, create AnnotationDescriptor instances in AnnotationSplitter. Change DescriptorRenderer to render annotations on "related" declarations when needed, with the explicit use-site target if applicable. Most changes in diagnostic test data are related to the fact that annotations which are known to have an incompatible use-site to the declaration they're applied at (such as `@param:`-annotation on a function), are now not loaded at all. It's fine because the code is erroneous, so it doesn't really matter how do we load annotations with invalid targets (some of this logic is also changed freely in subsequent commits). Some changes are also explained by the fact that for example an annotation on the property which is only applicable to FIELD is now rendered with an explicit use-site target `@field:`, regardless of whether it did have that use-site target syntactically or not. Basically, after this change there's no point in calling Annotations.getUseSiteTargetedAnnotations/getAllAnnotations anymore because it's easier and more intuitive to just use Annotations of the corresponding descriptor -- the backing / delegate field (introduced in this commit) or the extension receiver / setter parameter (related behavior was fixed in previous commits). Usages of use-site-target-related methods will be refactored out in subsequent commits
This commit is contained in:
@@ -19,7 +19,6 @@ package org.jetbrains.kotlin.codegen;
|
||||
import kotlin.collections.CollectionsKt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.codegen.annotation.WrappedAnnotated;
|
||||
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper;
|
||||
import org.jetbrains.kotlin.config.JvmTarget;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
@@ -156,36 +155,47 @@ public abstract class AnnotationCodegen {
|
||||
@Nullable Type returnType,
|
||||
@NotNull Set<String> annotationDescriptorsAlreadyPresent
|
||||
) {
|
||||
Annotated unwrapped = annotated;
|
||||
if (annotated instanceof WrappedAnnotated) {
|
||||
unwrapped = ((WrappedAnnotated) annotated).getOriginalAnnotated();
|
||||
if (annotated instanceof CallableDescriptor) {
|
||||
generateAdditionalCallableAnnotations((CallableDescriptor) annotated, returnType, annotationDescriptorsAlreadyPresent);
|
||||
}
|
||||
else if (annotated instanceof FieldDescriptor) {
|
||||
generateAdditionalCallableAnnotations(
|
||||
((FieldDescriptor) annotated).getCorrespondingProperty(), returnType, annotationDescriptorsAlreadyPresent
|
||||
);
|
||||
}
|
||||
else if (annotated instanceof ClassDescriptor) {
|
||||
generateAdditionalClassAnnotations(annotationDescriptorsAlreadyPresent, (ClassDescriptor) annotated);
|
||||
}
|
||||
}
|
||||
|
||||
private void generateAdditionalCallableAnnotations(
|
||||
@NotNull CallableDescriptor descriptor,
|
||||
@Nullable Type returnType,
|
||||
@NotNull Set<String> annotationDescriptorsAlreadyPresent
|
||||
) {
|
||||
// No need to annotate privates, synthetic accessors and their parameters
|
||||
if (isInvisibleFromTheOutside(descriptor)) return;
|
||||
if (descriptor instanceof ValueParameterDescriptor && isInvisibleFromTheOutside(descriptor.getContainingDeclaration())) return;
|
||||
|
||||
// No need to annotate annotation methods since they're always non-null
|
||||
if (descriptor instanceof PropertyGetterDescriptor &&
|
||||
DescriptorUtils.isAnnotationClass(descriptor.getContainingDeclaration())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (unwrapped instanceof CallableDescriptor) {
|
||||
CallableDescriptor descriptor = (CallableDescriptor) unwrapped;
|
||||
|
||||
// No need to annotate privates, synthetic accessors and their parameters
|
||||
if (isInvisibleFromTheOutside(descriptor)) return;
|
||||
if (descriptor instanceof ValueParameterDescriptor && isInvisibleFromTheOutside(descriptor.getContainingDeclaration())) return;
|
||||
|
||||
// No need to annotate annotation methods since they're always non-null
|
||||
if (descriptor instanceof PropertyGetterDescriptor &&
|
||||
DescriptorUtils.isAnnotationClass(descriptor.getContainingDeclaration())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (returnType != null && !AsmUtil.isPrimitive(returnType)) {
|
||||
generateNullabilityAnnotation(descriptor.getReturnType(), annotationDescriptorsAlreadyPresent);
|
||||
}
|
||||
if (returnType != null && !AsmUtil.isPrimitive(returnType)) {
|
||||
generateNullabilityAnnotation(descriptor.getReturnType(), annotationDescriptorsAlreadyPresent);
|
||||
}
|
||||
}
|
||||
|
||||
if (unwrapped instanceof ClassDescriptor) {
|
||||
ClassDescriptor classDescriptor = (ClassDescriptor) unwrapped;
|
||||
if (classDescriptor.getKind() == ClassKind.ANNOTATION_CLASS) {
|
||||
generateDocumentedAnnotation(classDescriptor, annotationDescriptorsAlreadyPresent);
|
||||
generateRetentionAnnotation(classDescriptor, annotationDescriptorsAlreadyPresent);
|
||||
generateTargetAnnotation(classDescriptor, annotationDescriptorsAlreadyPresent);
|
||||
}
|
||||
private void generateAdditionalClassAnnotations(
|
||||
@NotNull Set<String> annotationDescriptorsAlreadyPresent,
|
||||
@NotNull ClassDescriptor descriptor
|
||||
) {
|
||||
if (descriptor.getKind() == ClassKind.ANNOTATION_CLASS) {
|
||||
generateDocumentedAnnotation(descriptor, annotationDescriptorsAlreadyPresent);
|
||||
generateRetentionAnnotation(descriptor, annotationDescriptorsAlreadyPresent);
|
||||
generateTargetAnnotation(descriptor, annotationDescriptorsAlreadyPresent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -348,14 +348,6 @@ public class JvmCodegenUtil {
|
||||
!JvmAbi.isMappedIntrinsicCompanionObject((ClassDescriptor) companionObject);
|
||||
}
|
||||
|
||||
public static boolean hasBackingField(
|
||||
@NotNull PropertyDescriptor descriptor, @NotNull OwnerKind kind, @NotNull BindingContext bindingContext
|
||||
) {
|
||||
return !isJvmInterface(descriptor.getContainingDeclaration()) &&
|
||||
kind != OwnerKind.DEFAULT_IMPLS &&
|
||||
!Boolean.FALSE.equals(bindingContext.get(BindingContext.BACKING_FIELD_REQUIRED, descriptor));
|
||||
}
|
||||
|
||||
public static boolean isDeclarationOfBigArityFunctionInvoke(@Nullable DeclarationDescriptor descriptor) {
|
||||
return descriptor instanceof FunctionInvokeDescriptor && ((FunctionInvokeDescriptor) descriptor).hasBigArity();
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import com.intellij.psi.PsiElement;
|
||||
import kotlin.collections.CollectionsKt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.codegen.annotation.AnnotatedWithFakeAnnotations;
|
||||
import org.jetbrains.kotlin.codegen.context.CodegenContextUtil;
|
||||
import org.jetbrains.kotlin.codegen.context.FieldOwnerContext;
|
||||
import org.jetbrains.kotlin.codegen.context.MultifileClassFacadeContext;
|
||||
@@ -19,8 +18,6 @@ import org.jetbrains.kotlin.codegen.state.GenerationState;
|
||||
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper;
|
||||
import org.jetbrains.kotlin.config.LanguageFeature;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotated;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationSplitter;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.kotlin.fileClasses.JvmFileClassUtilKt;
|
||||
@@ -36,7 +33,6 @@ import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOriginKt;
|
||||
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodGenericSignature;
|
||||
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature;
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedPropertyDescriptor;
|
||||
import org.jetbrains.kotlin.storage.LockBasedStorageManager;
|
||||
import org.jetbrains.kotlin.types.ErrorUtils;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.org.objectweb.asm.FieldVisitor;
|
||||
@@ -129,7 +125,7 @@ public class PropertyCodegen {
|
||||
kind == OwnerKind.DEFAULT_IMPLS || kind == OwnerKind.ERASED_INLINE_CLASS
|
||||
: "Generating property with a wrong kind (" + kind + "): " + descriptor;
|
||||
|
||||
genBackingFieldAndAnnotations(declaration, descriptor, false);
|
||||
genBackingFieldAndAnnotations(declaration, descriptor);
|
||||
|
||||
boolean isDefaultGetterAndSetter = isDefaultAccessor(getter) && isDefaultAccessor(setter);
|
||||
|
||||
@@ -154,34 +150,21 @@ public class PropertyCodegen {
|
||||
|
||||
if (UnderscoreUtilKt.isSingleUnderscore(entry)) return;
|
||||
|
||||
genBackingFieldAndAnnotations(entry, descriptor, false);
|
||||
genBackingFieldAndAnnotations(entry, descriptor);
|
||||
|
||||
generateGetter(entry, descriptor, null);
|
||||
generateSetter(entry, descriptor, null);
|
||||
}
|
||||
|
||||
private void genBackingFieldAndAnnotations(
|
||||
@Nullable KtNamedDeclaration declaration, @NotNull PropertyDescriptor descriptor, boolean isParameter
|
||||
) {
|
||||
boolean hasBackingField = JvmCodegenUtil.hasBackingField(descriptor, kind, bindingContext);
|
||||
boolean hasDelegate = declaration instanceof KtProperty && ((KtProperty) declaration).hasDelegate();
|
||||
|
||||
AnnotationSplitter annotationSplitter =
|
||||
AnnotationSplitter.create(LockBasedStorageManager.NO_LOCKS,
|
||||
descriptor.getAnnotations(),
|
||||
AnnotationSplitter.getTargetSet(isParameter, descriptor.isVar(), hasBackingField, hasDelegate));
|
||||
|
||||
Annotations propertyAnnotations = annotationSplitter.getAnnotationsForTarget(AnnotationUseSiteTarget.PROPERTY);
|
||||
|
||||
private void genBackingFieldAndAnnotations(@Nullable KtNamedDeclaration declaration, @NotNull PropertyDescriptor descriptor) {
|
||||
// Fields and '$annotations' methods for non-private const properties are generated in the multi-file facade
|
||||
boolean isBackingFieldOwner = descriptor.isConst() && !Visibilities.isPrivate(descriptor.getVisibility())
|
||||
? !(context instanceof MultifileClassPartContext)
|
||||
: CodegenContextUtil.isImplClassOwner(context);
|
||||
|
||||
Annotations fieldAnnotations = annotationSplitter.getAnnotationsForTarget(AnnotationUseSiteTarget.FIELD);
|
||||
Annotations delegateAnnotations = annotationSplitter.getAnnotationsForTarget(AnnotationUseSiteTarget.PROPERTY_DELEGATE_FIELD);
|
||||
Annotations propertyAnnotations = descriptor.getAnnotations();
|
||||
assert declaration != null : "Declaration is null: " + descriptor + " (context=" + context + ")";
|
||||
generateBackingField(declaration, descriptor, fieldAnnotations, delegateAnnotations, isBackingFieldOwner);
|
||||
generateBackingField(declaration, descriptor, descriptor.getBackingField(), descriptor.getDelegateField(), isBackingFieldOwner);
|
||||
generateSyntheticMethodIfNeeded(descriptor, propertyAnnotations, isBackingFieldOwner);
|
||||
}
|
||||
|
||||
@@ -250,12 +233,12 @@ public class PropertyCodegen {
|
||||
return !Visibilities.isPrivate(descriptor.getVisibility());
|
||||
}
|
||||
|
||||
public void generatePrimaryConstructorProperty(@NotNull KtParameter p, @NotNull PropertyDescriptor descriptor) {
|
||||
genBackingFieldAndAnnotations(p, descriptor, true);
|
||||
public void generatePrimaryConstructorProperty(@NotNull KtParameter parameter, @NotNull PropertyDescriptor descriptor) {
|
||||
genBackingFieldAndAnnotations(parameter, descriptor);
|
||||
|
||||
if (areAccessorsNeededForPrimaryConstructorProperty(descriptor, context.getContextKind())) {
|
||||
generateGetter(p, descriptor, null);
|
||||
generateSetter(p, descriptor, null);
|
||||
generateGetter(parameter, descriptor, null);
|
||||
generateSetter(parameter, descriptor, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -321,8 +304,8 @@ public class PropertyCodegen {
|
||||
private void generateBackingField(
|
||||
@NotNull KtNamedDeclaration p,
|
||||
@NotNull PropertyDescriptor descriptor,
|
||||
@NotNull Annotations backingFieldAnnotations,
|
||||
@NotNull Annotations delegateAnnotations,
|
||||
@Nullable FieldDescriptor backingField,
|
||||
@Nullable FieldDescriptor delegateField,
|
||||
boolean isBackingFieldOwner
|
||||
) {
|
||||
if (isJvmInterface(descriptor.getContainingDeclaration()) || kind == OwnerKind.DEFAULT_IMPLS ||
|
||||
@@ -331,10 +314,10 @@ public class PropertyCodegen {
|
||||
}
|
||||
|
||||
if (p instanceof KtProperty && ((KtProperty) p).hasDelegate()) {
|
||||
generatePropertyDelegateAccess((KtProperty) p, descriptor, delegateAnnotations, isBackingFieldOwner);
|
||||
generatePropertyDelegateAccess((KtProperty) p, descriptor, delegateField, isBackingFieldOwner);
|
||||
}
|
||||
else if (Boolean.TRUE.equals(bindingContext.get(BindingContext.BACKING_FIELD_REQUIRED, descriptor))) {
|
||||
generateBackingFieldAccess(p, descriptor, backingFieldAnnotations, isBackingFieldOwner);
|
||||
generateBackingFieldAccess(p, descriptor, backingField, isBackingFieldOwner);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -369,18 +352,18 @@ public class PropertyCodegen {
|
||||
}
|
||||
|
||||
private void generateBackingField(
|
||||
KtNamedDeclaration element,
|
||||
PropertyDescriptor propertyDescriptor,
|
||||
@NotNull KtNamedDeclaration element,
|
||||
@NotNull PropertyDescriptor propertyDescriptor,
|
||||
boolean isDelegate,
|
||||
KotlinType kotlinType,
|
||||
Object defaultValue,
|
||||
Annotations annotations,
|
||||
@NotNull KotlinType kotlinType,
|
||||
@Nullable Object defaultValue,
|
||||
@Nullable FieldDescriptor annotatedField,
|
||||
boolean isBackingFieldOwner
|
||||
) {
|
||||
int modifiers = getDeprecatedAccessFlag(propertyDescriptor);
|
||||
|
||||
for (AnnotationCodegen.JvmFlagAnnotation flagAnnotation : AnnotationCodegen.FIELD_FLAGS) {
|
||||
if (flagAnnotation.hasAnnotation(propertyDescriptor.getOriginal())) {
|
||||
if (annotatedField != null && flagAnnotation.hasAnnotation(annotatedField)) {
|
||||
modifiers |= flagAnnotation.getJvmFlag();
|
||||
}
|
||||
}
|
||||
@@ -428,21 +411,21 @@ public class PropertyCodegen {
|
||||
isDelegate ? null : typeMapper.mapFieldSignature(kotlinType, propertyDescriptor), defaultValue
|
||||
);
|
||||
|
||||
Annotated fieldAnnotated = new AnnotatedWithFakeAnnotations(propertyDescriptor, annotations);
|
||||
AnnotationCodegen.forField(fv, memberCodegen, typeMapper).genAnnotations(
|
||||
fieldAnnotated, type, isDelegate ? AnnotationUseSiteTarget.PROPERTY_DELEGATE_FIELD : AnnotationUseSiteTarget.FIELD);
|
||||
if (annotatedField != null) {
|
||||
AnnotationCodegen.forField(fv, memberCodegen, typeMapper).genAnnotations(annotatedField, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void generatePropertyDelegateAccess(
|
||||
@NotNull KtProperty p,
|
||||
@NotNull PropertyDescriptor propertyDescriptor,
|
||||
@NotNull Annotations annotations,
|
||||
@Nullable FieldDescriptor delegateField,
|
||||
boolean isBackingFieldOwner
|
||||
) {
|
||||
KotlinType delegateType = getDelegateTypeForProperty(p, propertyDescriptor);
|
||||
|
||||
generateBackingField(p, propertyDescriptor, true, delegateType, null, annotations, isBackingFieldOwner);
|
||||
generateBackingField(p, propertyDescriptor, true, delegateType, null, delegateField, isBackingFieldOwner);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -470,7 +453,7 @@ public class PropertyCodegen {
|
||||
private void generateBackingFieldAccess(
|
||||
@NotNull KtNamedDeclaration p,
|
||||
@NotNull PropertyDescriptor propertyDescriptor,
|
||||
@NotNull Annotations annotations,
|
||||
@Nullable FieldDescriptor backingField,
|
||||
boolean isBackingFieldOwner
|
||||
) {
|
||||
Object value = null;
|
||||
@@ -482,7 +465,7 @@ public class PropertyCodegen {
|
||||
}
|
||||
}
|
||||
|
||||
generateBackingField(p, propertyDescriptor, false, propertyDescriptor.getType(), value, annotations, isBackingFieldOwner);
|
||||
generateBackingField(p, propertyDescriptor, false, propertyDescriptor.getType(), value, backingField, isBackingFieldOwner);
|
||||
}
|
||||
|
||||
private boolean shouldWriteFieldInitializer(@NotNull PropertyDescriptor descriptor) {
|
||||
|
||||
-26
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.codegen.annotation
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotated
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
|
||||
interface WrappedAnnotated : Annotated {
|
||||
val originalAnnotated: Annotated
|
||||
}
|
||||
|
||||
class AnnotatedWithFakeAnnotations(override val originalAnnotated: Annotated, override val annotations: Annotations) : WrappedAnnotated
|
||||
+5
-5
@@ -7,6 +7,8 @@ package org.jetbrains.kotlin.resolve.jvm.annotations
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotated
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
||||
import org.jetbrains.kotlin.load.java.JvmAbi.JVM_FIELD_ANNOTATION_FQ_NAME
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
@@ -29,7 +31,7 @@ fun DeclarationDescriptor.findJvmOverloadsAnnotation(): AnnotationDescriptor? =
|
||||
annotations.findAnnotation(JVM_OVERLOADS_FQ_NAME)
|
||||
|
||||
fun DeclarationDescriptor.findJvmFieldAnnotation(): AnnotationDescriptor? =
|
||||
DescriptorUtils.getAnnotationByFqName(annotations, JVM_FIELD_ANNOTATION_FQ_NAME)
|
||||
(this as? PropertyDescriptor)?.backingField?.annotations?.findAnnotation(JVM_FIELD_ANNOTATION_FQ_NAME)
|
||||
|
||||
fun DeclarationDescriptor.hasJvmFieldAnnotation(): Boolean =
|
||||
findJvmFieldAnnotation() != null
|
||||
@@ -40,8 +42,9 @@ fun DeclarationDescriptor.isCallableMemberWithJvmDefaultAnnotation(): Boolean =
|
||||
fun CallableMemberDescriptor.hasJvmDefaultAnnotation(): Boolean =
|
||||
DescriptorUtils.getDirectMember(this).annotations.hasAnnotation(JVM_DEFAULT_FQ_NAME)
|
||||
|
||||
fun DeclarationDescriptor.findJvmSyntheticAnnotation(): AnnotationDescriptor? =
|
||||
private fun Annotated.findJvmSyntheticAnnotation(): AnnotationDescriptor? =
|
||||
DescriptorUtils.getAnnotationByFqName(annotations, JVM_SYNTHETIC_ANNOTATION_FQ_NAME)
|
||||
?: (this as? PropertyDescriptor)?.backingField?.annotations?.findAnnotation(JVM_SYNTHETIC_ANNOTATION_FQ_NAME)
|
||||
|
||||
fun DeclarationDescriptor.hasJvmSyntheticAnnotation(): Boolean =
|
||||
findJvmSyntheticAnnotation() != null
|
||||
@@ -49,8 +52,5 @@ fun DeclarationDescriptor.hasJvmSyntheticAnnotation(): Boolean =
|
||||
fun DeclarationDescriptor.findStrictfpAnnotation(): AnnotationDescriptor? =
|
||||
DescriptorUtils.getAnnotationByFqName(annotations, STRICTFP_ANNOTATION_FQ_NAME)
|
||||
|
||||
fun DeclarationDescriptor.findVolatileAnnotation(): AnnotationDescriptor? =
|
||||
DescriptorUtils.getAnnotationByFqName(annotations, VOLATILE_ANNOTATION_FQ_NAME)
|
||||
|
||||
fun DeclarationDescriptor.findSynchronizedAnnotation(): AnnotationDescriptor? =
|
||||
DescriptorUtils.getAnnotationByFqName(annotations, SYNCHRONIZED_ANNOTATION_FQ_NAME)
|
||||
|
||||
+5
-2
@@ -50,10 +50,13 @@ class JvmFieldApplicabilityChecker : DeclarationChecker {
|
||||
}
|
||||
|
||||
override fun check(declaration: KtDeclaration, descriptor: DeclarationDescriptor, context: DeclarationCheckerContext) {
|
||||
val annotation = descriptor.findJvmFieldAnnotation() ?: return
|
||||
if (descriptor !is PropertyDescriptor) return
|
||||
|
||||
val annotation = descriptor.findJvmFieldAnnotation()
|
||||
?: descriptor.delegateField?.annotations?.findAnnotation(JvmAbi.JVM_FIELD_ANNOTATION_FQ_NAME)
|
||||
?: return
|
||||
|
||||
val problem = when {
|
||||
descriptor !is PropertyDescriptor -> return
|
||||
declaration is KtProperty && declaration.hasDelegate() -> DELEGATE
|
||||
!descriptor.hasBackingField(context.trace.bindingContext) -> return
|
||||
descriptor.isOverridable -> NOT_FINAL
|
||||
|
||||
+4
-5
@@ -17,19 +17,18 @@
|
||||
package org.jetbrains.kotlin.resolve.jvm.checkers
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.VariableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtProperty
|
||||
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
|
||||
import org.jetbrains.kotlin.resolve.checkers.DeclarationChecker
|
||||
import org.jetbrains.kotlin.resolve.checkers.DeclarationCheckerContext
|
||||
import org.jetbrains.kotlin.resolve.jvm.annotations.findJvmSyntheticAnnotation
|
||||
import org.jetbrains.kotlin.resolve.jvm.annotations.JVM_SYNTHETIC_ANNOTATION_FQ_NAME
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
|
||||
|
||||
class JvmSyntheticApplicabilityChecker : DeclarationChecker {
|
||||
override fun check(declaration: KtDeclaration, descriptor: DeclarationDescriptor, context: DeclarationCheckerContext) {
|
||||
val annotation = descriptor.findJvmSyntheticAnnotation() ?: return
|
||||
if (declaration is KtProperty && descriptor is VariableDescriptor && declaration.hasDelegate()) {
|
||||
val annotation = (descriptor as? PropertyDescriptor)?.delegateField?.annotations?.findAnnotation(JVM_SYNTHETIC_ANNOTATION_FQ_NAME)
|
||||
if (annotation != null) {
|
||||
val annotationEntry = DescriptorToSourceUtils.getSourceFromAnnotation(annotation) ?: return
|
||||
context.trace.report(ErrorsJvm.JVM_SYNTHETIC_ON_DELEGATE.on(annotationEntry))
|
||||
}
|
||||
|
||||
+13
-11
@@ -34,9 +34,9 @@ import org.jetbrains.kotlin.resolve.calls.components.isActualParameterWithCorres
|
||||
import org.jetbrains.kotlin.resolve.checkers.DeclarationChecker
|
||||
import org.jetbrains.kotlin.resolve.checkers.DeclarationCheckerContext
|
||||
import org.jetbrains.kotlin.resolve.inline.InlineUtil
|
||||
import org.jetbrains.kotlin.resolve.jvm.annotations.VOLATILE_ANNOTATION_FQ_NAME
|
||||
import org.jetbrains.kotlin.resolve.jvm.annotations.findJvmOverloadsAnnotation
|
||||
import org.jetbrains.kotlin.resolve.jvm.annotations.findSynchronizedAnnotation
|
||||
import org.jetbrains.kotlin.resolve.jvm.annotations.findVolatileAnnotation
|
||||
import org.jetbrains.kotlin.resolve.jvm.annotations.hasJvmFieldAnnotation
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
|
||||
|
||||
@@ -156,16 +156,18 @@ class JvmNameAnnotationChecker : DeclarationChecker {
|
||||
|
||||
class VolatileAnnotationChecker : DeclarationChecker {
|
||||
override fun check(declaration: KtDeclaration, descriptor: DeclarationDescriptor, context: DeclarationCheckerContext) {
|
||||
val volatileAnnotation = descriptor.findVolatileAnnotation()
|
||||
if (volatileAnnotation != null) {
|
||||
if (descriptor is PropertyDescriptor && !descriptor.isVar) {
|
||||
val annotationEntry = DescriptorToSourceUtils.getSourceFromAnnotation(volatileAnnotation) ?: return
|
||||
context.trace.report(ErrorsJvm.VOLATILE_ON_VALUE.on(annotationEntry))
|
||||
}
|
||||
if (declaration is KtProperty && declaration.hasDelegate()) {
|
||||
val annotationEntry = DescriptorToSourceUtils.getSourceFromAnnotation(volatileAnnotation) ?: return
|
||||
context.trace.report(ErrorsJvm.VOLATILE_ON_DELEGATE.on(annotationEntry))
|
||||
}
|
||||
if (descriptor !is PropertyDescriptor) return
|
||||
|
||||
val fieldAnnotation = descriptor.backingField?.annotations?.findAnnotation(VOLATILE_ANNOTATION_FQ_NAME)
|
||||
if (fieldAnnotation != null && !descriptor.isVar) {
|
||||
val annotationEntry = DescriptorToSourceUtils.getSourceFromAnnotation(fieldAnnotation) ?: return
|
||||
context.trace.report(ErrorsJvm.VOLATILE_ON_VALUE.on(annotationEntry))
|
||||
}
|
||||
|
||||
val delegateAnnotation = descriptor.delegateField?.annotations?.findAnnotation(VOLATILE_ANNOTATION_FQ_NAME)
|
||||
if (delegateAnnotation != null) {
|
||||
val annotationEntry = DescriptorToSourceUtils.getSourceFromAnnotation(delegateAnnotation) ?: return
|
||||
context.trace.report(ErrorsJvm.VOLATILE_ON_DELEGATE.on(annotationEntry))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+15
-19
@@ -87,16 +87,15 @@ class AnnotationSplitter(
|
||||
class PropertyWrapper @JvmOverloads constructor(val declaration: KtDeclaration, var descriptor: PropertyDescriptor? = null)
|
||||
|
||||
private val splitAnnotations = storageManager.createLazyValue {
|
||||
val map = hashMapOf<AnnotationUseSiteTarget, MutableList<AnnotationWithTarget>>()
|
||||
val other = arrayListOf<AnnotationWithTarget>()
|
||||
val map = hashMapOf<AnnotationUseSiteTarget, MutableList<AnnotationDescriptor>>()
|
||||
val other = arrayListOf<AnnotationDescriptor>()
|
||||
val applicableTargets = applicableTargetsLazy()
|
||||
val applicableTargetsWithoutUseSiteTarget = applicableTargets.intersect(TARGET_PRIORITIES)
|
||||
|
||||
outer@ for (annotationWithTarget in allAnnotations.getAllAnnotations()) {
|
||||
val useSiteTarget = annotationWithTarget.target
|
||||
outer@ for ((annotation, useSiteTarget) in allAnnotations.getAllAnnotations()) {
|
||||
if (useSiteTarget != null) {
|
||||
if (useSiteTarget in applicableTargets)
|
||||
map.getOrPut(useSiteTarget, { arrayListOf() }).add(annotationWithTarget)
|
||||
map.getOrPut(useSiteTarget) { arrayListOf() }.add(annotation)
|
||||
|
||||
continue@outer
|
||||
}
|
||||
@@ -105,38 +104,36 @@ class AnnotationSplitter(
|
||||
if (target !in applicableTargetsWithoutUseSiteTarget) continue
|
||||
|
||||
val declarationSiteTargetForCurrentTarget = KotlinTarget.USE_SITE_MAPPING[target] ?: continue
|
||||
val applicableTargetsForAnnotation = AnnotationChecker.applicableTargetSet(annotationWithTarget.annotation)
|
||||
val applicableTargetsForAnnotation = AnnotationChecker.applicableTargetSet(annotation)
|
||||
|
||||
if (declarationSiteTargetForCurrentTarget in applicableTargetsForAnnotation) {
|
||||
map.getOrPut(target, { arrayListOf() }).add(annotationWithTarget)
|
||||
map.getOrPut(target) { arrayListOf() }.add(annotation)
|
||||
continue@outer
|
||||
}
|
||||
}
|
||||
|
||||
other.add(annotationWithTarget)
|
||||
other.add(annotation)
|
||||
}
|
||||
map to AnnotationsImpl.create(other)
|
||||
|
||||
map to AnnotationsImpl(other)
|
||||
}
|
||||
|
||||
fun getOtherAnnotations(): Annotations = LazySplitAnnotations(storageManager, null)
|
||||
|
||||
fun getAnnotationsForTarget(target: AnnotationUseSiteTarget): Annotations = LazySplitAnnotations(storageManager, target)
|
||||
|
||||
fun getAnnotationsForTargets(vararg targets: AnnotationUseSiteTarget): Annotations {
|
||||
return CompositeAnnotations(targets.map { getAnnotationsForTarget(it) })
|
||||
}
|
||||
|
||||
private inner class LazySplitAnnotations(
|
||||
storageManager: StorageManager,
|
||||
val target: AnnotationUseSiteTarget?
|
||||
) : Annotations, LazyEntity {
|
||||
private val annotations by storageManager.createLazyValue {
|
||||
val splitAnnotations = this@AnnotationSplitter.splitAnnotations()
|
||||
val (targeted, other) = this@AnnotationSplitter.splitAnnotations()
|
||||
|
||||
if (target != null)
|
||||
AnnotationsImpl.create(splitAnnotations.first[target] ?: emptyList())
|
||||
else
|
||||
splitAnnotations.second
|
||||
if (target != null) {
|
||||
targeted[target]?.let(::AnnotationsImpl) ?: Annotations.EMPTY
|
||||
} else {
|
||||
other
|
||||
}
|
||||
}
|
||||
|
||||
override fun forceResolveAllContents() {
|
||||
@@ -151,5 +148,4 @@ class AnnotationSplitter(
|
||||
override fun iterator() = annotations.iterator()
|
||||
override fun toString() = annotations.toString()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -876,8 +876,9 @@ public class DescriptorResolver {
|
||||
() -> AnnotationSplitter.getTargetSet(false, trace.getBindingContext(), wrapper));
|
||||
|
||||
Annotations propertyAnnotations = new CompositeAnnotations(CollectionsKt.listOf(
|
||||
annotationSplitter.getAnnotationsForTargets(PROPERTY, FIELD, PROPERTY_DELEGATE_FIELD),
|
||||
annotationSplitter.getOtherAnnotations()));
|
||||
annotationSplitter.getAnnotationsForTarget(PROPERTY),
|
||||
annotationSplitter.getOtherAnnotations())
|
||||
);
|
||||
|
||||
PropertyDescriptorImpl propertyDescriptor = PropertyDescriptorImpl.create(
|
||||
container,
|
||||
@@ -984,7 +985,11 @@ public class DescriptorResolver {
|
||||
propertyInfo.getPropertySetter(),
|
||||
propertyInfo.getHasDelegate());
|
||||
|
||||
propertyDescriptor.initialize(getter, setter);
|
||||
propertyDescriptor.initialize(
|
||||
getter, setter,
|
||||
new FieldDescriptorImpl(annotationSplitter.getAnnotationsForTarget(FIELD), propertyDescriptor),
|
||||
new FieldDescriptorImpl(annotationSplitter.getAnnotationsForTarget(PROPERTY_DELEGATE_FIELD), propertyDescriptor)
|
||||
);
|
||||
|
||||
trace.record(BindingContext.VARIABLE, variableDeclaration, propertyDescriptor);
|
||||
return propertyDescriptor;
|
||||
@@ -1222,8 +1227,9 @@ public class DescriptorResolver {
|
||||
() -> AnnotationSplitter.getTargetSet(true, trace.getBindingContext(), propertyWrapper));
|
||||
|
||||
Annotations propertyAnnotations = new CompositeAnnotations(
|
||||
annotationSplitter.getAnnotationsForTargets(PROPERTY, FIELD),
|
||||
annotationSplitter.getOtherAnnotations());
|
||||
annotationSplitter.getAnnotationsForTarget(PROPERTY),
|
||||
annotationSplitter.getOtherAnnotations()
|
||||
);
|
||||
|
||||
PropertyDescriptorImpl propertyDescriptor = PropertyDescriptorImpl.create(
|
||||
classDescriptor,
|
||||
@@ -1256,7 +1262,12 @@ public class DescriptorResolver {
|
||||
)
|
||||
: null;
|
||||
|
||||
propertyDescriptor.initialize(getter, setter);
|
||||
propertyDescriptor.initialize(
|
||||
getter, setter,
|
||||
new FieldDescriptorImpl(annotationSplitter.getAnnotationsForTarget(FIELD), propertyDescriptor),
|
||||
null
|
||||
);
|
||||
|
||||
getter.initialize(propertyDescriptor.getType());
|
||||
|
||||
trace.record(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, parameter, propertyDescriptor);
|
||||
|
||||
+9
-1
@@ -578,4 +578,12 @@ open class WrappedPropertyDescriptor(
|
||||
}
|
||||
|
||||
override val isDelegated get() = false
|
||||
}
|
||||
|
||||
override fun getBackingField(): FieldDescriptor? {
|
||||
TODO("not implemented")
|
||||
}
|
||||
|
||||
override fun getDelegateField(): FieldDescriptor? {
|
||||
TODO("not implemented")
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -366,7 +366,9 @@ internal class DeepCopyIrTreeWithDescriptors(val targetDescriptor: FunctionDescr
|
||||
|
||||
initialize(
|
||||
/* getter = */ oldDescriptor.getter?.let { copyPropertyGetterDescriptor(it, this) },
|
||||
/* setter = */ oldDescriptor.setter?.let { copyPropertySetterDescriptor(it, this) })
|
||||
/* setter = */ oldDescriptor.setter?.let { copyPropertySetterDescriptor(it, this) },
|
||||
oldDescriptor.backingField, oldDescriptor.delegateField
|
||||
)
|
||||
|
||||
overriddenDescriptors += oldDescriptor.overriddenDescriptors
|
||||
}
|
||||
|
||||
@@ -18,11 +18,12 @@ package org.jetbrains.kotlin.backend.jvm.descriptors
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.descriptors.impl.*
|
||||
import org.jetbrains.kotlin.descriptors.impl.PropertyDescriptorImpl
|
||||
import org.jetbrains.kotlin.descriptors.impl.PropertyGetterDescriptorImpl
|
||||
import org.jetbrains.kotlin.descriptors.impl.PropertySetterDescriptorImpl
|
||||
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeProjectionImpl
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor
|
||||
|
||||
fun PropertyDescriptorImpl.initialize(
|
||||
type: KotlinType,
|
||||
@@ -30,10 +31,12 @@ fun PropertyDescriptorImpl.initialize(
|
||||
dispatchReceiverParameter: ReceiverParameterDescriptor? = null,
|
||||
extensionReceiverParameter: ReceiverParameterDescriptor? = null,
|
||||
getter: PropertyGetterDescriptorImpl? = null,
|
||||
setter: PropertySetterDescriptorImpl? = null
|
||||
setter: PropertySetterDescriptorImpl? = null,
|
||||
backingField: FieldDescriptor? = null,
|
||||
delegateField: FieldDescriptor? = null
|
||||
): PropertyDescriptorImpl {
|
||||
setType(type, typeParameters, dispatchReceiverParameter, extensionReceiverParameter)
|
||||
initialize(getter, setter)
|
||||
initialize(getter, setter, backingField, delegateField)
|
||||
return this
|
||||
}
|
||||
|
||||
|
||||
+13
-23
@@ -5,9 +5,11 @@
|
||||
|
||||
package org.jetbrains.kotlin.psi2ir.generators
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclaration
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||
import org.jetbrains.kotlin.ir.declarations.IrField
|
||||
import org.jetbrains.kotlin.ir.declarations.IrTypeParametersContainer
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid
|
||||
import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid
|
||||
|
||||
@@ -31,27 +33,15 @@ class AnnotationGenerator(context: GeneratorContext) : IrElementVisitorVoid {
|
||||
}
|
||||
|
||||
private fun generateAnnotationsForDeclaration(declaration: IrDeclaration) {
|
||||
declaration.descriptor.annotations.getAllAnnotations()
|
||||
.filter { isAnnotationTargetMatchingDeclaration(it.target, declaration) }
|
||||
.mapTo(declaration.annotations) {
|
||||
constantValueGenerator.generateAnnotationConstructorCall(it.annotation)
|
||||
}
|
||||
}
|
||||
// Delegate field is mapped to a new property descriptor with annotations of the original property delegate
|
||||
// (see IrPropertyDelegateDescriptorImpl), but annotations on backing fields should be processed manually here
|
||||
val annotatedDescriptor =
|
||||
if (declaration is IrField && declaration.origin != IrDeclarationOrigin.DELEGATE)
|
||||
declaration.descriptor.backingField
|
||||
else declaration.descriptor
|
||||
|
||||
private fun isAnnotationTargetMatchingDeclaration(target: AnnotationUseSiteTarget?, element: IrElement): Boolean =
|
||||
when (element) {
|
||||
is IrProperty ->
|
||||
target == null || target == AnnotationUseSiteTarget.PROPERTY
|
||||
|
||||
is IrField ->
|
||||
target == AnnotationUseSiteTarget.FIELD || target == AnnotationUseSiteTarget.PROPERTY_DELEGATE_FIELD
|
||||
|
||||
is IrSimpleFunction ->
|
||||
target == null || target == AnnotationUseSiteTarget.PROPERTY_GETTER || target == AnnotationUseSiteTarget.PROPERTY_SETTER
|
||||
|
||||
is IrValueParameter ->
|
||||
target == null || target == AnnotationUseSiteTarget.CONSTRUCTOR_PARAMETER
|
||||
|
||||
else -> target == null
|
||||
annotatedDescriptor?.annotations?.mapTo(declaration.annotations) {
|
||||
constantValueGenerator.generateAnnotationConstructorCall(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ class IrPropertyDelegateDescriptorImpl(
|
||||
correspondingProperty.containingDeclaration,
|
||||
getDelegateName(correspondingProperty.name),
|
||||
delegateType,
|
||||
correspondingProperty.annotations
|
||||
correspondingProperty.delegateField?.annotations ?: Annotations.EMPTY
|
||||
),
|
||||
IrPropertyDelegateDescriptor
|
||||
|
||||
|
||||
+8
-27
@@ -27,13 +27,9 @@ import org.jetbrains.kotlin.asJava.classes.lazyPub
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationWithTarget
|
||||
import org.jetbrains.kotlin.descriptors.annotations.KotlinTarget
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getParentOfType
|
||||
import org.jetbrains.kotlin.psi.psiUtil.isPropertyParameter
|
||||
import org.jetbrains.kotlin.resolve.AnnotationChecker
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.jvm.annotations.JVM_DEFAULT_FQ_NAME
|
||||
import org.jetbrains.kotlin.resolve.source.getPsi
|
||||
@@ -146,25 +142,26 @@ private fun getAnnotationDescriptors(declaration: KtDeclaration, annotatedLightE
|
||||
}
|
||||
|
||||
val annotatedDescriptor = when {
|
||||
descriptor is ClassDescriptor && annotatedLightElement is KtLightMethod && annotatedLightElement.isConstructor -> descriptor.unsubstitutedPrimaryConstructor
|
||||
descriptor !is PropertyDescriptor || annotatedLightElement !is KtLightMethod -> descriptor
|
||||
descriptor is ClassDescriptor && annotatedLightElement is KtLightMethod && annotatedLightElement.isConstructor ->
|
||||
descriptor.unsubstitutedPrimaryConstructor
|
||||
descriptor !is PropertyDescriptor -> descriptor
|
||||
annotatedLightElement is KtLightFieldImpl.KtLightFieldForDeclaration -> descriptor.backingField
|
||||
annotatedLightElement !is KtLightMethod -> descriptor
|
||||
annotatedLightElement.isGetter -> descriptor.getter
|
||||
annotatedLightElement.isSetter -> descriptor.setter
|
||||
else -> descriptor
|
||||
} ?: return emptyList()
|
||||
|
||||
val annotations = annotatedDescriptor.annotations.getAllAnnotations()
|
||||
.filter { it.matches(annotatedLightElement) }
|
||||
.map { it.annotation }
|
||||
val annotations = annotatedDescriptor.annotations.toMutableList()
|
||||
|
||||
if (descriptor is PropertyDescriptor) {
|
||||
val jvmDefault = descriptor.annotations.findAnnotation(JVM_DEFAULT_FQ_NAME)
|
||||
if (jvmDefault != null) {
|
||||
return annotations + jvmDefault
|
||||
annotations.add(jvmDefault)
|
||||
}
|
||||
}
|
||||
return annotations
|
||||
|
||||
return annotations
|
||||
}
|
||||
|
||||
private fun hasAnnotationsInSource(declaration: KtDeclaration): Boolean {
|
||||
@@ -178,19 +175,3 @@ private fun hasAnnotationsInSource(declaration: KtDeclaration): Boolean {
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
private fun AnnotationWithTarget.matches(annotated: KtLightElement<*, *>): Boolean {
|
||||
if (annotated is KtLightFieldImpl.KtLightFieldForDeclaration) {
|
||||
if (target == AnnotationUseSiteTarget.FIELD) return true
|
||||
|
||||
if (target != null) return false
|
||||
|
||||
val declarationSiteTargets = AnnotationChecker.applicableTargetSet(annotation)
|
||||
return KotlinTarget.FIELD in declarationSiteTargets && KotlinTarget.PROPERTY !in declarationSiteTargets
|
||||
}
|
||||
else if (annotated is KtLightParameter && annotated.method.isSetter) {
|
||||
return target == AnnotationUseSiteTarget.SETTER_PARAMETER
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
@@ -28,7 +28,7 @@ object KotlinStubVersions {
|
||||
// Binary stub version should be increased if stub format (org.jetbrains.kotlin.psi.stubs.impl) is changed
|
||||
// or changes are made to the core stub building code (org.jetbrains.kotlin.idea.decompiler.stubBuilder).
|
||||
// Increasing this version will lead to reindexing of all binary files that are potentially kotlin binaries (including all class files).
|
||||
private const val BINARY_STUB_VERSION = 68
|
||||
private const val BINARY_STUB_VERSION = 69
|
||||
|
||||
// Classfile stub version should be increased if changes are made to classfile stub building subsystem (org.jetbrains.kotlin.idea.decompiler.classFile)
|
||||
// Increasing this version will lead to reindexing of all classfiles.
|
||||
|
||||
+4
-1
@@ -164,7 +164,10 @@ class DescriptorSerializer private constructor(
|
||||
val compileTimeConstant = descriptor.compileTimeInitializer
|
||||
val hasConstant = compileTimeConstant != null && compileTimeConstant !is NullValue
|
||||
|
||||
val hasAnnotations = descriptor.annotations.getAllAnnotations().isNotEmpty()
|
||||
val hasAnnotations =
|
||||
!descriptor.annotations.isEmpty() ||
|
||||
descriptor.backingField?.annotations?.isEmpty() == false ||
|
||||
descriptor.delegateField?.annotations?.isEmpty() == false
|
||||
|
||||
val propertyFlags = Flags.getAccessorFlags(
|
||||
hasAnnotations,
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
package
|
||||
|
||||
package a {
|
||||
@java.lang.Deprecated @java.lang.SuppressWarnings(value = {}) public val s: kotlin.String = ""
|
||||
@field:java.lang.Deprecated @field:java.lang.SuppressWarnings(value = {}) public val s: kotlin.String = ""
|
||||
@java.lang.Deprecated @java.lang.SuppressWarnings(value = {}) public fun main(/*0*/ args: kotlin.Array<kotlin.String>): kotlin.Unit
|
||||
|
||||
public final class Test {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package
|
||||
|
||||
public var bar: kotlin.Int
|
||||
@setparam:[ERROR : varargs] /* annotation class not found */ public var bar: kotlin.Int
|
||||
public val x: (kotlin.Int) -> kotlin.Int
|
||||
public fun foo(/*0*/ @[ERROR : varargs] /* annotation class not found */ f: kotlin.Int): kotlin.Unit
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package
|
||||
|
||||
public var bar: kotlin.Int
|
||||
@setparam:test public var bar: kotlin.Int
|
||||
public val x: (kotlin.Int) -> kotlin.Int
|
||||
public fun foo(/*0*/ @test f: kotlin.Int): kotlin.Unit
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package
|
||||
|
||||
public var x: kotlin.Int
|
||||
@setparam:Ann public var x: kotlin.Int
|
||||
|
||||
@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.CLASS}) public final annotation class Ann : kotlin.Annotation {
|
||||
public constructor Ann()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package
|
||||
|
||||
@Field public val x: kotlin.Int = 42
|
||||
@field:Field public val x: kotlin.Int = 42
|
||||
@Field public val y: kotlin.Int
|
||||
|
||||
@Field public final annotation class Another : kotlin.Annotation {
|
||||
@@ -28,8 +28,8 @@ public interface His {
|
||||
@Field public abstract class My {
|
||||
public constructor My(/*0*/ @Field arg: kotlin.Int, /*1*/ w: kotlin.Int)
|
||||
@Field public final val v: kotlin.Int
|
||||
@Field public final val w: kotlin.Int
|
||||
@Field public final val x: kotlin.Int
|
||||
@field:Field public final val w: kotlin.Int
|
||||
@field:Field public final val x: kotlin.Int
|
||||
@Field public final val y: kotlin.Int
|
||||
@Field public abstract val z: kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
|
||||
@@ -75,8 +75,8 @@ package test {
|
||||
@test.AnnotationTargets.base @test.AnnotationTargets.meta @test.AnnotationTargets.type @test.AnnotationTargets.method @test.AnnotationTargets.multiple public final class KClass {
|
||||
@test.AnnotationTargets.base @test.AnnotationTargets.method @test.AnnotationTargets.konstructor public constructor KClass()
|
||||
public constructor KClass(/*0*/ @test.AnnotationTargets.base @test.AnnotationTargets.parameter y: @test.AnnotationTargets.base @test.AnnotationTargets.type kotlin.Int)
|
||||
@test.AnnotationTargets.base @test.AnnotationTargets.multiple @test.AnnotationTargets.fieldann @test.AnnotationTargets.local public final val x: kotlin.Int = 0
|
||||
@test.AnnotationTargets.fieldann public final val y: @test.AnnotationTargets.base @test.AnnotationTargets.type kotlin.Int
|
||||
@test.AnnotationTargets.base @test.AnnotationTargets.local @field:test.AnnotationTargets.multiple @field:test.AnnotationTargets.fieldann public final val x: kotlin.Int = 0
|
||||
@field:test.AnnotationTargets.fieldann public final val y: @test.AnnotationTargets.base @test.AnnotationTargets.type kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
@test.AnnotationTargets.base @test.AnnotationTargets.method @test.AnnotationTargets.multiple @test.AnnotationTargets.konstructor public final fun foo(/*0*/ @test.AnnotationTargets.parameter @test.AnnotationTargets.type i: @test.AnnotationTargets.base @test.AnnotationTargets.multiple kotlin.Int): @test.AnnotationTargets.fieldann @test.AnnotationTargets.parameter kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package
|
||||
|
||||
@unrepann(x = 0) public var annotated: kotlin.Int
|
||||
@unrepann(x = 0) @property:unrepann(x = 1) public var annotated2: kotlin.Int
|
||||
@unrepann(x = 0) @unrepann(x = 1) public var annotated2: kotlin.Int
|
||||
@ann(y = 0) @ann(y = 1) public fun foo(/*0*/ @ann(y = 7) @ann(y = 2) x: kotlin.Int): kotlin.Int
|
||||
|
||||
@unrepann(x = 1) @unrepann(x = 2) public final class DoubleAnnotated {
|
||||
|
||||
+7
-7
@@ -1,6 +1,6 @@
|
||||
package
|
||||
|
||||
public fun foo(/*0*/ @delegate:Field @delegate:Prop x: kotlin.Int): kotlin.Int
|
||||
public fun foo(/*0*/ x: kotlin.Int): kotlin.Int
|
||||
|
||||
public final class CustomDelegate {
|
||||
public constructor CustomDelegate()
|
||||
@@ -24,19 +24,19 @@ public final class CustomDelegate {
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
@delegate:Field public final class SomeClass {
|
||||
@delegate:Field public constructor SomeClass()
|
||||
public final class SomeClass {
|
||||
public constructor SomeClass()
|
||||
@delegate:Field @delegate:Prop protected final val delegatedProperty: kotlin.String
|
||||
@delegate:Field @delegate:Prop public final val propertyWithCustomGetter: kotlin.Int
|
||||
@delegate:Field @delegate:Prop protected final val simpleProperty: kotlin.String = "text"
|
||||
public final val propertyWithCustomGetter: kotlin.Int
|
||||
protected final val simpleProperty: kotlin.String = "text"
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class WithPrimaryConstructor {
|
||||
public constructor WithPrimaryConstructor(/*0*/ a: kotlin.String, /*1*/ @param:Field @param:Prop b: kotlin.String)
|
||||
@delegate:Field @delegate:Prop public final val a: kotlin.String
|
||||
public constructor WithPrimaryConstructor(/*0*/ a: kotlin.String, /*1*/ @Field @Prop b: kotlin.String)
|
||||
public final val a: kotlin.String
|
||||
public final val b: kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
|
||||
+5
-5
@@ -15,13 +15,13 @@ public final class CustomDelegate {
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
@field:Ann public final class SomeClass {
|
||||
@field:Ann public constructor SomeClass()
|
||||
@field:Ann protected final val delegatedProperty: kotlin.String
|
||||
@field:Ann public final val propertyWithCustomGetter: kotlin.Int
|
||||
public final class SomeClass {
|
||||
public constructor SomeClass()
|
||||
protected final val delegatedProperty: kotlin.String
|
||||
public final val propertyWithCustomGetter: kotlin.Int
|
||||
@field:Ann protected final val simpleProperty: kotlin.String = "text"
|
||||
@field:Ann protected final val simplePropertyWithAnnotationList: kotlin.String = "text"
|
||||
@field:Ann public final fun anotherFun(/*0*/ @field:Ann s: kotlin.String): kotlin.Unit
|
||||
public final fun anotherFun(/*0*/ s: kotlin.String): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
+3
-3
@@ -15,14 +15,14 @@ public final class CustomDelegate {
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
@get:Ann public final class SomeClass {
|
||||
@get:Ann public constructor SomeClass()
|
||||
public final class SomeClass {
|
||||
public constructor SomeClass()
|
||||
protected final val delegatedProperty: kotlin.String
|
||||
protected final var mutableProperty: kotlin.String
|
||||
public final val propertyWithCustomGetter: kotlin.Int
|
||||
protected final val simpleProperty: kotlin.String = "text"
|
||||
protected final val simplePropertyWithAnnotationList: kotlin.String = "text"
|
||||
@get:Ann public final fun annotationOnFunction(/*0*/ a: kotlin.Int): kotlin.Int
|
||||
public final fun annotationOnFunction(/*0*/ a: kotlin.Int): kotlin.Int
|
||||
public final fun anotherFun(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
|
||||
+5
-5
@@ -8,7 +8,7 @@ public final annotation class Ann : kotlin.Annotation {
|
||||
}
|
||||
|
||||
public final class PrimaryConstructorClass {
|
||||
public constructor PrimaryConstructorClass(/*0*/ @param:Ann a: kotlin.String, /*1*/ @param:Ann @param:Second b: kotlin.String, /*2*/ @param:Ann c: kotlin.String)
|
||||
public constructor PrimaryConstructorClass(/*0*/ a: kotlin.String, /*1*/ b: kotlin.String, /*2*/ @Ann c: kotlin.String)
|
||||
public final val c: kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
@@ -22,10 +22,10 @@ public final annotation class Second : kotlin.Annotation {
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
@param:Ann public final class SomeClass {
|
||||
@param:Ann public constructor SomeClass(/*0*/ @param:Ann a: kotlin.String)
|
||||
@param:Ann protected final val simpleProperty: kotlin.String = "text"
|
||||
@param:Ann public final fun anotherFun(): kotlin.Unit
|
||||
public final class SomeClass {
|
||||
public constructor SomeClass(/*0*/ a: kotlin.String)
|
||||
protected final val simpleProperty: kotlin.String = "text"
|
||||
public final fun anotherFun(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
+8
-8
@@ -22,14 +22,14 @@ public final annotation class Second : kotlin.Annotation {
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
@property:Ann public final class SomeClass {
|
||||
@property:Ann public constructor SomeClass(/*0*/ s: kotlin.String)
|
||||
@property:Ann protected final val p1: kotlin.String = ""
|
||||
@property:Ann @property:Second protected final val p2: kotlin.String = ""
|
||||
@property:Ann protected final var p3: kotlin.String
|
||||
@property:Ann protected final val p4: kotlin.String
|
||||
@property:Ann public final var propertyWithCustomSetter: kotlin.Int
|
||||
@property:Ann public final fun anotherFun(): kotlin.Unit
|
||||
public final class SomeClass {
|
||||
public constructor SomeClass(/*0*/ s: kotlin.String)
|
||||
@Ann protected final val p1: kotlin.String = ""
|
||||
@Ann @Second protected final val p2: kotlin.String = ""
|
||||
@Ann protected final var p3: kotlin.String
|
||||
@Ann protected final val p4: kotlin.String
|
||||
@Ann public final var propertyWithCustomSetter: kotlin.Int
|
||||
public final fun anotherFun(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
+4
-4
@@ -10,11 +10,11 @@ public final annotation class Ann : kotlin.Annotation {
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
@receiver:Ann public final class SomeClass {
|
||||
@receiver:Ann public constructor SomeClass(/*0*/ @receiver:Ann a: kotlin.String)
|
||||
@receiver:Ann protected final val simpleProperty: kotlin.String = "text"
|
||||
public final class SomeClass {
|
||||
public constructor SomeClass(/*0*/ a: kotlin.String)
|
||||
protected final val simpleProperty: kotlin.String = "text"
|
||||
public final val @receiver:Ann kotlin.String.extensionProperty2: kotlin.String
|
||||
@receiver:Ann public final fun anotherFun(): kotlin.Unit
|
||||
public final fun anotherFun(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
+3
-3
@@ -16,14 +16,14 @@ public final class CustomDelegate {
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
@set:Ann public final class SomeClass {
|
||||
public final class SomeClass {
|
||||
public constructor SomeClass()
|
||||
protected final var delegatedProperty: kotlin.String
|
||||
protected final var mutableProperty: kotlin.String
|
||||
protected final var mutablePropertyWithAnnotationList: kotlin.String
|
||||
public final var propertyWithCustomSetter: kotlin.Int
|
||||
@set:Ann protected final val simpleProperty: kotlin.String = "text"
|
||||
@set:Ann public final fun annotationOnFunction(/*0*/ a: kotlin.Int): kotlin.Int
|
||||
protected final val simpleProperty: kotlin.String = "text"
|
||||
public final fun annotationOnFunction(/*0*/ a: kotlin.Int): kotlin.Int
|
||||
public final fun anotherFun(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
|
||||
+4
-4
@@ -16,14 +16,14 @@ public final class CustomDelegate {
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
@setparam:Ann public final class SomeClass {
|
||||
@setparam:Ann public constructor SomeClass()
|
||||
public final class SomeClass {
|
||||
public constructor SomeClass()
|
||||
@setparam:Ann protected final var delegatedProperty: kotlin.String
|
||||
@setparam:Ann protected final var mutableProperty: kotlin.String
|
||||
@setparam:Ann protected final var mutablePropertyWithAnnotationList: kotlin.String
|
||||
@setparam:Ann public final var propertyWithCustomSetter: kotlin.Int
|
||||
@setparam:Ann protected final val simpleProperty: kotlin.String = "text"
|
||||
@setparam:Ann public final fun anotherFun(): kotlin.Unit
|
||||
protected final val simpleProperty: kotlin.String = "text"
|
||||
public final fun anotherFun(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
+3
-3
@@ -1,10 +1,10 @@
|
||||
package
|
||||
|
||||
package bar {
|
||||
@file:bar.foo public val prop: [ERROR : No type, no body]
|
||||
@file:bar.bar @file:bar.baz public fun func(): kotlin.Unit
|
||||
public val prop: [ERROR : No type, no body]
|
||||
public fun func(): kotlin.Unit
|
||||
|
||||
@file:bar.baz public final class C {
|
||||
public final class C {
|
||||
public constructor C()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
|
||||
Vendored
+1
-1
@@ -1,6 +1,6 @@
|
||||
package
|
||||
|
||||
@foo @bar @file:baz public fun test(): kotlin.Unit
|
||||
@foo @bar public fun test(): kotlin.Unit
|
||||
|
||||
public final annotation class bar : kotlin.Annotation {
|
||||
public constructor bar()
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package
|
||||
|
||||
@foo @bar @file:baz public fun test(): kotlin.Unit
|
||||
@foo @bar public fun test(): kotlin.Unit
|
||||
|
||||
public final annotation class bar : kotlin.Annotation {
|
||||
public constructor bar()
|
||||
|
||||
+4
-4
@@ -1,11 +1,11 @@
|
||||
package
|
||||
|
||||
public fun test1(/*0*/ @file:kotlin.Suppress(names = {""}) x: kotlin.Int): kotlin.Unit
|
||||
@file:kotlin.Suppress(names = {""}) public fun test2(): kotlin.Unit
|
||||
public fun @file:kotlin.Suppress(names = {""}) kotlin.Int.test3(): kotlin.Unit
|
||||
public fun test1(/*0*/ x: kotlin.Int): kotlin.Unit
|
||||
public fun test2(): kotlin.Unit
|
||||
public fun kotlin.Int.test3(): kotlin.Unit
|
||||
|
||||
public final class OnType {
|
||||
public constructor OnType(/*0*/ x: @file:kotlin.Suppress(names = {""}) kotlin.Int)
|
||||
public constructor OnType(/*0*/ x: kotlin.Int)
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
+4
-4
@@ -1,11 +1,11 @@
|
||||
package
|
||||
|
||||
public fun test1(/*0*/ @file:kotlin.Suppress(names = {""}) x: kotlin.Int): kotlin.Unit
|
||||
@file:kotlin.Suppress(names = {""}) public fun test2(): kotlin.Unit
|
||||
public fun @file:kotlin.Suppress(names = {""}) kotlin.Int.test3(): kotlin.Unit
|
||||
public fun test1(/*0*/ x: kotlin.Int): kotlin.Unit
|
||||
public fun test2(): kotlin.Unit
|
||||
public fun kotlin.Int.test3(): kotlin.Unit
|
||||
|
||||
public final class OnType {
|
||||
public constructor OnType(/*0*/ x: @file:kotlin.Suppress(names = {""}) kotlin.Int)
|
||||
public constructor OnType(/*0*/ x: kotlin.Int)
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package
|
||||
|
||||
public val @receiver:Fancy kotlin.Int.asVal: kotlin.Int
|
||||
public fun ((@receiver:Fancy kotlin.Int) -> kotlin.Unit).complexReceiver1(): kotlin.Unit
|
||||
public fun ((kotlin.Int) -> @receiver:Fancy kotlin.Unit).complexReceiver2(): kotlin.Unit
|
||||
public fun ((kotlin.Int) -> kotlin.Unit).complexReceiver1(): kotlin.Unit
|
||||
public fun ((kotlin.Int) -> kotlin.Unit).complexReceiver2(): kotlin.Unit
|
||||
public fun @receiver:Fancy kotlin.String.myExtension(): kotlin.Unit
|
||||
|
||||
@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.VALUE_PARAMETER}) public final annotation class Fancy : kotlin.Annotation {
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package
|
||||
|
||||
public val @receiver:Fancy kotlin.Int.asVal: kotlin.Int
|
||||
public fun ((@receiver:Fancy kotlin.Int) -> kotlin.Unit).complexReceiver1(): kotlin.Unit
|
||||
public fun ((kotlin.Int) -> @receiver:Fancy kotlin.Unit).complexReceiver2(): kotlin.Unit
|
||||
public fun ((kotlin.Int) -> kotlin.Unit).complexReceiver1(): kotlin.Unit
|
||||
public fun ((kotlin.Int) -> kotlin.Unit).complexReceiver2(): kotlin.Unit
|
||||
public fun @receiver:Fancy kotlin.String.myExtension(): kotlin.Unit
|
||||
|
||||
@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.VALUE_PARAMETER}) public final annotation class Fancy : kotlin.Annotation {
|
||||
|
||||
+9
-9
@@ -1,16 +1,16 @@
|
||||
package
|
||||
|
||||
public final class A {
|
||||
public constructor A(/*0*/ @param:Ann @Ann x: kotlin.Int, /*1*/ @param:RepeatableAnn @Ann y: kotlin.Int)
|
||||
@property:Ann @RepeatableAnn @property:RepeatableAnn @field:Ann public final val a: kotlin.Int = 0
|
||||
@Ann @property:Ann @field:Ann public final val b: kotlin.Int = 0
|
||||
public constructor A(/*0*/ @Ann @Ann x: kotlin.Int, /*1*/ @RepeatableAnn @Ann y: kotlin.Int)
|
||||
@Ann @RepeatableAnn @RepeatableAnn @field:Ann public final val a: kotlin.Int = 0
|
||||
@Ann @Ann @field:Ann public final val b: kotlin.Int = 0
|
||||
@field:RepeatableAnn @field:RepeatableAnn public final val c: kotlin.Int = 0
|
||||
@property:RepeatableAnn @RepeatableAnn public final val d: kotlin.Int = 0
|
||||
@property:RepeatableAnn @RepeatableAnn @delegate:RepeatableAnn public final val e: kotlin.String
|
||||
@property:Ann @delegate:Ann public final val f: kotlin.String
|
||||
@RepeatableAnn @RepeatableAnn public final val d: kotlin.Int = 0
|
||||
@RepeatableAnn @RepeatableAnn @delegate:RepeatableAnn public final val e: kotlin.String
|
||||
@Ann @delegate:Ann public final val f: kotlin.String
|
||||
@Ann @delegate:Ann public final val g: kotlin.String
|
||||
@Ann @field:Ann public final val h: kotlin.String = ""
|
||||
@property:Ann @field:Ann public final val i: kotlin.String = ""
|
||||
@Ann @field:Ann public final val i: kotlin.String = ""
|
||||
public final val x: kotlin.Int
|
||||
public final val y: kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
@@ -26,10 +26,10 @@ public final annotation class Ann : kotlin.Annotation {
|
||||
}
|
||||
|
||||
public final class B {
|
||||
public constructor B(/*0*/ @param:fieldOrPropAnn x: kotlin.Int, /*1*/ y: kotlin.Int)
|
||||
public constructor B(/*0*/ @fieldOrPropAnn x: kotlin.Int, /*1*/ y: kotlin.Int)
|
||||
@getSetAndParamAnn @setparam:getSetAndParamAnn public final var w: kotlin.Int
|
||||
@fieldOrPropAnn public final val x: kotlin.Int
|
||||
@property:fieldOrPropAnn @fieldOrPropAnn public final val y: kotlin.Int
|
||||
@fieldOrPropAnn @fieldOrPropAnn public final val y: kotlin.Int
|
||||
@fieldOrPropAnn @field:fieldOrPropAnn public final val z: kotlin.Int = 42
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
|
||||
+7
-7
@@ -1,9 +1,9 @@
|
||||
package
|
||||
|
||||
public fun test1(/*0*/ i: @setparam:kotlin.Suppress(names = {}) kotlin.Int): kotlin.Unit
|
||||
public fun test2(/*0*/ i: @param:kotlin.Suppress(names = {}) kotlin.Int): kotlin.Unit
|
||||
public fun test3(/*0*/ i: @receiver:kotlin.Suppress(names = {}) kotlin.Int): kotlin.Unit
|
||||
public fun test4(): @setparam:kotlin.Suppress(names = {}) kotlin.Int
|
||||
public fun test5(/*0*/ i: (@setparam:kotlin.Suppress(names = {}) kotlin.Int) -> kotlin.Unit): kotlin.Unit
|
||||
public fun test7(): (@setparam:kotlin.Suppress(names = {}) kotlin.Int) -> kotlin.Unit
|
||||
public fun ((@setparam:kotlin.Suppress(names = {}) kotlin.Int) -> kotlin.Unit).test6(): kotlin.Unit
|
||||
public fun test1(/*0*/ i: kotlin.Int): kotlin.Unit
|
||||
public fun test2(/*0*/ i: kotlin.Int): kotlin.Unit
|
||||
public fun test3(/*0*/ i: kotlin.Int): kotlin.Unit
|
||||
public fun test4(): kotlin.Int
|
||||
public fun test5(/*0*/ i: (kotlin.Int) -> kotlin.Unit): kotlin.Unit
|
||||
public fun test7(): (kotlin.Int) -> kotlin.Unit
|
||||
public fun ((kotlin.Int) -> kotlin.Unit).test6(): kotlin.Unit
|
||||
|
||||
+7
-7
@@ -1,9 +1,9 @@
|
||||
package
|
||||
|
||||
public fun test1(/*0*/ i: @setparam:kotlin.Suppress(names = {}) kotlin.Int): kotlin.Unit
|
||||
public fun test2(/*0*/ i: @param:kotlin.Suppress(names = {}) kotlin.Int): kotlin.Unit
|
||||
public fun test3(/*0*/ i: @receiver:kotlin.Suppress(names = {}) kotlin.Int): kotlin.Unit
|
||||
public fun test4(): @setparam:kotlin.Suppress(names = {}) kotlin.Int
|
||||
public fun test5(/*0*/ i: (@setparam:kotlin.Suppress(names = {}) kotlin.Int) -> kotlin.Unit): kotlin.Unit
|
||||
public fun test7(): (@setparam:kotlin.Suppress(names = {}) kotlin.Int) -> kotlin.Unit
|
||||
public fun ((@setparam:kotlin.Suppress(names = {}) kotlin.Int) -> kotlin.Unit).test6(): kotlin.Unit
|
||||
public fun test1(/*0*/ i: kotlin.Int): kotlin.Unit
|
||||
public fun test2(/*0*/ i: kotlin.Int): kotlin.Unit
|
||||
public fun test3(/*0*/ i: kotlin.Int): kotlin.Unit
|
||||
public fun test4(): kotlin.Int
|
||||
public fun test5(/*0*/ i: (kotlin.Int) -> kotlin.Unit): kotlin.Unit
|
||||
public fun test7(): (kotlin.Int) -> kotlin.Unit
|
||||
public fun ((kotlin.Int) -> kotlin.Unit).test6(): kotlin.Unit
|
||||
|
||||
+7
-7
@@ -1,9 +1,9 @@
|
||||
package
|
||||
|
||||
public fun test1(/*0*/ i: @setparam:kotlin.Suppress(names = {}) kotlin.Int): kotlin.Unit
|
||||
public fun test2(/*0*/ i: @param:kotlin.Suppress(names = {}) kotlin.Int): kotlin.Unit
|
||||
public fun test3(/*0*/ i: @receiver:kotlin.Suppress(names = {}) kotlin.Int): kotlin.Unit
|
||||
public fun test4(): @setparam:kotlin.Suppress(names = {}) kotlin.Int
|
||||
public fun test5(/*0*/ i: (@setparam:kotlin.Suppress(names = {}) kotlin.Int) -> kotlin.Unit): kotlin.Unit
|
||||
public fun test7(): (@setparam:kotlin.Suppress(names = {}) kotlin.Int) -> kotlin.Unit
|
||||
public fun ((@setparam:kotlin.Suppress(names = {}) kotlin.Int) -> kotlin.Unit).test6(): kotlin.Unit
|
||||
public fun test1(/*0*/ i: kotlin.Int): kotlin.Unit
|
||||
public fun test2(/*0*/ i: kotlin.Int): kotlin.Unit
|
||||
public fun test3(/*0*/ i: kotlin.Int): kotlin.Unit
|
||||
public fun test4(): kotlin.Int
|
||||
public fun test5(/*0*/ i: (kotlin.Int) -> kotlin.Unit): kotlin.Unit
|
||||
public fun test7(): (kotlin.Int) -> kotlin.Unit
|
||||
public fun ((kotlin.Int) -> kotlin.Unit).test6(): kotlin.Unit
|
||||
|
||||
@@ -10,7 +10,7 @@ package
|
||||
|
||||
public final class B : A {
|
||||
public constructor B(/*0*/ foo: kotlin.String)
|
||||
@property:kotlin.Deprecated private final val foo: kotlin.String
|
||||
@kotlin.Deprecated private final val foo: kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ fun getFoo(/*0*/ text: kotlin.String): kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ public fun literals(): kotlin.Unit
|
||||
public final class PropertyHolder {
|
||||
public constructor PropertyHolder()
|
||||
@kotlin.Deprecated(message = "") public final val a1: kotlin.Int = 1
|
||||
@property:kotlin.Deprecated(message = "") public final var a2: kotlin.String
|
||||
@kotlin.Deprecated(message = "") public final var a2: kotlin.String
|
||||
public final val withGetter: kotlin.String = ""
|
||||
public final var withSetter: kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@ package
|
||||
|
||||
package foo {
|
||||
@kotlin.js.JsName(name = "xx") public val foo.A.x: kotlin.Int
|
||||
@property:kotlin.js.JsName(name = "yy") public val foo.A.y: kotlin.Int
|
||||
@kotlin.js.JsName(name = "yy") public val foo.A.y: kotlin.Int
|
||||
|
||||
public final class A {
|
||||
public constructor A()
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ package
|
||||
|
||||
public final class A {
|
||||
public constructor A()
|
||||
@property:kotlin.js.JsName(name = "x_") public final val x: kotlin.Int = 0
|
||||
@kotlin.js.JsName(name = "x_") public final val x: kotlin.Int = 0
|
||||
public final var y: kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
|
||||
@@ -3,8 +3,8 @@ package
|
||||
public final class My {
|
||||
public constructor My()
|
||||
@field:kotlin.jvm.Volatile public final val w: kotlin.Int = 2
|
||||
@kotlin.jvm.Volatile public final val x: kotlin.Int = 0
|
||||
@kotlin.jvm.Volatile public final var y: kotlin.Int
|
||||
@field:kotlin.jvm.Volatile public final val x: kotlin.Int = 0
|
||||
@field:kotlin.jvm.Volatile public final var y: kotlin.Int
|
||||
@delegate:kotlin.jvm.Volatile public final var z: kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
interface Test {
|
||||
@get:JvmStatic
|
||||
val a: Int
|
||||
<!JVM_STATIC_NOT_IN_OBJECT_OR_CLASS_COMPANION!>@get:JvmStatic
|
||||
val a: Int<!>
|
||||
|
||||
<!INAPPLICABLE_JVM_NAME!>@get:JvmName("1")<!>
|
||||
val b: Int
|
||||
@@ -8,6 +8,6 @@ interface Test {
|
||||
<!SYNCHRONIZED_ON_ABSTRACT!>@get:Synchronized<!>
|
||||
val c: Int
|
||||
|
||||
<!WRONG_ANNOTATION_TARGET_WITH_USE_SITE_TARGET!>@get:JvmOverloads<!>
|
||||
<!OVERLOADS_INTERFACE, WRONG_ANNOTATION_TARGET_WITH_USE_SITE_TARGET!>@get:JvmOverloads<!>
|
||||
val d: Int
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -59,9 +59,9 @@ public final class Foo {
|
||||
}
|
||||
|
||||
private final class Other {
|
||||
public constructor Other(/*0*/ @param:Ann param: kotlin.Int)
|
||||
public constructor Other(/*0*/ @Ann param: kotlin.Int)
|
||||
@delegate:Ann private final val delegate: kotlin.String
|
||||
@property:Ann @field:Ann private final val other: kotlin.String = ""
|
||||
@Ann @field:Ann private final val other: kotlin.String = ""
|
||||
private final val param: kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
@@ -94,7 +94,7 @@ public final class Statics {
|
||||
|
||||
public companion object Companion {
|
||||
private constructor Companion()
|
||||
@kotlin.jvm.JvmField public final val x0: kotlin.String = ""
|
||||
@field:kotlin.jvm.JvmField public final val x0: kotlin.String = ""
|
||||
public const final val x1: kotlin.String = ""
|
||||
@kotlin.jvm.JvmStatic public final val x2: kotlin.String = ""
|
||||
@kotlin.jvm.JvmStatic private final val x3: kotlin.String = ""
|
||||
|
||||
compiler/testData/diagnostics/testsWithStdLib/annotations/jvmField/clashWithCompanionObjectField.txt
Vendored
+1
-1
@@ -2,7 +2,7 @@ package
|
||||
|
||||
public final class A {
|
||||
public constructor A()
|
||||
@kotlin.jvm.JvmField public final val clash: kotlin.Int = 1
|
||||
@field:kotlin.jvm.JvmField public final val clash: kotlin.Int = 1
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
+3
-3
@@ -1,11 +1,11 @@
|
||||
package
|
||||
|
||||
@kotlin.jvm.JvmField public val c: kotlin.Int = 4
|
||||
@kotlin.jvm.JvmField public var g: kotlin.Int
|
||||
@field:kotlin.jvm.JvmField public val c: kotlin.Int = 4
|
||||
@field:kotlin.jvm.JvmField public var g: kotlin.Int
|
||||
|
||||
public final class C {
|
||||
public constructor C()
|
||||
@kotlin.jvm.JvmField public final var g: kotlin.Int
|
||||
@field:kotlin.jvm.JvmField public final var g: kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
+3
-3
@@ -1,11 +1,11 @@
|
||||
package
|
||||
|
||||
@kotlin.jvm.JvmField public val c: kotlin.Int = 4
|
||||
@kotlin.jvm.JvmField public var g: kotlin.Int
|
||||
@field:kotlin.jvm.JvmField public val c: kotlin.Int = 4
|
||||
@field:kotlin.jvm.JvmField public var g: kotlin.Int
|
||||
|
||||
public final class C {
|
||||
public constructor C()
|
||||
@kotlin.jvm.JvmField public final var g: kotlin.Int
|
||||
@field:kotlin.jvm.JvmField public final var g: kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
+9
-9
@@ -7,7 +7,7 @@ public interface A {
|
||||
|
||||
public companion object Companion {
|
||||
private constructor Companion()
|
||||
@kotlin.jvm.JvmField public final val c: kotlin.Int = 3
|
||||
@field:kotlin.jvm.JvmField public final val c: kotlin.Int = 3
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
@@ -21,8 +21,8 @@ public interface B {
|
||||
|
||||
public companion object Companion {
|
||||
private constructor Companion()
|
||||
@kotlin.jvm.JvmField public final val a: kotlin.Int = 3
|
||||
@kotlin.jvm.JvmField public final val c: kotlin.Int = 3
|
||||
@field:kotlin.jvm.JvmField public final val a: kotlin.Int = 3
|
||||
@field:kotlin.jvm.JvmField public final val c: kotlin.Int = 3
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
@@ -37,7 +37,7 @@ public interface C {
|
||||
public companion object Companion {
|
||||
private constructor Companion()
|
||||
public final val a: kotlin.Int = 3
|
||||
@kotlin.jvm.JvmField public final val c: kotlin.Int = 3
|
||||
@field:kotlin.jvm.JvmField public final val c: kotlin.Int = 3
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
@@ -51,7 +51,7 @@ public interface D {
|
||||
|
||||
public companion object Companion {
|
||||
private constructor Companion()
|
||||
@kotlin.jvm.JvmField public final var c: kotlin.Int
|
||||
@field:kotlin.jvm.JvmField public final var c: kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
@@ -65,9 +65,9 @@ public interface E {
|
||||
|
||||
public companion object Companion {
|
||||
private constructor Companion()
|
||||
@kotlin.jvm.JvmField private final val a: kotlin.Int = 3
|
||||
@kotlin.jvm.JvmField internal final val b: kotlin.Int = 3
|
||||
@kotlin.jvm.JvmField protected final val c: kotlin.Int = 3
|
||||
@field:kotlin.jvm.JvmField private final val a: kotlin.Int = 3
|
||||
@field:kotlin.jvm.JvmField internal final val b: kotlin.Int = 3
|
||||
@field:kotlin.jvm.JvmField protected final val c: kotlin.Int = 3
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
@@ -81,7 +81,7 @@ public interface F {
|
||||
|
||||
public companion object Companion {
|
||||
private constructor Companion()
|
||||
@kotlin.jvm.JvmField public open val a: kotlin.Int = 3
|
||||
@field:kotlin.jvm.JvmField public open val a: kotlin.Int = 3
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
Vendored
+1
-1
@@ -17,7 +17,7 @@ abstract class C : I{
|
||||
<!WRONG_ANNOTATION_TARGET!>@kotlin.jvm.JvmField<!> private fun foo(s: String = "OK") {
|
||||
}
|
||||
|
||||
<!INAPPLICABLE_JVM_FIELD, WRONG_ANNOTATION_TARGET!>@JvmField<!> val a: String by lazy { "A" }
|
||||
<!WRONG_ANNOTATION_TARGET!>@JvmField<!> val a: String by lazy { "A" }
|
||||
|
||||
<!INAPPLICABLE_JVM_FIELD!>@JvmField<!> open val b: Int = 3
|
||||
|
||||
|
||||
Vendored
+21
-21
@@ -1,25 +1,25 @@
|
||||
package
|
||||
|
||||
@kotlin.jvm.JvmField public const val Const: kotlin.Int = 4
|
||||
@kotlin.jvm.JvmField public var i: kotlin.Int
|
||||
@kotlin.jvm.JvmField private val private: kotlin.Int = 3
|
||||
@field:kotlin.jvm.JvmField public const val Const: kotlin.Int = 4
|
||||
@field:kotlin.jvm.JvmField public var i: kotlin.Int
|
||||
@field:kotlin.jvm.JvmField private val private: kotlin.Int = 3
|
||||
@kotlin.jvm.JvmField public fun foo(): kotlin.Unit
|
||||
|
||||
@kotlin.jvm.JvmField public abstract class C : I {
|
||||
@kotlin.jvm.JvmField public constructor C(/*0*/ s: kotlin.String)
|
||||
@kotlin.jvm.JvmField public final val a: kotlin.String
|
||||
@kotlin.jvm.JvmField public final override /*1*/ val ai: kotlin.Int = 3
|
||||
@kotlin.jvm.JvmField public open val b: kotlin.Int = 3
|
||||
@field:kotlin.jvm.JvmField public final override /*1*/ val ai: kotlin.Int = 3
|
||||
@field:kotlin.jvm.JvmField public open val b: kotlin.Int = 3
|
||||
@kotlin.jvm.JvmField public open override /*1*/ /*fake_override*/ val bi: kotlin.Int
|
||||
@kotlin.jvm.JvmField public abstract val c: kotlin.Int
|
||||
@kotlin.jvm.JvmField public final val customGetter: kotlin.String = ""
|
||||
@kotlin.jvm.JvmField public final var customSetter: kotlin.String
|
||||
@kotlin.jvm.JvmField public final val explicitDefaultAnnotatedGetter: kotlin.String = ""
|
||||
@kotlin.jvm.JvmField public final var explicitDefaultAnnotatedSetter: kotlin.String
|
||||
@kotlin.jvm.JvmField public final val explicitDefaultGetter: kotlin.String = ""
|
||||
@kotlin.jvm.JvmField public final var explicitDefaultSetter: kotlin.String
|
||||
@field:kotlin.jvm.JvmField public final val customGetter: kotlin.String = ""
|
||||
@field:kotlin.jvm.JvmField public final var customSetter: kotlin.String
|
||||
@field:kotlin.jvm.JvmField public final val explicitDefaultAnnotatedGetter: kotlin.String = ""
|
||||
@field:kotlin.jvm.JvmField public final var explicitDefaultAnnotatedSetter: kotlin.String
|
||||
@field:kotlin.jvm.JvmField public final val explicitDefaultGetter: kotlin.String = ""
|
||||
@field:kotlin.jvm.JvmField public final var explicitDefaultSetter: kotlin.String
|
||||
@kotlin.jvm.JvmField public final val noBackingField: kotlin.String
|
||||
@kotlin.jvm.JvmField private final val private: kotlin.Int = 3
|
||||
@field:kotlin.jvm.JvmField private final val private: kotlin.Int = 3
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
@kotlin.jvm.JvmField private final fun foo(/*0*/ s: kotlin.String = ...): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
@@ -35,7 +35,7 @@ public final annotation class DemoAnnotation : kotlin.Annotation {
|
||||
|
||||
public final class G {
|
||||
public constructor G()
|
||||
@kotlin.jvm.JvmField public final lateinit var lateInit: kotlin.String
|
||||
@field:kotlin.jvm.JvmField public final lateinit var lateInit: kotlin.String
|
||||
@delegate:kotlin.jvm.JvmField public final val s: kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
@@ -50,7 +50,7 @@ public final class H {
|
||||
|
||||
public companion object Companion {
|
||||
private constructor Companion()
|
||||
@kotlin.jvm.JvmField public final var c: kotlin.Int
|
||||
@field:kotlin.jvm.JvmField public final var c: kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
@@ -74,7 +74,7 @@ public interface K {
|
||||
|
||||
public companion object Companion {
|
||||
private constructor Companion()
|
||||
@kotlin.jvm.JvmField public final var c: kotlin.Int
|
||||
@field:kotlin.jvm.JvmField public final var c: kotlin.Int
|
||||
public final var x: kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
@@ -84,8 +84,8 @@ public interface K {
|
||||
|
||||
public final class KK : K {
|
||||
public constructor KK()
|
||||
@kotlin.jvm.JvmField public open override /*1*/ val i: kotlin.Int = 0
|
||||
@kotlin.jvm.JvmField public final override /*1*/ val j: kotlin.Int = 0
|
||||
@field:kotlin.jvm.JvmField public open override /*1*/ val i: kotlin.Int = 0
|
||||
@field:kotlin.jvm.JvmField public final override /*1*/ val j: kotlin.Int = 0
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
@@ -93,8 +93,8 @@ public final class KK : K {
|
||||
|
||||
public open class KKK : K {
|
||||
public constructor KKK()
|
||||
@kotlin.jvm.JvmField public open override /*1*/ val i: kotlin.Int = 0
|
||||
@kotlin.jvm.JvmField public final override /*1*/ val j: kotlin.Int = 0
|
||||
@field:kotlin.jvm.JvmField public open override /*1*/ val i: kotlin.Int = 0
|
||||
@field:kotlin.jvm.JvmField public final override /*1*/ val j: kotlin.Int = 0
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
@@ -108,7 +108,7 @@ public final annotation class L : kotlin.Annotation {
|
||||
|
||||
public companion object Companion {
|
||||
private constructor Companion()
|
||||
@kotlin.jvm.JvmField public final var c: kotlin.Int
|
||||
@field:kotlin.jvm.JvmField public final var c: kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
@@ -117,7 +117,7 @@ public final annotation class L : kotlin.Annotation {
|
||||
|
||||
public object O {
|
||||
private constructor O()
|
||||
@kotlin.jvm.JvmField public final val c: kotlin.Int = 3
|
||||
@field:kotlin.jvm.JvmField public final val c: kotlin.Int = 3
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
Vendored
+2
-2
@@ -8,7 +8,7 @@ public final class A {
|
||||
|
||||
public companion object Companion {
|
||||
private constructor Companion()
|
||||
@kotlin.jvm.JvmStatic @kotlin.jvm.JvmField public final val x: kotlin.Int = 1
|
||||
@kotlin.jvm.JvmStatic @field:kotlin.jvm.JvmField public final val x: kotlin.Int = 1
|
||||
@kotlin.jvm.JvmStatic public const final val z: kotlin.Int = 1
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
@@ -18,7 +18,7 @@ public final class A {
|
||||
|
||||
public object B {
|
||||
private constructor B()
|
||||
@kotlin.jvm.JvmStatic @kotlin.jvm.JvmField public final val x: kotlin.Int = 1
|
||||
@kotlin.jvm.JvmStatic @field:kotlin.jvm.JvmField public final val x: kotlin.Int = 1
|
||||
@kotlin.jvm.JvmStatic public const final val z: kotlin.Int = 1
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
|
||||
@@ -7,19 +7,12 @@ package org.jetbrains.kotlin.load.java;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.builtins.CompanionObjectMapping;
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationWithTarget;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.name.ClassId;
|
||||
import org.jetbrains.kotlin.name.FqName;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.util.capitalizeDecapitalize.CapitalizeDecapitalizeKt;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.kotlin.resolve.DescriptorUtils.isClassOrEnumClass;
|
||||
import static org.jetbrains.kotlin.resolve.DescriptorUtils.isCompanionObject;
|
||||
|
||||
@@ -120,12 +113,10 @@ public final class JvmAbi {
|
||||
}
|
||||
|
||||
public static boolean hasJvmFieldAnnotation(@NotNull CallableMemberDescriptor memberDescriptor) {
|
||||
List<AnnotationWithTarget> annotations = memberDescriptor.getAnnotations().getUseSiteTargetedAnnotations();
|
||||
for (AnnotationWithTarget annotationWithTarget : annotations) {
|
||||
if (AnnotationUseSiteTarget.FIELD.equals(annotationWithTarget.getTarget()) &&
|
||||
JVM_FIELD_ANNOTATION_FQ_NAME.equals(annotationWithTarget.getAnnotation().getFqName())) {
|
||||
return true;
|
||||
}
|
||||
// TODO: deduplicate this with org.jetbrains.kotlin.resolve.jvm.annotations.hasJvmFieldAnnotation
|
||||
if (memberDescriptor instanceof PropertyDescriptor) {
|
||||
FieldDescriptor field = ((PropertyDescriptor) memberDescriptor).getBackingField();
|
||||
if (field != null && field.getAnnotations().hasAnnotation(JVM_FIELD_ANNOTATION_FQ_NAME)) return true;
|
||||
}
|
||||
return memberDescriptor.getAnnotations().hasAnnotation(JVM_FIELD_ANNOTATION_FQ_NAME);
|
||||
}
|
||||
|
||||
+1
-1
@@ -131,7 +131,7 @@ public class JavaPropertyDescriptor extends PropertyDescriptorImpl implements Ja
|
||||
newSetter.initialize(setter.getValueParameters().get(0));
|
||||
}
|
||||
|
||||
enhanced.initialize(newGetter, newSetter);
|
||||
enhanced.initialize(newGetter, newSetter, getBackingField(), getDelegateField());
|
||||
enhanced.setSetterProjectedOut(isSetterProjectedOut());
|
||||
if (compileTimeInitializer != null) {
|
||||
enhanced.setCompileTimeInitializer(compileTimeInitializer);
|
||||
|
||||
+2
-1
@@ -271,7 +271,8 @@ abstract class LazyJavaScope(protected val c: LazyJavaResolverContext) : MemberS
|
||||
|
||||
private fun resolveProperty(field: JavaField): PropertyDescriptor {
|
||||
val propertyDescriptor = createPropertyDescriptor(field)
|
||||
propertyDescriptor.initialize(null, null)
|
||||
// Annotations on Java fields are loaded as property annotations, therefore backingField = null below
|
||||
propertyDescriptor.initialize(null, null, null, null)
|
||||
|
||||
val propertyType = getPropertyType(field)
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.descriptors
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotated
|
||||
|
||||
interface FieldDescriptor : Annotated {
|
||||
val correspondingProperty: PropertyDescriptor
|
||||
}
|
||||
@@ -18,7 +18,6 @@ package org.jetbrains.kotlin.descriptors;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.types.TypeSubstitution;
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -54,6 +53,12 @@ public interface PropertyDescriptor extends VariableDescriptorWithAccessors, Cal
|
||||
@Override
|
||||
Collection<? extends PropertyDescriptor> getOverriddenDescriptors();
|
||||
|
||||
@Nullable
|
||||
FieldDescriptor getBackingField();
|
||||
|
||||
@Nullable
|
||||
FieldDescriptor getDelegateField();
|
||||
|
||||
@Override
|
||||
PropertyDescriptor substitute(@NotNull TypeSubstitutor substitutor);
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.descriptors.impl
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.FieldDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotatedImpl
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
|
||||
class FieldDescriptorImpl(
|
||||
annotations: Annotations,
|
||||
override val correspondingProperty: PropertyDescriptor
|
||||
) : FieldDescriptor, AnnotatedImpl(annotations)
|
||||
+35
-2
@@ -53,6 +53,8 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
|
||||
private PropertyGetterDescriptorImpl getter;
|
||||
private PropertySetterDescriptor setter;
|
||||
private boolean setterProjectedOut;
|
||||
private FieldDescriptor backingField;
|
||||
private FieldDescriptor delegateField;
|
||||
|
||||
protected PropertyDescriptorImpl(
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@@ -120,9 +122,23 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
|
||||
this.dispatchReceiverParameter = dispatchReceiverParameter;
|
||||
}
|
||||
|
||||
public void initialize(@Nullable PropertyGetterDescriptorImpl getter, @Nullable PropertySetterDescriptor setter) {
|
||||
public void initialize(
|
||||
@Nullable PropertyGetterDescriptorImpl getter,
|
||||
@Nullable PropertySetterDescriptor setter
|
||||
) {
|
||||
initialize(getter, setter, null, null);
|
||||
}
|
||||
|
||||
public void initialize(
|
||||
@Nullable PropertyGetterDescriptorImpl getter,
|
||||
@Nullable PropertySetterDescriptor setter,
|
||||
@Nullable FieldDescriptor backingField,
|
||||
@Nullable FieldDescriptor delegateField
|
||||
) {
|
||||
this.getter = getter;
|
||||
this.setter = setter;
|
||||
this.backingField = backingField;
|
||||
this.delegateField = delegateField;
|
||||
}
|
||||
|
||||
public void setSetterProjectedOut(boolean setterProjectedOut) {
|
||||
@@ -413,7 +429,12 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
|
||||
newSetter.initialize(substitutedValueParameters.get(0));
|
||||
}
|
||||
|
||||
substitutedDescriptor.initialize(newGetter, newSetter);
|
||||
substitutedDescriptor.initialize(
|
||||
newGetter,
|
||||
newSetter,
|
||||
backingField == null ? null : new FieldDescriptorImpl(backingField.getAnnotations(), substitutedDescriptor),
|
||||
delegateField == null ? null : new FieldDescriptorImpl(delegateField.getAnnotations(), substitutedDescriptor)
|
||||
);
|
||||
|
||||
if (copyConfiguration.copyOverrides) {
|
||||
Collection<CallableMemberDescriptor> overridden = SmartSet.create();
|
||||
@@ -488,6 +509,18 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
|
||||
return isActual;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public FieldDescriptor getBackingField() {
|
||||
return backingField;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public FieldDescriptor getDelegateField() {
|
||||
return delegateField;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOverriddenDescriptors(@NotNull Collection<? extends CallableMemberDescriptor> overriddenDescriptors) {
|
||||
//noinspection unchecked
|
||||
|
||||
@@ -399,13 +399,13 @@ internal class DescriptorRendererImpl(
|
||||
}
|
||||
}
|
||||
|
||||
private fun StringBuilder.renderAnnotations(annotated: Annotated) {
|
||||
private fun StringBuilder.renderAnnotations(annotated: Annotated, target: AnnotationUseSiteTarget? = null) {
|
||||
if (DescriptorRendererModifier.ANNOTATIONS !in modifiers) return
|
||||
|
||||
val excluded = if (annotated is KotlinType) excludedTypeAnnotationClasses else excludedAnnotationClasses
|
||||
|
||||
val annotationFilter = annotationFilter
|
||||
for ((annotation, target) in annotated.annotations.getAllAnnotations()) {
|
||||
for (annotation in annotated.annotations) {
|
||||
if (annotation.fqName !in excluded && (annotationFilter == null || annotationFilter(annotation))) {
|
||||
append(renderAnnotation(annotation, target))
|
||||
if (eachAnnotationOnNewLine) {
|
||||
@@ -685,6 +685,8 @@ internal class DescriptorRendererImpl(
|
||||
private fun renderReceiver(callableDescriptor: CallableDescriptor, builder: StringBuilder) {
|
||||
val receiver = callableDescriptor.extensionReceiverParameter
|
||||
if (receiver != null) {
|
||||
builder.renderAnnotations(receiver, AnnotationUseSiteTarget.RECEIVER)
|
||||
|
||||
val type = receiver.type
|
||||
var result = renderType(type)
|
||||
if (shouldRenderAsPrettyFunctionType(type) && !TypeUtils.isNullableType(type)) {
|
||||
@@ -817,7 +819,7 @@ internal class DescriptorRendererImpl(
|
||||
private fun renderProperty(property: PropertyDescriptor, builder: StringBuilder) {
|
||||
if (!startFromName) {
|
||||
if (!startFromDeclarationKeyword) {
|
||||
builder.renderAnnotations(property)
|
||||
renderPropertyAnnotations(property, builder)
|
||||
renderVisibility(property.visibility, builder)
|
||||
renderModifier(builder, property.isConst, "const")
|
||||
renderMemberModifiers(property, builder)
|
||||
@@ -841,6 +843,21 @@ internal class DescriptorRendererImpl(
|
||||
renderWhereSuffix(property.typeParameters, builder)
|
||||
}
|
||||
|
||||
private fun renderPropertyAnnotations(property: PropertyDescriptor, builder: StringBuilder) {
|
||||
if (DescriptorRendererModifier.ANNOTATIONS !in modifiers) return
|
||||
|
||||
builder.renderAnnotations(property)
|
||||
|
||||
property.backingField?.let { builder.renderAnnotations(it, AnnotationUseSiteTarget.FIELD) }
|
||||
property.delegateField?.let { builder.renderAnnotations(it, AnnotationUseSiteTarget.PROPERTY_DELEGATE_FIELD) }
|
||||
|
||||
if (propertyAccessorRenderingPolicy == PropertyAccessorRenderingPolicy.NONE) {
|
||||
property.setter?.valueParameters?.single()?.let {
|
||||
builder.renderAnnotations(it, AnnotationUseSiteTarget.SETTER_PARAMETER)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun renderInitializer(variable: VariableDescriptor, builder: StringBuilder) {
|
||||
if (includePropertyConstant) {
|
||||
variable.compileTimeInitializer?.let { constant ->
|
||||
|
||||
+18
-2
@@ -7,8 +7,10 @@ package org.jetbrains.kotlin.serialization.deserialization
|
||||
|
||||
import org.jetbrains.kotlin.builtins.isSuspendFunctionType
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationsImpl
|
||||
import org.jetbrains.kotlin.descriptors.impl.FieldDescriptorImpl
|
||||
import org.jetbrains.kotlin.descriptors.impl.PropertyGetterDescriptorImpl
|
||||
import org.jetbrains.kotlin.descriptors.impl.PropertySetterDescriptorImpl
|
||||
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl
|
||||
@@ -29,9 +31,11 @@ class MemberDeserializer(private val c: DeserializationContext) {
|
||||
fun loadProperty(proto: ProtoBuf.Property): PropertyDescriptor {
|
||||
val flags = if (proto.hasFlags()) proto.flags else loadOldFlags(proto.oldFlags)
|
||||
|
||||
val propertyAnnotations = getAnnotations(proto, flags, AnnotatedCallableKind.PROPERTY)
|
||||
|
||||
val property = DeserializedPropertyDescriptor(
|
||||
c.containingDeclaration, null,
|
||||
getAnnotations(proto, flags, AnnotatedCallableKind.PROPERTY),
|
||||
propertyAnnotations,
|
||||
ProtoEnumFlags.modality(Flags.MODALITY.get(flags)),
|
||||
ProtoEnumFlags.visibility(Flags.VISIBILITY.get(flags)),
|
||||
Flags.IS_VAR.get(flags),
|
||||
@@ -134,7 +138,19 @@ class MemberDeserializer(private val c: DeserializationContext) {
|
||||
)
|
||||
}
|
||||
|
||||
property.initialize(getter, setter, property.checkExperimentalCoroutine(local.typeDeserializer))
|
||||
// TODO: add needed methods to AnnotationAndConstantLoader
|
||||
val fieldAnnotations = DeserializedAnnotations(c.storageManager) {
|
||||
propertyAnnotations.getUseSiteTargetedAnnotations()
|
||||
.filter { it.target == AnnotationUseSiteTarget.FIELD }.map { it.annotation }
|
||||
}
|
||||
val delegateAnnotations = DeserializedAnnotations(c.storageManager) {
|
||||
propertyAnnotations.getUseSiteTargetedAnnotations()
|
||||
.filter { it.target == AnnotationUseSiteTarget.PROPERTY_DELEGATE_FIELD }.map { it.annotation }
|
||||
}
|
||||
property.initialize(
|
||||
getter, setter, FieldDescriptorImpl(fieldAnnotations, property), FieldDescriptorImpl(delegateAnnotations, property),
|
||||
property.checkExperimentalCoroutine(local.typeDeserializer)
|
||||
)
|
||||
|
||||
return property
|
||||
}
|
||||
|
||||
+3
-1
@@ -146,9 +146,11 @@ class DeserializedPropertyDescriptor(
|
||||
fun initialize(
|
||||
getter: PropertyGetterDescriptorImpl?,
|
||||
setter: PropertySetterDescriptor?,
|
||||
backingField: FieldDescriptor?,
|
||||
delegateField: FieldDescriptor?,
|
||||
isExperimentalCoroutineInReleaseEnvironment: DeserializedMemberDescriptor.CoroutinesCompatibilityMode
|
||||
) {
|
||||
super.initialize(getter, setter)
|
||||
super.initialize(getter, setter, backingField, delegateField)
|
||||
.also { this.coroutinesExperimentalCompatibilityMode = isExperimentalCoroutineInReleaseEnvironment }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user