diff --git a/libraries/kotlinx-metadata/jvm/api/kotlin-metadata-jvm.api b/libraries/kotlinx-metadata/jvm/api/kotlin-metadata-jvm.api index 4839dce47bf..d53a8e15482 100644 --- a/libraries/kotlinx-metadata/jvm/api/kotlin-metadata-jvm.api +++ b/libraries/kotlinx-metadata/jvm/api/kotlin-metadata-jvm.api @@ -9,10 +9,8 @@ public final class kotlin/metadata/Attributes { public static final fun getHasAnnotations (Lkotlin/metadata/KmValueParameter;)Z public static final fun getHasConstant (Lkotlin/metadata/KmProperty;)Z public static final fun getHasEnumEntries (Lkotlin/metadata/KmClass;)Z - public static final fun getHasGetter (Lkotlin/metadata/KmProperty;)Z public static final fun getHasNonStableParameterNames (Lkotlin/metadata/KmConstructor;)Z public static final fun getHasNonStableParameterNames (Lkotlin/metadata/KmFunction;)Z - public static final fun getHasSetter (Lkotlin/metadata/KmProperty;)Z public static final fun getKind (Lkotlin/metadata/KmClass;)Lkotlin/metadata/ClassKind; public static final fun getKind (Lkotlin/metadata/KmFunction;)Lkotlin/metadata/MemberKind; public static final fun getKind (Lkotlin/metadata/KmProperty;)Lkotlin/metadata/MemberKind; @@ -80,10 +78,8 @@ public final class kotlin/metadata/Attributes { public static final fun setHasAnnotations (Lkotlin/metadata/KmValueParameter;Z)V public static final fun setHasConstant (Lkotlin/metadata/KmProperty;Z)V public static final fun setHasEnumEntries (Lkotlin/metadata/KmClass;Z)V - public static final fun setHasGetter (Lkotlin/metadata/KmProperty;Z)V public static final fun setHasNonStableParameterNames (Lkotlin/metadata/KmConstructor;Z)V public static final fun setHasNonStableParameterNames (Lkotlin/metadata/KmFunction;Z)V - public static final fun setHasSetter (Lkotlin/metadata/KmProperty;Z)V public static final fun setInfix (Lkotlin/metadata/KmFunction;Z)V public static final fun setInline (Lkotlin/metadata/KmFunction;Z)V public static final fun setInline (Lkotlin/metadata/KmPropertyAccessorAttributes;Z)V @@ -131,128 +127,12 @@ public final class kotlin/metadata/ClassKind : java/lang/Enum { } public final class kotlin/metadata/ClassNameKt { - public static final fun isLocal (Ljava/lang/String;)Z public static final fun isLocalClassName (Ljava/lang/String;)Z } public abstract interface annotation class kotlin/metadata/ExperimentalContextReceivers : java/lang/annotation/Annotation { } -public final class kotlin/metadata/Flag { - public static final field Common Lkotlin/metadata/Flag$Common; - public static final field HAS_ANNOTATIONS Lkotlin/metadata/Flag; - public static final field IS_ABSTRACT Lkotlin/metadata/Flag; - public static final field IS_FINAL Lkotlin/metadata/Flag; - public static final field IS_INTERNAL Lkotlin/metadata/Flag; - public static final field IS_LOCAL Lkotlin/metadata/Flag; - public static final field IS_OPEN Lkotlin/metadata/Flag; - public static final field IS_PRIVATE Lkotlin/metadata/Flag; - public static final field IS_PRIVATE_TO_THIS Lkotlin/metadata/Flag; - public static final field IS_PROTECTED Lkotlin/metadata/Flag; - public static final field IS_PUBLIC Lkotlin/metadata/Flag; - public static final field IS_SEALED Lkotlin/metadata/Flag; - public fun (III)V - public final fun invoke (I)Z -} - -public final class kotlin/metadata/Flag$Class { - public static final field HAS_ENUM_ENTRIES Lkotlin/metadata/Flag; - public static final field INSTANCE Lkotlin/metadata/Flag$Class; - public static final field IS_ANNOTATION_CLASS Lkotlin/metadata/Flag; - public static final field IS_CLASS Lkotlin/metadata/Flag; - public static final field IS_COMPANION_OBJECT Lkotlin/metadata/Flag; - public static final field IS_DATA Lkotlin/metadata/Flag; - public static final field IS_ENUM_CLASS Lkotlin/metadata/Flag; - public static final field IS_ENUM_ENTRY Lkotlin/metadata/Flag; - public static final field IS_EXPECT Lkotlin/metadata/Flag; - public static final field IS_EXTERNAL Lkotlin/metadata/Flag; - public static final field IS_FUN Lkotlin/metadata/Flag; - public static final field IS_INLINE Lkotlin/metadata/Flag; - public static final field IS_INNER Lkotlin/metadata/Flag; - public static final field IS_INTERFACE Lkotlin/metadata/Flag; - public static final field IS_OBJECT Lkotlin/metadata/Flag; - public static final field IS_VALUE Lkotlin/metadata/Flag; -} - -public final class kotlin/metadata/Flag$Common { -} - -public final class kotlin/metadata/Flag$Constructor { - public static final field HAS_NON_STABLE_PARAMETER_NAMES Lkotlin/metadata/Flag; - public static final field INSTANCE Lkotlin/metadata/Flag$Constructor; - public static final field IS_PRIMARY Lkotlin/metadata/Flag; - public static final field IS_SECONDARY Lkotlin/metadata/Flag; -} - -public final class kotlin/metadata/Flag$EffectExpression { - public static final field INSTANCE Lkotlin/metadata/Flag$EffectExpression; - public static final field IS_NEGATED Lkotlin/metadata/Flag; - public static final field IS_NULL_CHECK_PREDICATE Lkotlin/metadata/Flag; -} - -public final class kotlin/metadata/Flag$Function { - public static final field HAS_NON_STABLE_PARAMETER_NAMES Lkotlin/metadata/Flag; - public static final field INSTANCE Lkotlin/metadata/Flag$Function; - public static final field IS_DECLARATION Lkotlin/metadata/Flag; - public static final field IS_DELEGATION Lkotlin/metadata/Flag; - public static final field IS_EXPECT Lkotlin/metadata/Flag; - public static final field IS_EXTERNAL Lkotlin/metadata/Flag; - public static final field IS_FAKE_OVERRIDE Lkotlin/metadata/Flag; - public static final field IS_INFIX Lkotlin/metadata/Flag; - public static final field IS_INLINE Lkotlin/metadata/Flag; - public static final field IS_OPERATOR Lkotlin/metadata/Flag; - public static final field IS_SUSPEND Lkotlin/metadata/Flag; - public static final field IS_SYNTHESIZED Lkotlin/metadata/Flag; - public static final field IS_TAILREC Lkotlin/metadata/Flag; -} - -public final class kotlin/metadata/Flag$Property { - public static final field HAS_CONSTANT Lkotlin/metadata/Flag; - public static final field HAS_GETTER Lkotlin/metadata/Flag; - public static final field HAS_SETTER Lkotlin/metadata/Flag; - public static final field INSTANCE Lkotlin/metadata/Flag$Property; - public static final field IS_CONST Lkotlin/metadata/Flag; - public static final field IS_DECLARATION Lkotlin/metadata/Flag; - public static final field IS_DELEGATED Lkotlin/metadata/Flag; - public static final field IS_DELEGATION Lkotlin/metadata/Flag; - public static final field IS_EXPECT Lkotlin/metadata/Flag; - public static final field IS_EXTERNAL Lkotlin/metadata/Flag; - public static final field IS_FAKE_OVERRIDE Lkotlin/metadata/Flag; - public static final field IS_LATEINIT Lkotlin/metadata/Flag; - public static final field IS_SYNTHESIZED Lkotlin/metadata/Flag; - public static final field IS_VAR Lkotlin/metadata/Flag; -} - -public final class kotlin/metadata/Flag$PropertyAccessor { - public static final field INSTANCE Lkotlin/metadata/Flag$PropertyAccessor; - public static final field IS_EXTERNAL Lkotlin/metadata/Flag; - public static final field IS_INLINE Lkotlin/metadata/Flag; - public static final field IS_NOT_DEFAULT Lkotlin/metadata/Flag; -} - -public final class kotlin/metadata/Flag$Type { - public static final field INSTANCE Lkotlin/metadata/Flag$Type; - public static final field IS_DEFINITELY_NON_NULL Lkotlin/metadata/Flag; - public static final field IS_NULLABLE Lkotlin/metadata/Flag; - public static final field IS_SUSPEND Lkotlin/metadata/Flag; -} - -public final class kotlin/metadata/Flag$TypeParameter { - public static final field INSTANCE Lkotlin/metadata/Flag$TypeParameter; - public static final field IS_REIFIED Lkotlin/metadata/Flag; -} - -public final class kotlin/metadata/Flag$ValueParameter { - public static final field DECLARES_DEFAULT_VALUE Lkotlin/metadata/Flag; - public static final field INSTANCE Lkotlin/metadata/Flag$ValueParameter; - public static final field IS_CROSSINLINE Lkotlin/metadata/Flag; - public static final field IS_NOINLINE Lkotlin/metadata/Flag; -} - -public final class kotlin/metadata/FlagsKt { - public static final fun flagsOf ([Lkotlin/metadata/Flag;)I -} - public final class kotlin/metadata/KmAnnotation { public fun (Ljava/lang/String;Ljava/util/Map;)V public fun equals (Ljava/lang/Object;)Z @@ -382,13 +262,10 @@ public final class kotlin/metadata/KmAnnotationArgument$IntValue : kotlin/metada public final class kotlin/metadata/KmAnnotationArgument$KClassValue : kotlin/metadata/KmAnnotationArgument { public fun (Ljava/lang/String;)V - public fun (Ljava/lang/String;I)V public final fun component1 ()Ljava/lang/String; - public final fun component2 ()I - public final fun copy (Ljava/lang/String;I)Lkotlin/metadata/KmAnnotationArgument$KClassValue; - public static synthetic fun copy$default (Lkotlin/metadata/KmAnnotationArgument$KClassValue;Ljava/lang/String;IILjava/lang/Object;)Lkotlin/metadata/KmAnnotationArgument$KClassValue; + public final fun copy (Ljava/lang/String;)Lkotlin/metadata/KmAnnotationArgument$KClassValue; + public static synthetic fun copy$default (Lkotlin/metadata/KmAnnotationArgument$KClassValue;Ljava/lang/String;ILjava/lang/Object;)Lkotlin/metadata/KmAnnotationArgument$KClassValue; public fun equals (Ljava/lang/Object;)Z - public final fun getArrayDimensionCount ()I public final fun getClassName ()Ljava/lang/String; public fun hashCode ()I public fun toString ()Ljava/lang/String; @@ -476,15 +353,13 @@ public final class kotlin/metadata/KmAnnotationArgument$UShortValue : kotlin/met public fun hashCode ()I } -public final class kotlin/metadata/KmClass : kotlin/metadata/KmClassVisitor, kotlin/metadata/KmDeclarationContainer { +public final class kotlin/metadata/KmClass : kotlin/metadata/KmDeclarationContainer { public field name Ljava/lang/String; public fun ()V - public final fun accept (Lkotlin/metadata/KmClassVisitor;)V public final fun getCompanionObject ()Ljava/lang/String; public final fun getConstructors ()Ljava/util/List; public final fun getContextReceiverTypes ()Ljava/util/List; public final fun getEnumEntries ()Ljava/util/List; - public final fun getFlags ()I public fun getFunctions ()Ljava/util/List; public final fun getInlineClassUnderlyingPropertyName ()Ljava/lang/String; public final fun getInlineClassUnderlyingType ()Lkotlin/metadata/KmType; @@ -497,53 +372,9 @@ public final class kotlin/metadata/KmClass : kotlin/metadata/KmClassVisitor, kot public final fun getTypeParameters ()Ljava/util/List; public final fun getVersionRequirements ()Ljava/util/List; public final fun setCompanionObject (Ljava/lang/String;)V - public final fun setFlags (I)V public final fun setInlineClassUnderlyingPropertyName (Ljava/lang/String;)V public final fun setInlineClassUnderlyingType (Lkotlin/metadata/KmType;)V public final fun setName (Ljava/lang/String;)V - public fun visit (ILjava/lang/String;)V - public fun visitCompanionObject (Ljava/lang/String;)V - public fun visitConstructor (I)Lkotlin/metadata/KmConstructorVisitor; - public fun visitContextReceiverType (I)Lkotlin/metadata/KmTypeVisitor; - public fun visitEnumEntry (Ljava/lang/String;)V - public fun visitExtensions (Lkotlin/metadata/KmExtensionType;)Lkotlin/metadata/KmClassExtensionVisitor; - public synthetic fun visitExtensions (Lkotlin/metadata/KmExtensionType;)Lkotlin/metadata/KmDeclarationContainerExtensionVisitor; - public fun visitFunction (ILjava/lang/String;)Lkotlin/metadata/KmFunctionVisitor; - public fun visitInlineClassUnderlyingPropertyName (Ljava/lang/String;)V - public fun visitInlineClassUnderlyingType (I)Lkotlin/metadata/KmTypeVisitor; - public fun visitNestedClass (Ljava/lang/String;)V - public fun visitProperty (ILjava/lang/String;II)Lkotlin/metadata/KmPropertyVisitor; - public fun visitSealedSubclass (Ljava/lang/String;)V - public fun visitSupertype (I)Lkotlin/metadata/KmTypeVisitor; - public fun visitTypeAlias (ILjava/lang/String;)Lkotlin/metadata/KmTypeAliasVisitor; - public fun visitTypeParameter (ILjava/lang/String;ILkotlin/metadata/KmVariance;)Lkotlin/metadata/KmTypeParameterVisitor; - public fun visitVersionRequirement ()Lkotlin/metadata/KmVersionRequirementVisitor; -} - -public abstract interface class kotlin/metadata/KmClassExtensionVisitor : kotlin/metadata/KmDeclarationContainerExtensionVisitor { -} - -public abstract class kotlin/metadata/KmClassVisitor : kotlin/metadata/KmDeclarationContainerVisitor { - public fun ()V - public fun (Lkotlin/metadata/KmClassVisitor;)V - public synthetic fun (Lkotlin/metadata/KmClassVisitor;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - protected fun getDelegate ()Lkotlin/metadata/KmClassVisitor; - public synthetic fun getDelegate ()Lkotlin/metadata/KmDeclarationContainerVisitor; - public fun visit (ILjava/lang/String;)V - public fun visitCompanionObject (Ljava/lang/String;)V - public fun visitConstructor (I)Lkotlin/metadata/KmConstructorVisitor; - public fun visitContextReceiverType (I)Lkotlin/metadata/KmTypeVisitor; - public fun visitEnd ()V - public fun visitEnumEntry (Ljava/lang/String;)V - public fun visitExtensions (Lkotlin/metadata/KmExtensionType;)Lkotlin/metadata/KmClassExtensionVisitor; - public synthetic fun visitExtensions (Lkotlin/metadata/KmExtensionType;)Lkotlin/metadata/KmDeclarationContainerExtensionVisitor; - public fun visitInlineClassUnderlyingPropertyName (Ljava/lang/String;)V - public fun visitInlineClassUnderlyingType (I)Lkotlin/metadata/KmTypeVisitor; - public fun visitNestedClass (Ljava/lang/String;)V - public fun visitSealedSubclass (Ljava/lang/String;)V - public fun visitSupertype (I)Lkotlin/metadata/KmTypeVisitor; - public fun visitTypeParameter (ILjava/lang/String;ILkotlin/metadata/KmVariance;)Lkotlin/metadata/KmTypeParameterVisitor; - public fun visitVersionRequirement ()Lkotlin/metadata/KmVersionRequirementVisitor; } public abstract class kotlin/metadata/KmClassifier { @@ -593,45 +424,15 @@ public final class kotlin/metadata/KmConstantValue { public fun toString ()Ljava/lang/String; } -public final class kotlin/metadata/KmConstructor : kotlin/metadata/KmConstructorVisitor { +public final class kotlin/metadata/KmConstructor { public fun ()V - public fun (I)V - public final fun accept (Lkotlin/metadata/KmConstructorVisitor;)V - public final fun getFlags ()I public final fun getValueParameters ()Ljava/util/List; public final fun getVersionRequirements ()Ljava/util/List; - public final fun setFlags (I)V - public fun visitExtensions (Lkotlin/metadata/KmExtensionType;)Lkotlin/metadata/KmConstructorExtensionVisitor; - public fun visitValueParameter (ILjava/lang/String;)Lkotlin/metadata/KmValueParameterVisitor; - public fun visitVersionRequirement ()Lkotlin/metadata/KmVersionRequirementVisitor; } -public abstract interface class kotlin/metadata/KmConstructorExtensionVisitor : kotlin/metadata/KmExtensionVisitor { -} - -public abstract class kotlin/metadata/KmConstructorVisitor { +public final class kotlin/metadata/KmContract { public fun ()V - public fun (Lkotlin/metadata/KmConstructorVisitor;)V - public synthetic fun (Lkotlin/metadata/KmConstructorVisitor;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun visitEnd ()V - public fun visitExtensions (Lkotlin/metadata/KmExtensionType;)Lkotlin/metadata/KmConstructorExtensionVisitor; - public fun visitValueParameter (ILjava/lang/String;)Lkotlin/metadata/KmValueParameterVisitor; - public fun visitVersionRequirement ()Lkotlin/metadata/KmVersionRequirementVisitor; -} - -public final class kotlin/metadata/KmContract : kotlin/metadata/KmContractVisitor { - public fun ()V - public final fun accept (Lkotlin/metadata/KmContractVisitor;)V public final fun getEffects ()Ljava/util/List; - public fun visitEffect (Lkotlin/metadata/KmEffectType;Lkotlin/metadata/KmEffectInvocationKind;)Lkotlin/metadata/KmEffectVisitor; -} - -public abstract class kotlin/metadata/KmContractVisitor { - public fun ()V - public fun (Lkotlin/metadata/KmContractVisitor;)V - public synthetic fun (Lkotlin/metadata/KmContractVisitor;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun visitEffect (Lkotlin/metadata/KmEffectType;Lkotlin/metadata/KmEffectInvocationKind;)Lkotlin/metadata/KmEffectVisitor; - public fun visitEnd ()V } public abstract interface class kotlin/metadata/KmDeclarationContainer { @@ -640,23 +441,8 @@ public abstract interface class kotlin/metadata/KmDeclarationContainer { public abstract fun getTypeAliases ()Ljava/util/List; } -public abstract interface class kotlin/metadata/KmDeclarationContainerExtensionVisitor : kotlin/metadata/KmExtensionVisitor { -} - -public abstract class kotlin/metadata/KmDeclarationContainerVisitor { - public fun ()V - public fun (Lkotlin/metadata/KmDeclarationContainerVisitor;)V - public synthetic fun (Lkotlin/metadata/KmDeclarationContainerVisitor;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - protected fun getDelegate ()Lkotlin/metadata/KmDeclarationContainerVisitor; - public fun visitExtensions (Lkotlin/metadata/KmExtensionType;)Lkotlin/metadata/KmDeclarationContainerExtensionVisitor; - public fun visitFunction (ILjava/lang/String;)Lkotlin/metadata/KmFunctionVisitor; - public fun visitProperty (ILjava/lang/String;II)Lkotlin/metadata/KmPropertyVisitor; - public fun visitTypeAlias (ILjava/lang/String;)Lkotlin/metadata/KmTypeAliasVisitor; -} - -public final class kotlin/metadata/KmEffect : kotlin/metadata/KmEffectVisitor { +public final class kotlin/metadata/KmEffect { public fun (Lkotlin/metadata/KmEffectType;Lkotlin/metadata/KmEffectInvocationKind;)V - public final fun accept (Lkotlin/metadata/KmEffectVisitor;)V public final fun getConclusion ()Lkotlin/metadata/KmEffectExpression; public final fun getConstructorArguments ()Ljava/util/List; public final fun getInvocationKind ()Lkotlin/metadata/KmEffectInvocationKind; @@ -664,40 +450,18 @@ public final class kotlin/metadata/KmEffect : kotlin/metadata/KmEffectVisitor { public final fun setConclusion (Lkotlin/metadata/KmEffectExpression;)V public final fun setInvocationKind (Lkotlin/metadata/KmEffectInvocationKind;)V public final fun setType (Lkotlin/metadata/KmEffectType;)V - public fun visitConclusionOfConditionalEffect ()Lkotlin/metadata/KmEffectExpressionVisitor; - public fun visitConstructorArgument ()Lkotlin/metadata/KmEffectExpressionVisitor; } -public final class kotlin/metadata/KmEffectExpression : kotlin/metadata/KmEffectExpressionVisitor { +public final class kotlin/metadata/KmEffectExpression { public fun ()V - public final fun accept (Lkotlin/metadata/KmEffectExpressionVisitor;)V public final fun getAndArguments ()Ljava/util/List; public final fun getConstantValue ()Lkotlin/metadata/KmConstantValue; - public final fun getFlags ()I public final fun getOrArguments ()Ljava/util/List; public final fun getParameterIndex ()Ljava/lang/Integer; public final fun isInstanceType ()Lkotlin/metadata/KmType; public final fun setConstantValue (Lkotlin/metadata/KmConstantValue;)V - public final fun setFlags (I)V public final fun setInstanceType (Lkotlin/metadata/KmType;)V public final fun setParameterIndex (Ljava/lang/Integer;)V - public fun visit (ILjava/lang/Integer;)V - public fun visitAndArgument ()Lkotlin/metadata/KmEffectExpressionVisitor; - public fun visitConstantValue (Ljava/lang/Object;)V - public fun visitIsInstanceType (I)Lkotlin/metadata/KmTypeVisitor; - public fun visitOrArgument ()Lkotlin/metadata/KmEffectExpressionVisitor; -} - -public abstract class kotlin/metadata/KmEffectExpressionVisitor { - public fun ()V - public fun (Lkotlin/metadata/KmEffectExpressionVisitor;)V - public synthetic fun (Lkotlin/metadata/KmEffectExpressionVisitor;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun visit (ILjava/lang/Integer;)V - public fun visitAndArgument ()Lkotlin/metadata/KmEffectExpressionVisitor; - public fun visitConstantValue (Ljava/lang/Object;)V - public fun visitEnd ()V - public fun visitIsInstanceType (I)Lkotlin/metadata/KmTypeVisitor; - public fun visitOrArgument ()Lkotlin/metadata/KmEffectExpressionVisitor; } public final class kotlin/metadata/KmEffectInvocationKind : java/lang/Enum { @@ -718,26 +482,6 @@ public final class kotlin/metadata/KmEffectType : java/lang/Enum { public static fun values ()[Lkotlin/metadata/KmEffectType; } -public abstract class kotlin/metadata/KmEffectVisitor { - public fun ()V - public fun (Lkotlin/metadata/KmEffectVisitor;)V - public synthetic fun (Lkotlin/metadata/KmEffectVisitor;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun visitConclusionOfConditionalEffect ()Lkotlin/metadata/KmEffectExpressionVisitor; - public fun visitConstructorArgument ()Lkotlin/metadata/KmEffectExpressionVisitor; - public fun visitEnd ()V -} - -public final class kotlin/metadata/KmExtensionType { - public fun (Lkotlin/reflect/KClass;)V - public fun equals (Ljava/lang/Object;)Z - public fun hashCode ()I - public fun toString ()Ljava/lang/String; -} - -public abstract interface class kotlin/metadata/KmExtensionVisitor { - public abstract fun getType ()Lkotlin/metadata/KmExtensionType; -} - public final class kotlin/metadata/KmFlexibleTypeUpperBound { public fun (Lkotlin/metadata/KmType;Ljava/lang/String;)V public final fun component1 ()Lkotlin/metadata/KmType; @@ -753,14 +497,11 @@ public final class kotlin/metadata/KmFlexibleTypeUpperBound { public fun toString ()Ljava/lang/String; } -public final class kotlin/metadata/KmFunction : kotlin/metadata/KmFunctionVisitor { +public final class kotlin/metadata/KmFunction { public field returnType Lkotlin/metadata/KmType; - public fun (ILjava/lang/String;)V public fun (Ljava/lang/String;)V - public final fun accept (Lkotlin/metadata/KmFunctionVisitor;)V public final fun getContextReceiverTypes ()Ljava/util/List; public final fun getContract ()Lkotlin/metadata/KmContract; - public final fun getFlags ()I public final fun getName ()Ljava/lang/String; public final fun getReceiverParameterType ()Lkotlin/metadata/KmType; public final fun getReturnType ()Lkotlin/metadata/KmType; @@ -768,235 +509,86 @@ public final class kotlin/metadata/KmFunction : kotlin/metadata/KmFunctionVisito public final fun getValueParameters ()Ljava/util/List; public final fun getVersionRequirements ()Ljava/util/List; public final fun setContract (Lkotlin/metadata/KmContract;)V - public final fun setFlags (I)V public final fun setName (Ljava/lang/String;)V public final fun setReceiverParameterType (Lkotlin/metadata/KmType;)V public final fun setReturnType (Lkotlin/metadata/KmType;)V - public fun visitContextReceiverType (I)Lkotlin/metadata/KmTypeVisitor; - public fun visitContract ()Lkotlin/metadata/KmContractVisitor; - public fun visitExtensions (Lkotlin/metadata/KmExtensionType;)Lkotlin/metadata/KmFunctionExtensionVisitor; - public fun visitReceiverParameterType (I)Lkotlin/metadata/KmTypeVisitor; - public fun visitReturnType (I)Lkotlin/metadata/KmTypeVisitor; - public fun visitTypeParameter (ILjava/lang/String;ILkotlin/metadata/KmVariance;)Lkotlin/metadata/KmTypeParameterVisitor; - public fun visitValueParameter (ILjava/lang/String;)Lkotlin/metadata/KmValueParameterVisitor; - public fun visitVersionRequirement ()Lkotlin/metadata/KmVersionRequirementVisitor; } -public abstract interface class kotlin/metadata/KmFunctionExtensionVisitor : kotlin/metadata/KmExtensionVisitor { -} - -public abstract class kotlin/metadata/KmFunctionVisitor { - public fun ()V - public fun (Lkotlin/metadata/KmFunctionVisitor;)V - public synthetic fun (Lkotlin/metadata/KmFunctionVisitor;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun visitContextReceiverType (I)Lkotlin/metadata/KmTypeVisitor; - public fun visitContract ()Lkotlin/metadata/KmContractVisitor; - public fun visitEnd ()V - public fun visitExtensions (Lkotlin/metadata/KmExtensionType;)Lkotlin/metadata/KmFunctionExtensionVisitor; - public fun visitReceiverParameterType (I)Lkotlin/metadata/KmTypeVisitor; - public fun visitReturnType (I)Lkotlin/metadata/KmTypeVisitor; - public fun visitTypeParameter (ILjava/lang/String;ILkotlin/metadata/KmVariance;)Lkotlin/metadata/KmTypeParameterVisitor; - public fun visitValueParameter (ILjava/lang/String;)Lkotlin/metadata/KmValueParameterVisitor; - public fun visitVersionRequirement ()Lkotlin/metadata/KmVersionRequirementVisitor; -} - -public final class kotlin/metadata/KmLambda : kotlin/metadata/KmLambdaVisitor { +public final class kotlin/metadata/KmLambda { public field function Lkotlin/metadata/KmFunction; public fun ()V - public final fun accept (Lkotlin/metadata/KmLambdaVisitor;)V public final fun getFunction ()Lkotlin/metadata/KmFunction; public final fun setFunction (Lkotlin/metadata/KmFunction;)V - public fun visitFunction (ILjava/lang/String;)Lkotlin/metadata/KmFunctionVisitor; } -public abstract class kotlin/metadata/KmLambdaVisitor { +public final class kotlin/metadata/KmPackage : kotlin/metadata/KmDeclarationContainer { public fun ()V - public fun (Lkotlin/metadata/KmLambdaVisitor;)V - public synthetic fun (Lkotlin/metadata/KmLambdaVisitor;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun visitEnd ()V - public fun visitFunction (ILjava/lang/String;)Lkotlin/metadata/KmFunctionVisitor; -} - -public final class kotlin/metadata/KmPackage : kotlin/metadata/KmPackageVisitor, kotlin/metadata/KmDeclarationContainer { - public fun ()V - public final fun accept (Lkotlin/metadata/KmPackageVisitor;)V public fun getFunctions ()Ljava/util/List; public fun getProperties ()Ljava/util/List; public fun getTypeAliases ()Ljava/util/List; - public synthetic fun visitExtensions (Lkotlin/metadata/KmExtensionType;)Lkotlin/metadata/KmDeclarationContainerExtensionVisitor; - public fun visitExtensions (Lkotlin/metadata/KmExtensionType;)Lkotlin/metadata/KmPackageExtensionVisitor; - public fun visitFunction (ILjava/lang/String;)Lkotlin/metadata/KmFunctionVisitor; - public fun visitProperty (ILjava/lang/String;II)Lkotlin/metadata/KmPropertyVisitor; - public fun visitTypeAlias (ILjava/lang/String;)Lkotlin/metadata/KmTypeAliasVisitor; } -public abstract interface class kotlin/metadata/KmPackageExtensionVisitor : kotlin/metadata/KmDeclarationContainerExtensionVisitor { -} - -public abstract class kotlin/metadata/KmPackageVisitor : kotlin/metadata/KmDeclarationContainerVisitor { - public fun ()V - public fun (Lkotlin/metadata/KmPackageVisitor;)V - public synthetic fun (Lkotlin/metadata/KmPackageVisitor;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public synthetic fun getDelegate ()Lkotlin/metadata/KmDeclarationContainerVisitor; - protected fun getDelegate ()Lkotlin/metadata/KmPackageVisitor; - public fun visitEnd ()V - public synthetic fun visitExtensions (Lkotlin/metadata/KmExtensionType;)Lkotlin/metadata/KmDeclarationContainerExtensionVisitor; - public fun visitExtensions (Lkotlin/metadata/KmExtensionType;)Lkotlin/metadata/KmPackageExtensionVisitor; -} - -public final class kotlin/metadata/KmProperty : kotlin/metadata/KmPropertyVisitor { +public final class kotlin/metadata/KmProperty { public field returnType Lkotlin/metadata/KmType; - public fun (ILjava/lang/String;II)V public fun (Ljava/lang/String;)V - public final fun accept (Lkotlin/metadata/KmPropertyVisitor;)V public final fun getContextReceiverTypes ()Ljava/util/List; - public final fun getFlags ()I public final fun getGetter ()Lkotlin/metadata/KmPropertyAccessorAttributes; - public final fun getGetterFlags ()I public final fun getName ()Ljava/lang/String; public final fun getReceiverParameterType ()Lkotlin/metadata/KmType; public final fun getReturnType ()Lkotlin/metadata/KmType; public final fun getSetter ()Lkotlin/metadata/KmPropertyAccessorAttributes; - public final fun getSetterFlags ()I public final fun getSetterParameter ()Lkotlin/metadata/KmValueParameter; public final fun getTypeParameters ()Ljava/util/List; public final fun getVersionRequirements ()Ljava/util/List; - public final fun setFlags (I)V - public final fun setGetterFlags (I)V public final fun setName (Ljava/lang/String;)V public final fun setReceiverParameterType (Lkotlin/metadata/KmType;)V public final fun setReturnType (Lkotlin/metadata/KmType;)V public final fun setSetter (Lkotlin/metadata/KmPropertyAccessorAttributes;)V - public final fun setSetterFlags (I)V public final fun setSetterParameter (Lkotlin/metadata/KmValueParameter;)V - public fun visitContextReceiverType (I)Lkotlin/metadata/KmTypeVisitor; - public fun visitExtensions (Lkotlin/metadata/KmExtensionType;)Lkotlin/metadata/KmPropertyExtensionVisitor; - public fun visitReceiverParameterType (I)Lkotlin/metadata/KmTypeVisitor; - public fun visitReturnType (I)Lkotlin/metadata/KmTypeVisitor; - public fun visitSetterParameter (ILjava/lang/String;)Lkotlin/metadata/KmValueParameterVisitor; - public fun visitTypeParameter (ILjava/lang/String;ILkotlin/metadata/KmVariance;)Lkotlin/metadata/KmTypeParameterVisitor; - public fun visitVersionRequirement ()Lkotlin/metadata/KmVersionRequirementVisitor; } public final class kotlin/metadata/KmPropertyAccessorAttributes { public fun ()V } -public abstract interface class kotlin/metadata/KmPropertyExtensionVisitor : kotlin/metadata/KmExtensionVisitor { -} - -public abstract class kotlin/metadata/KmPropertyVisitor { - public fun ()V - public fun (Lkotlin/metadata/KmPropertyVisitor;)V - public synthetic fun (Lkotlin/metadata/KmPropertyVisitor;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun visitContextReceiverType (I)Lkotlin/metadata/KmTypeVisitor; - public fun visitEnd ()V - public fun visitExtensions (Lkotlin/metadata/KmExtensionType;)Lkotlin/metadata/KmPropertyExtensionVisitor; - public fun visitReceiverParameterType (I)Lkotlin/metadata/KmTypeVisitor; - public fun visitReturnType (I)Lkotlin/metadata/KmTypeVisitor; - public fun visitSetterParameter (ILjava/lang/String;)Lkotlin/metadata/KmValueParameterVisitor; - public fun visitTypeParameter (ILjava/lang/String;ILkotlin/metadata/KmVariance;)Lkotlin/metadata/KmTypeParameterVisitor; - public fun visitVersionRequirement ()Lkotlin/metadata/KmVersionRequirementVisitor; -} - -public final class kotlin/metadata/KmType : kotlin/metadata/KmTypeVisitor { +public final class kotlin/metadata/KmType { public field classifier Lkotlin/metadata/KmClassifier; public fun ()V - public fun (I)V - public final fun accept (Lkotlin/metadata/KmTypeVisitor;)V public final fun getAbbreviatedType ()Lkotlin/metadata/KmType; public final fun getArguments ()Ljava/util/List; public final fun getClassifier ()Lkotlin/metadata/KmClassifier; - public final fun getFlags ()I public final fun getFlexibleTypeUpperBound ()Lkotlin/metadata/KmFlexibleTypeUpperBound; public final fun getOuterType ()Lkotlin/metadata/KmType; public final fun setAbbreviatedType (Lkotlin/metadata/KmType;)V public final fun setClassifier (Lkotlin/metadata/KmClassifier;)V - public final fun setFlags (I)V public final fun setFlexibleTypeUpperBound (Lkotlin/metadata/KmFlexibleTypeUpperBound;)V public final fun setOuterType (Lkotlin/metadata/KmType;)V - public fun visitAbbreviatedType (I)Lkotlin/metadata/KmTypeVisitor; - public fun visitArgument (ILkotlin/metadata/KmVariance;)Lkotlin/metadata/KmTypeVisitor; - public fun visitClass (Ljava/lang/String;)V - public fun visitExtensions (Lkotlin/metadata/KmExtensionType;)Lkotlin/metadata/KmTypeExtensionVisitor; - public fun visitFlexibleTypeUpperBound (ILjava/lang/String;)Lkotlin/metadata/KmTypeVisitor; - public fun visitOuterType (I)Lkotlin/metadata/KmTypeVisitor; - public fun visitStarProjection ()V - public fun visitTypeAlias (Ljava/lang/String;)V - public fun visitTypeParameter (I)V } -public final class kotlin/metadata/KmTypeAlias : kotlin/metadata/KmTypeAliasVisitor { +public final class kotlin/metadata/KmTypeAlias { public field expandedType Lkotlin/metadata/KmType; public field underlyingType Lkotlin/metadata/KmType; - public fun (ILjava/lang/String;)V public fun (Ljava/lang/String;)V - public final fun accept (Lkotlin/metadata/KmTypeAliasVisitor;)V public final fun getAnnotations ()Ljava/util/List; public final fun getExpandedType ()Lkotlin/metadata/KmType; - public final fun getFlags ()I public final fun getName ()Ljava/lang/String; public final fun getTypeParameters ()Ljava/util/List; public final fun getUnderlyingType ()Lkotlin/metadata/KmType; public final fun getVersionRequirements ()Ljava/util/List; public final fun setExpandedType (Lkotlin/metadata/KmType;)V - public final fun setFlags (I)V public final fun setName (Ljava/lang/String;)V public final fun setUnderlyingType (Lkotlin/metadata/KmType;)V - public fun visitAnnotation (Lkotlin/metadata/KmAnnotation;)V - public fun visitExpandedType (I)Lkotlin/metadata/KmTypeVisitor; - public fun visitExtensions (Lkotlin/metadata/KmExtensionType;)Lkotlin/metadata/KmTypeAliasExtensionVisitor; - public fun visitTypeParameter (ILjava/lang/String;ILkotlin/metadata/KmVariance;)Lkotlin/metadata/KmTypeParameterVisitor; - public fun visitUnderlyingType (I)Lkotlin/metadata/KmTypeVisitor; - public fun visitVersionRequirement ()Lkotlin/metadata/KmVersionRequirementVisitor; } -public abstract interface class kotlin/metadata/KmTypeAliasExtensionVisitor : kotlin/metadata/KmExtensionVisitor { -} - -public abstract class kotlin/metadata/KmTypeAliasVisitor { - public fun ()V - public fun (Lkotlin/metadata/KmTypeAliasVisitor;)V - public synthetic fun (Lkotlin/metadata/KmTypeAliasVisitor;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun visitAnnotation (Lkotlin/metadata/KmAnnotation;)V - public fun visitEnd ()V - public fun visitExpandedType (I)Lkotlin/metadata/KmTypeVisitor; - public fun visitExtensions (Lkotlin/metadata/KmExtensionType;)Lkotlin/metadata/KmTypeAliasExtensionVisitor; - public fun visitTypeParameter (ILjava/lang/String;ILkotlin/metadata/KmVariance;)Lkotlin/metadata/KmTypeParameterVisitor; - public fun visitUnderlyingType (I)Lkotlin/metadata/KmTypeVisitor; - public fun visitVersionRequirement ()Lkotlin/metadata/KmVersionRequirementVisitor; -} - -public abstract interface class kotlin/metadata/KmTypeExtensionVisitor : kotlin/metadata/KmExtensionVisitor { -} - -public final class kotlin/metadata/KmTypeParameter : kotlin/metadata/KmTypeParameterVisitor { - public fun (ILjava/lang/String;ILkotlin/metadata/KmVariance;)V +public final class kotlin/metadata/KmTypeParameter { public fun (Ljava/lang/String;ILkotlin/metadata/KmVariance;)V - public final fun accept (Lkotlin/metadata/KmTypeParameterVisitor;)V - public final fun getFlags ()I public final fun getId ()I public final fun getName ()Ljava/lang/String; public final fun getUpperBounds ()Ljava/util/List; public final fun getVariance ()Lkotlin/metadata/KmVariance; - public final fun setFlags (I)V public final fun setId (I)V public final fun setName (Ljava/lang/String;)V public final fun setVariance (Lkotlin/metadata/KmVariance;)V - public fun visitExtensions (Lkotlin/metadata/KmExtensionType;)Lkotlin/metadata/KmTypeParameterExtensionVisitor; - public fun visitUpperBound (I)Lkotlin/metadata/KmTypeVisitor; -} - -public abstract interface class kotlin/metadata/KmTypeParameterExtensionVisitor : kotlin/metadata/KmExtensionVisitor { -} - -public abstract class kotlin/metadata/KmTypeParameterVisitor { - public fun ()V - public fun (Lkotlin/metadata/KmTypeParameterVisitor;)V - public synthetic fun (Lkotlin/metadata/KmTypeParameterVisitor;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun visitEnd ()V - public fun visitExtensions (Lkotlin/metadata/KmExtensionType;)Lkotlin/metadata/KmTypeParameterExtensionVisitor; - public fun visitUpperBound (I)Lkotlin/metadata/KmTypeVisitor; } public final class kotlin/metadata/KmTypeProjection { @@ -1019,51 +611,15 @@ public final class kotlin/metadata/KmTypeProjection { public final class kotlin/metadata/KmTypeProjection$Companion { } -public abstract class kotlin/metadata/KmTypeVisitor { - public fun ()V - public fun (Lkotlin/metadata/KmTypeVisitor;)V - public synthetic fun (Lkotlin/metadata/KmTypeVisitor;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun visitAbbreviatedType (I)Lkotlin/metadata/KmTypeVisitor; - public fun visitArgument (ILkotlin/metadata/KmVariance;)Lkotlin/metadata/KmTypeVisitor; - public fun visitClass (Ljava/lang/String;)V - public fun visitEnd ()V - public fun visitExtensions (Lkotlin/metadata/KmExtensionType;)Lkotlin/metadata/KmTypeExtensionVisitor; - public fun visitFlexibleTypeUpperBound (ILjava/lang/String;)Lkotlin/metadata/KmTypeVisitor; - public fun visitOuterType (I)Lkotlin/metadata/KmTypeVisitor; - public fun visitStarProjection ()V - public fun visitTypeAlias (Ljava/lang/String;)V - public fun visitTypeParameter (I)V -} - -public final class kotlin/metadata/KmValueParameter : kotlin/metadata/KmValueParameterVisitor { +public final class kotlin/metadata/KmValueParameter { public field type Lkotlin/metadata/KmType; - public fun (ILjava/lang/String;)V public fun (Ljava/lang/String;)V - public final fun accept (Lkotlin/metadata/KmValueParameterVisitor;)V - public final fun getFlags ()I public final fun getName ()Ljava/lang/String; public final fun getType ()Lkotlin/metadata/KmType; public final fun getVarargElementType ()Lkotlin/metadata/KmType; - public final fun setFlags (I)V public final fun setName (Ljava/lang/String;)V public final fun setType (Lkotlin/metadata/KmType;)V public final fun setVarargElementType (Lkotlin/metadata/KmType;)V - public fun visitExtensions (Lkotlin/metadata/KmExtensionType;)Lkotlin/metadata/KmValueParameterExtensionVisitor; - public fun visitType (I)Lkotlin/metadata/KmTypeVisitor; - public fun visitVarargElementType (I)Lkotlin/metadata/KmTypeVisitor; -} - -public abstract interface class kotlin/metadata/KmValueParameterExtensionVisitor : kotlin/metadata/KmExtensionVisitor { -} - -public abstract class kotlin/metadata/KmValueParameterVisitor { - public fun ()V - public fun (Lkotlin/metadata/KmValueParameterVisitor;)V - public synthetic fun (Lkotlin/metadata/KmValueParameterVisitor;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun visitEnd ()V - public fun visitExtensions (Lkotlin/metadata/KmExtensionType;)Lkotlin/metadata/KmValueParameterExtensionVisitor; - public fun visitType (I)Lkotlin/metadata/KmTypeVisitor; - public fun visitVarargElementType (I)Lkotlin/metadata/KmTypeVisitor; } public final class kotlin/metadata/KmVariance : java/lang/Enum { @@ -1090,12 +646,11 @@ public final class kotlin/metadata/KmVersion { public fun toString ()Ljava/lang/String; } -public final class kotlin/metadata/KmVersionRequirement : kotlin/metadata/KmVersionRequirementVisitor { +public final class kotlin/metadata/KmVersionRequirement { public field kind Lkotlin/metadata/KmVersionRequirementVersionKind; public field level Lkotlin/metadata/KmVersionRequirementLevel; public field version Lkotlin/metadata/KmVersion; public fun ()V - public final fun accept (Lkotlin/metadata/KmVersionRequirementVisitor;)V public final fun getErrorCode ()Ljava/lang/Integer; public final fun getKind ()Lkotlin/metadata/KmVersionRequirementVersionKind; public final fun getLevel ()Lkotlin/metadata/KmVersionRequirementLevel; @@ -1107,8 +662,6 @@ public final class kotlin/metadata/KmVersionRequirement : kotlin/metadata/KmVers public final fun setMessage (Ljava/lang/String;)V public final fun setVersion (Lkotlin/metadata/KmVersion;)V public fun toString ()Ljava/lang/String; - public fun visit (Lkotlin/metadata/KmVersionRequirementVersionKind;Lkotlin/metadata/KmVersionRequirementLevel;Ljava/lang/Integer;Ljava/lang/String;)V - public fun visitVersion (III)V } public final class kotlin/metadata/KmVersionRequirementLevel : java/lang/Enum { @@ -1130,15 +683,6 @@ public final class kotlin/metadata/KmVersionRequirementVersionKind : java/lang/E public static fun values ()[Lkotlin/metadata/KmVersionRequirementVersionKind; } -public abstract class kotlin/metadata/KmVersionRequirementVisitor { - public fun ()V - public fun (Lkotlin/metadata/KmVersionRequirementVisitor;)V - public synthetic fun (Lkotlin/metadata/KmVersionRequirementVisitor;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun visit (Lkotlin/metadata/KmVersionRequirementVersionKind;Lkotlin/metadata/KmVersionRequirementLevel;Ljava/lang/Integer;Ljava/lang/String;)V - public fun visitEnd ()V - public fun visitVersion (III)V -} - public final class kotlin/metadata/MemberKind : java/lang/Enum { public static final field DECLARATION Lkotlin/metadata/MemberKind; public static final field DELEGATION Lkotlin/metadata/MemberKind; @@ -1180,53 +724,12 @@ public final class kotlin/metadata/jvm/JvmAttributes { public static final fun setMovedFromInterfaceCompanion (Lkotlin/metadata/KmProperty;Z)V } -public class kotlin/metadata/jvm/JvmClassExtensionVisitor : kotlin/metadata/jvm/JvmDeclarationContainerExtensionVisitor, kotlin/metadata/KmClassExtensionVisitor { - public static final field Companion Lkotlin/metadata/jvm/JvmClassExtensionVisitor$Companion; - public static final field TYPE Lkotlin/metadata/KmExtensionType; - public fun ()V - public fun (Lkotlin/metadata/jvm/JvmClassExtensionVisitor;)V - public synthetic fun (Lkotlin/metadata/jvm/JvmClassExtensionVisitor;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - protected fun getDelegate ()Lkotlin/metadata/jvm/JvmClassExtensionVisitor; - public synthetic fun getDelegate ()Lkotlin/metadata/jvm/JvmDeclarationContainerExtensionVisitor; - public final fun getType ()Lkotlin/metadata/KmExtensionType; - public fun visitAnonymousObjectOriginName (Ljava/lang/String;)V - public fun visitEnd ()V - public fun visitJvmFlags (I)V -} - -public final class kotlin/metadata/jvm/JvmClassExtensionVisitor$Companion { -} - -public class kotlin/metadata/jvm/JvmConstructorExtensionVisitor : kotlin/metadata/KmConstructorExtensionVisitor { - public static final field Companion Lkotlin/metadata/jvm/JvmConstructorExtensionVisitor$Companion; - public static final field TYPE Lkotlin/metadata/KmExtensionType; - public fun ()V - public fun (Lkotlin/metadata/jvm/JvmConstructorExtensionVisitor;)V - public synthetic fun (Lkotlin/metadata/jvm/JvmConstructorExtensionVisitor;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getType ()Lkotlin/metadata/KmExtensionType; - public fun visit (Lkotlin/metadata/jvm/JvmMethodSignature;)V -} - -public final class kotlin/metadata/jvm/JvmConstructorExtensionVisitor$Companion { -} - -public abstract class kotlin/metadata/jvm/JvmDeclarationContainerExtensionVisitor : kotlin/metadata/KmDeclarationContainerExtensionVisitor { - public fun ()V - public fun (Lkotlin/metadata/jvm/JvmDeclarationContainerExtensionVisitor;)V - public synthetic fun (Lkotlin/metadata/jvm/JvmDeclarationContainerExtensionVisitor;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - protected fun getDelegate ()Lkotlin/metadata/jvm/JvmDeclarationContainerExtensionVisitor; - public fun visitLocalDelegatedProperty (ILjava/lang/String;II)Lkotlin/metadata/KmPropertyVisitor; - public fun visitModuleName (Ljava/lang/String;)V -} - public final class kotlin/metadata/jvm/JvmExtensionsKt { public static final fun getAnnotations (Lkotlin/metadata/KmType;)Ljava/util/List; public static final fun getAnnotations (Lkotlin/metadata/KmTypeParameter;)Ljava/util/List; public static final fun getAnonymousObjectOriginName (Lkotlin/metadata/KmClass;)Ljava/lang/String; public static final fun getFieldSignature (Lkotlin/metadata/KmProperty;)Lkotlin/metadata/jvm/JvmFieldSignature; public static final fun getGetterSignature (Lkotlin/metadata/KmProperty;)Lkotlin/metadata/jvm/JvmMethodSignature; - public static final fun getJvmFlags (Lkotlin/metadata/KmClass;)I - public static final fun getJvmFlags (Lkotlin/metadata/KmProperty;)I public static final fun getLambdaClassOriginName (Lkotlin/metadata/KmFunction;)Ljava/lang/String; public static final fun getLocalDelegatedProperties (Lkotlin/metadata/KmClass;)Ljava/util/List; public static final fun getLocalDelegatedProperties (Lkotlin/metadata/KmPackage;)Ljava/util/List; @@ -1241,8 +744,6 @@ public final class kotlin/metadata/jvm/JvmExtensionsKt { public static final fun setAnonymousObjectOriginName (Lkotlin/metadata/KmClass;Ljava/lang/String;)V public static final fun setFieldSignature (Lkotlin/metadata/KmProperty;Lkotlin/metadata/jvm/JvmFieldSignature;)V public static final fun setGetterSignature (Lkotlin/metadata/KmProperty;Lkotlin/metadata/jvm/JvmMethodSignature;)V - public static final fun setJvmFlags (Lkotlin/metadata/KmClass;I)V - public static final fun setJvmFlags (Lkotlin/metadata/KmProperty;I)V public static final fun setLambdaClassOriginName (Lkotlin/metadata/KmFunction;Ljava/lang/String;)V public static final fun setModuleName (Lkotlin/metadata/KmClass;Ljava/lang/String;)V public static final fun setModuleName (Lkotlin/metadata/KmPackage;Ljava/lang/String;)V @@ -1267,39 +768,7 @@ public final class kotlin/metadata/jvm/JvmFieldSignature : kotlin/metadata/jvm/J public fun toString ()Ljava/lang/String; } -public final class kotlin/metadata/jvm/JvmFlag { - public static final field INSTANCE Lkotlin/metadata/jvm/JvmFlag; -} - -public final class kotlin/metadata/jvm/JvmFlag$Class { - public static final field HAS_METHOD_BODIES_IN_INTERFACE Lkotlin/metadata/Flag; - public static final field INSTANCE Lkotlin/metadata/jvm/JvmFlag$Class; - public static final field IS_COMPILED_IN_COMPATIBILITY_MODE Lkotlin/metadata/Flag; -} - -public final class kotlin/metadata/jvm/JvmFlag$Property { - public static final field INSTANCE Lkotlin/metadata/jvm/JvmFlag$Property; - public static final field IS_MOVED_FROM_INTERFACE_COMPANION Lkotlin/metadata/Flag; -} - -public class kotlin/metadata/jvm/JvmFunctionExtensionVisitor : kotlin/metadata/KmFunctionExtensionVisitor { - public static final field Companion Lkotlin/metadata/jvm/JvmFunctionExtensionVisitor$Companion; - public static final field TYPE Lkotlin/metadata/KmExtensionType; - public fun ()V - public fun (Lkotlin/metadata/jvm/JvmFunctionExtensionVisitor;)V - public synthetic fun (Lkotlin/metadata/jvm/JvmFunctionExtensionVisitor;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getType ()Lkotlin/metadata/KmExtensionType; - public fun visit (Lkotlin/metadata/jvm/JvmMethodSignature;)V - public fun visitEnd ()V - public fun visitLambdaClassOriginName (Ljava/lang/String;)V -} - -public final class kotlin/metadata/jvm/JvmFunctionExtensionVisitor$Companion { -} - public abstract class kotlin/metadata/jvm/JvmMemberSignature { - public final fun asString ()Ljava/lang/String; - public final fun getDesc ()Ljava/lang/String; public abstract fun getDescriptor ()Ljava/lang/String; public abstract fun getName ()Ljava/lang/String; public abstract fun toString ()Ljava/lang/String; @@ -1308,7 +777,6 @@ public abstract class kotlin/metadata/jvm/JvmMemberSignature { public final class kotlin/metadata/jvm/JvmMetadataUtil { public static final fun Metadata (Ljava/lang/Integer;[I[Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Integer;)Lkotlin/Metadata; public static synthetic fun Metadata$default (Ljava/lang/Integer;[I[Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Integer;ILjava/lang/Object;)Lkotlin/Metadata; - public static final fun getJvmInternalName (Ljava/lang/String;)Ljava/lang/String; public static final fun toJvmInternalName (Ljava/lang/String;)Ljava/lang/String; } @@ -1343,88 +811,10 @@ public final class kotlin/metadata/jvm/JvmMethodSignature : kotlin/metadata/jvm/ public fun toString ()Ljava/lang/String; } -public class kotlin/metadata/jvm/JvmPackageExtensionVisitor : kotlin/metadata/jvm/JvmDeclarationContainerExtensionVisitor, kotlin/metadata/KmPackageExtensionVisitor { - public static final field Companion Lkotlin/metadata/jvm/JvmPackageExtensionVisitor$Companion; - public static final field TYPE Lkotlin/metadata/KmExtensionType; +public final class kotlin/metadata/jvm/KmModule { public fun ()V - public fun (Lkotlin/metadata/jvm/JvmPackageExtensionVisitor;)V - public synthetic fun (Lkotlin/metadata/jvm/JvmPackageExtensionVisitor;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public synthetic fun getDelegate ()Lkotlin/metadata/jvm/JvmDeclarationContainerExtensionVisitor; - protected fun getDelegate ()Lkotlin/metadata/jvm/JvmPackageExtensionVisitor; - public final fun getType ()Lkotlin/metadata/KmExtensionType; - public fun visitEnd ()V -} - -public final class kotlin/metadata/jvm/JvmPackageExtensionVisitor$Companion { -} - -public class kotlin/metadata/jvm/JvmPropertyExtensionVisitor : kotlin/metadata/KmPropertyExtensionVisitor { - public static final field Companion Lkotlin/metadata/jvm/JvmPropertyExtensionVisitor$Companion; - public static final field TYPE Lkotlin/metadata/KmExtensionType; - public fun ()V - public fun (Lkotlin/metadata/jvm/JvmPropertyExtensionVisitor;)V - public synthetic fun (Lkotlin/metadata/jvm/JvmPropertyExtensionVisitor;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getType ()Lkotlin/metadata/KmExtensionType; - public fun visit (ILkotlin/metadata/jvm/JvmFieldSignature;Lkotlin/metadata/jvm/JvmMethodSignature;Lkotlin/metadata/jvm/JvmMethodSignature;)V - public fun visit (Lkotlin/metadata/jvm/JvmFieldSignature;Lkotlin/metadata/jvm/JvmMethodSignature;Lkotlin/metadata/jvm/JvmMethodSignature;)V - public fun visitEnd ()V - public fun visitSyntheticMethodForAnnotations (Lkotlin/metadata/jvm/JvmMethodSignature;)V - public fun visitSyntheticMethodForDelegate (Lkotlin/metadata/jvm/JvmMethodSignature;)V -} - -public final class kotlin/metadata/jvm/JvmPropertyExtensionVisitor$Companion { -} - -public class kotlin/metadata/jvm/JvmTypeExtensionVisitor : kotlin/metadata/KmTypeExtensionVisitor { - public static final field Companion Lkotlin/metadata/jvm/JvmTypeExtensionVisitor$Companion; - public static final field PLATFORM_TYPE_ID Ljava/lang/String; - public static final field TYPE Lkotlin/metadata/KmExtensionType; - public fun ()V - public fun (Lkotlin/metadata/jvm/JvmTypeExtensionVisitor;)V - public synthetic fun (Lkotlin/metadata/jvm/JvmTypeExtensionVisitor;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getType ()Lkotlin/metadata/KmExtensionType; - public fun visit (Z)V - public fun visitAnnotation (Lkotlin/metadata/KmAnnotation;)V - public fun visitEnd ()V -} - -public final class kotlin/metadata/jvm/JvmTypeExtensionVisitor$Companion { -} - -public class kotlin/metadata/jvm/JvmTypeParameterExtensionVisitor : kotlin/metadata/KmTypeParameterExtensionVisitor { - public static final field Companion Lkotlin/metadata/jvm/JvmTypeParameterExtensionVisitor$Companion; - public static final field TYPE Lkotlin/metadata/KmExtensionType; - public fun ()V - public fun (Lkotlin/metadata/jvm/JvmTypeParameterExtensionVisitor;)V - public synthetic fun (Lkotlin/metadata/jvm/JvmTypeParameterExtensionVisitor;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getType ()Lkotlin/metadata/KmExtensionType; - public fun visitAnnotation (Lkotlin/metadata/KmAnnotation;)V - public fun visitEnd ()V -} - -public final class kotlin/metadata/jvm/JvmTypeParameterExtensionVisitor$Companion { -} - -public final class kotlin/metadata/jvm/KmModule : kotlin/metadata/jvm/KmModuleVisitor { - public fun ()V - public final fun accept (Lkotlin/metadata/jvm/KmModuleVisitor;)V - public final fun getAnnotations ()Ljava/util/List; public final fun getOptionalAnnotationClasses ()Ljava/util/List; public final fun getPackageParts ()Ljava/util/Map; - public fun visitAnnotation (Lkotlin/metadata/KmAnnotation;)V - public fun visitOptionalAnnotationClass ()Lkotlin/metadata/KmClass; - public synthetic fun visitOptionalAnnotationClass ()Lkotlin/metadata/KmClassVisitor; - public fun visitPackageParts (Ljava/lang/String;Ljava/util/List;Ljava/util/Map;)V -} - -public abstract class kotlin/metadata/jvm/KmModuleVisitor { - public fun ()V - public fun (Lkotlin/metadata/jvm/KmModuleVisitor;)V - public synthetic fun (Lkotlin/metadata/jvm/KmModuleVisitor;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun visitAnnotation (Lkotlin/metadata/KmAnnotation;)V - public fun visitEnd ()V - public fun visitOptionalAnnotationClass ()Lkotlin/metadata/KmClassVisitor; - public fun visitPackageParts (Ljava/lang/String;Ljava/util/List;Ljava/util/Map;)V } public final class kotlin/metadata/jvm/KmPackageParts { @@ -1434,12 +824,6 @@ public final class kotlin/metadata/jvm/KmPackageParts { } public final class kotlin/metadata/jvm/KotlinClassHeader : kotlin/Metadata { - public static final field CLASS_KIND I - public static final field COMPATIBLE_METADATA_VERSION [I - public static final field FILE_FACADE_KIND I - public static final field MULTI_FILE_CLASS_FACADE_KIND I - public static final field MULTI_FILE_CLASS_PART_KIND I - public static final field SYNTHETIC_CLASS_KIND I public fun (Ljava/lang/Integer;[I[Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Integer;)V public fun annotationType ()Ljava/lang/Class; public fun bv ()[I @@ -1454,7 +838,6 @@ public final class kotlin/metadata/jvm/KotlinClassHeader : kotlin/Metadata { public abstract class kotlin/metadata/jvm/KotlinClassMetadata { public static final field CLASS_KIND I - public static final field COMPATIBLE_METADATA_VERSION [I public static final field Companion Lkotlin/metadata/jvm/KotlinClassMetadata$Companion; public static final field FILE_FACADE_KIND I public static final field MULTI_FILE_CLASS_FACADE_KIND I @@ -1462,105 +845,41 @@ public abstract class kotlin/metadata/jvm/KotlinClassMetadata { public static final field SYNTHETIC_CLASS_KIND I public abstract fun getFlags ()I public abstract fun getVersion ()Lkotlin/metadata/jvm/JvmMetadataVersion; - public static final fun read (Lkotlin/Metadata;)Lkotlin/metadata/jvm/KotlinClassMetadata; public static final fun readLenient (Lkotlin/Metadata;)Lkotlin/metadata/jvm/KotlinClassMetadata; public static final fun readStrict (Lkotlin/Metadata;)Lkotlin/metadata/jvm/KotlinClassMetadata; public abstract fun setFlags (I)V public abstract fun setVersion (Lkotlin/metadata/jvm/JvmMetadataVersion;)V public abstract fun write ()Lkotlin/Metadata; - public static final fun writeClass (Lkotlin/metadata/KmClass;)Lkotlin/Metadata; - public static final fun writeClass (Lkotlin/metadata/KmClass;[I)Lkotlin/Metadata; - public static final fun writeClass (Lkotlin/metadata/KmClass;[II)Lkotlin/Metadata; - public static final fun writeFileFacade (Lkotlin/metadata/KmPackage;)Lkotlin/Metadata; - public static final fun writeFileFacade (Lkotlin/metadata/KmPackage;[I)Lkotlin/Metadata; - public static final fun writeFileFacade (Lkotlin/metadata/KmPackage;[II)Lkotlin/Metadata; - public static final fun writeLambda (Lkotlin/metadata/KmLambda;)Lkotlin/Metadata; - public static final fun writeLambda (Lkotlin/metadata/KmLambda;[I)Lkotlin/Metadata; - public static final fun writeLambda (Lkotlin/metadata/KmLambda;[II)Lkotlin/Metadata; - public static final fun writeMultiFileClassFacade (Ljava/util/List;)Lkotlin/Metadata; - public static final fun writeMultiFileClassFacade (Ljava/util/List;[I)Lkotlin/Metadata; - public static final fun writeMultiFileClassFacade (Ljava/util/List;[II)Lkotlin/Metadata; - public static final fun writeMultiFileClassPart (Lkotlin/metadata/KmPackage;Ljava/lang/String;)Lkotlin/Metadata; - public static final fun writeMultiFileClassPart (Lkotlin/metadata/KmPackage;Ljava/lang/String;[I)Lkotlin/Metadata; - public static final fun writeMultiFileClassPart (Lkotlin/metadata/KmPackage;Ljava/lang/String;[II)Lkotlin/Metadata; - public static final fun writeSyntheticClass ()Lkotlin/Metadata; - public static final fun writeSyntheticClass ([I)Lkotlin/Metadata; - public static final fun writeSyntheticClass ([II)Lkotlin/Metadata; } public final class kotlin/metadata/jvm/KotlinClassMetadata$Class : kotlin/metadata/jvm/KotlinClassMetadata { public fun (Lkotlin/metadata/KmClass;Lkotlin/metadata/jvm/JvmMetadataVersion;I)V - public final fun accept (Lkotlin/metadata/KmClassVisitor;)V public fun getFlags ()I public final fun getKmClass ()Lkotlin/metadata/KmClass; public fun getVersion ()Lkotlin/metadata/jvm/JvmMetadataVersion; public fun setFlags (I)V public final fun setKmClass (Lkotlin/metadata/KmClass;)V public fun setVersion (Lkotlin/metadata/jvm/JvmMetadataVersion;)V - public final fun toKmClass ()Lkotlin/metadata/KmClass; public fun write ()Lkotlin/Metadata; } -public final class kotlin/metadata/jvm/KotlinClassMetadata$Class$Writer : kotlin/metadata/internal/ClassWriter { - public fun ()V - public final fun write ()Lkotlin/metadata/jvm/KotlinClassMetadata$Class; - public final fun write ([I)Lkotlin/metadata/jvm/KotlinClassMetadata$Class; - public final fun write ([II)Lkotlin/metadata/jvm/KotlinClassMetadata$Class; - public static synthetic fun write$default (Lkotlin/metadata/jvm/KotlinClassMetadata$Class$Writer;[IIILjava/lang/Object;)Lkotlin/metadata/jvm/KotlinClassMetadata$Class; -} - public final class kotlin/metadata/jvm/KotlinClassMetadata$Companion { - public final fun read (Lkotlin/Metadata;)Lkotlin/metadata/jvm/KotlinClassMetadata; public final fun readLenient (Lkotlin/Metadata;)Lkotlin/metadata/jvm/KotlinClassMetadata; public final fun readStrict (Lkotlin/Metadata;)Lkotlin/metadata/jvm/KotlinClassMetadata; public final fun transform (Lkotlin/Metadata;Lkotlin/jvm/functions/Function1;)Lkotlin/Metadata; - public final fun writeClass (Lkotlin/metadata/KmClass;)Lkotlin/Metadata; - public final fun writeClass (Lkotlin/metadata/KmClass;[I)Lkotlin/Metadata; - public final fun writeClass (Lkotlin/metadata/KmClass;[II)Lkotlin/Metadata; - public static synthetic fun writeClass$default (Lkotlin/metadata/jvm/KotlinClassMetadata$Companion;Lkotlin/metadata/KmClass;[IIILjava/lang/Object;)Lkotlin/Metadata; - public final fun writeFileFacade (Lkotlin/metadata/KmPackage;)Lkotlin/Metadata; - public final fun writeFileFacade (Lkotlin/metadata/KmPackage;[I)Lkotlin/Metadata; - public final fun writeFileFacade (Lkotlin/metadata/KmPackage;[II)Lkotlin/Metadata; - public static synthetic fun writeFileFacade$default (Lkotlin/metadata/jvm/KotlinClassMetadata$Companion;Lkotlin/metadata/KmPackage;[IIILjava/lang/Object;)Lkotlin/Metadata; - public final fun writeLambda (Lkotlin/metadata/KmLambda;)Lkotlin/Metadata; - public final fun writeLambda (Lkotlin/metadata/KmLambda;[I)Lkotlin/Metadata; - public final fun writeLambda (Lkotlin/metadata/KmLambda;[II)Lkotlin/Metadata; - public static synthetic fun writeLambda$default (Lkotlin/metadata/jvm/KotlinClassMetadata$Companion;Lkotlin/metadata/KmLambda;[IIILjava/lang/Object;)Lkotlin/Metadata; - public final fun writeMultiFileClassFacade (Ljava/util/List;)Lkotlin/Metadata; - public final fun writeMultiFileClassFacade (Ljava/util/List;[I)Lkotlin/Metadata; - public final fun writeMultiFileClassFacade (Ljava/util/List;[II)Lkotlin/Metadata; - public static synthetic fun writeMultiFileClassFacade$default (Lkotlin/metadata/jvm/KotlinClassMetadata$Companion;Ljava/util/List;[IIILjava/lang/Object;)Lkotlin/Metadata; - public final fun writeMultiFileClassPart (Lkotlin/metadata/KmPackage;Ljava/lang/String;)Lkotlin/Metadata; - public final fun writeMultiFileClassPart (Lkotlin/metadata/KmPackage;Ljava/lang/String;[I)Lkotlin/Metadata; - public final fun writeMultiFileClassPart (Lkotlin/metadata/KmPackage;Ljava/lang/String;[II)Lkotlin/Metadata; - public static synthetic fun writeMultiFileClassPart$default (Lkotlin/metadata/jvm/KotlinClassMetadata$Companion;Lkotlin/metadata/KmPackage;Ljava/lang/String;[IIILjava/lang/Object;)Lkotlin/Metadata; - public final fun writeSyntheticClass ()Lkotlin/Metadata; - public final fun writeSyntheticClass ([I)Lkotlin/Metadata; - public final fun writeSyntheticClass ([II)Lkotlin/Metadata; - public static synthetic fun writeSyntheticClass$default (Lkotlin/metadata/jvm/KotlinClassMetadata$Companion;[IIILjava/lang/Object;)Lkotlin/Metadata; } public final class kotlin/metadata/jvm/KotlinClassMetadata$FileFacade : kotlin/metadata/jvm/KotlinClassMetadata { public fun (Lkotlin/metadata/KmPackage;Lkotlin/metadata/jvm/JvmMetadataVersion;I)V - public final fun accept (Lkotlin/metadata/KmPackageVisitor;)V public fun getFlags ()I public final fun getKmPackage ()Lkotlin/metadata/KmPackage; public fun getVersion ()Lkotlin/metadata/jvm/JvmMetadataVersion; public fun setFlags (I)V public final fun setKmPackage (Lkotlin/metadata/KmPackage;)V public fun setVersion (Lkotlin/metadata/jvm/JvmMetadataVersion;)V - public final fun toKmPackage ()Lkotlin/metadata/KmPackage; public fun write ()Lkotlin/Metadata; } -public final class kotlin/metadata/jvm/KotlinClassMetadata$FileFacade$Writer : kotlin/metadata/internal/PackageWriter { - public fun ()V - public final fun write ()Lkotlin/metadata/jvm/KotlinClassMetadata$FileFacade; - public final fun write ([I)Lkotlin/metadata/jvm/KotlinClassMetadata$FileFacade; - public final fun write ([II)Lkotlin/metadata/jvm/KotlinClassMetadata$FileFacade; - public static synthetic fun write$default (Lkotlin/metadata/jvm/KotlinClassMetadata$FileFacade$Writer;[IIILjava/lang/Object;)Lkotlin/metadata/jvm/KotlinClassMetadata$FileFacade; -} - public final class kotlin/metadata/jvm/KotlinClassMetadata$MultiFileClassFacade : kotlin/metadata/jvm/KotlinClassMetadata { public fun (Ljava/util/List;Lkotlin/metadata/jvm/JvmMetadataVersion;I)V public fun getFlags ()I @@ -1572,17 +891,8 @@ public final class kotlin/metadata/jvm/KotlinClassMetadata$MultiFileClassFacade public fun write ()Lkotlin/Metadata; } -public final class kotlin/metadata/jvm/KotlinClassMetadata$MultiFileClassFacade$Writer { - public fun ()V - public final fun write (Ljava/util/List;)Lkotlin/metadata/jvm/KotlinClassMetadata$MultiFileClassFacade; - public final fun write (Ljava/util/List;[I)Lkotlin/metadata/jvm/KotlinClassMetadata$MultiFileClassFacade; - public final fun write (Ljava/util/List;[II)Lkotlin/metadata/jvm/KotlinClassMetadata$MultiFileClassFacade; - public static synthetic fun write$default (Lkotlin/metadata/jvm/KotlinClassMetadata$MultiFileClassFacade$Writer;Ljava/util/List;[IIILjava/lang/Object;)Lkotlin/metadata/jvm/KotlinClassMetadata$MultiFileClassFacade; -} - public final class kotlin/metadata/jvm/KotlinClassMetadata$MultiFileClassPart : kotlin/metadata/jvm/KotlinClassMetadata { public fun (Lkotlin/metadata/KmPackage;Ljava/lang/String;Lkotlin/metadata/jvm/JvmMetadataVersion;I)V - public final fun accept (Lkotlin/metadata/KmPackageVisitor;)V public final fun getFacadeClassName ()Ljava/lang/String; public fun getFlags ()I public final fun getKmPackage ()Lkotlin/metadata/KmPackage; @@ -1591,21 +901,11 @@ public final class kotlin/metadata/jvm/KotlinClassMetadata$MultiFileClassPart : public fun setFlags (I)V public final fun setKmPackage (Lkotlin/metadata/KmPackage;)V public fun setVersion (Lkotlin/metadata/jvm/JvmMetadataVersion;)V - public final fun toKmPackage ()Lkotlin/metadata/KmPackage; public fun write ()Lkotlin/Metadata; } -public final class kotlin/metadata/jvm/KotlinClassMetadata$MultiFileClassPart$Writer : kotlin/metadata/internal/PackageWriter { - public fun ()V - public final fun write (Ljava/lang/String;)Lkotlin/metadata/jvm/KotlinClassMetadata$MultiFileClassPart; - public final fun write (Ljava/lang/String;[I)Lkotlin/metadata/jvm/KotlinClassMetadata$MultiFileClassPart; - public final fun write (Ljava/lang/String;[II)Lkotlin/metadata/jvm/KotlinClassMetadata$MultiFileClassPart; - public static synthetic fun write$default (Lkotlin/metadata/jvm/KotlinClassMetadata$MultiFileClassPart$Writer;Ljava/lang/String;[IIILjava/lang/Object;)Lkotlin/metadata/jvm/KotlinClassMetadata$MultiFileClassPart; -} - public final class kotlin/metadata/jvm/KotlinClassMetadata$SyntheticClass : kotlin/metadata/jvm/KotlinClassMetadata { public fun (Lkotlin/metadata/KmLambda;Lkotlin/metadata/jvm/JvmMetadataVersion;I)V - public final fun accept (Lkotlin/metadata/KmLambdaVisitor;)V public fun getFlags ()I public final fun getKmLambda ()Lkotlin/metadata/KmLambda; public fun getVersion ()Lkotlin/metadata/jvm/JvmMetadataVersion; @@ -1613,21 +913,10 @@ public final class kotlin/metadata/jvm/KotlinClassMetadata$SyntheticClass : kotl public fun setFlags (I)V public final fun setKmLambda (Lkotlin/metadata/KmLambda;)V public fun setVersion (Lkotlin/metadata/jvm/JvmMetadataVersion;)V - public final fun toKmLambda ()Lkotlin/metadata/KmLambda; public fun write ()Lkotlin/Metadata; } -public final class kotlin/metadata/jvm/KotlinClassMetadata$SyntheticClass$Writer : kotlin/metadata/internal/LambdaWriter { - public fun ()V - public final fun write ()Lkotlin/metadata/jvm/KotlinClassMetadata$SyntheticClass; - public final fun write ([I)Lkotlin/metadata/jvm/KotlinClassMetadata$SyntheticClass; - public final fun write ([II)Lkotlin/metadata/jvm/KotlinClassMetadata$SyntheticClass; - public static synthetic fun write$default (Lkotlin/metadata/jvm/KotlinClassMetadata$SyntheticClass$Writer;[IIILjava/lang/Object;)Lkotlin/metadata/jvm/KotlinClassMetadata$SyntheticClass; -} - public final class kotlin/metadata/jvm/KotlinClassMetadata$Unknown : kotlin/metadata/jvm/KotlinClassMetadata { - public static final field Companion Lkotlin/metadata/jvm/KotlinClassMetadata$Unknown$Companion; - public static final field INSTANCE Lkotlin/metadata/jvm/KotlinClassMetadata$Unknown; public fun getFlags ()I public fun getVersion ()Lkotlin/metadata/jvm/JvmMetadataVersion; public fun setFlags (I)V @@ -1635,35 +924,19 @@ public final class kotlin/metadata/jvm/KotlinClassMetadata$Unknown : kotlin/meta public fun write ()Lkotlin/Metadata; } -public final class kotlin/metadata/jvm/KotlinClassMetadata$Unknown$Companion { -} - public final class kotlin/metadata/jvm/KotlinModuleMetadata { public static final field Companion Lkotlin/metadata/jvm/KotlinModuleMetadata$Companion; public fun (Lkotlin/metadata/jvm/KmModule;Lkotlin/metadata/jvm/JvmMetadataVersion;)V - public final fun accept (Lkotlin/metadata/jvm/KmModuleVisitor;)V public final fun getKmModule ()Lkotlin/metadata/jvm/KmModule; public final fun getVersion ()Lkotlin/metadata/jvm/JvmMetadataVersion; public static final fun read ([B)Lkotlin/metadata/jvm/KotlinModuleMetadata; public final fun setKmModule (Lkotlin/metadata/jvm/KmModule;)V public final fun setVersion (Lkotlin/metadata/jvm/JvmMetadataVersion;)V - public final fun toKmModule ()Lkotlin/metadata/jvm/KmModule; public final fun write ()[B - public static final fun write (Lkotlin/metadata/jvm/KmModule;)[B - public static final fun write (Lkotlin/metadata/jvm/KmModule;Lkotlin/metadata/jvm/JvmMetadataVersion;)[B } public final class kotlin/metadata/jvm/KotlinModuleMetadata$Companion { public final fun read ([B)Lkotlin/metadata/jvm/KotlinModuleMetadata; - public final fun write (Lkotlin/metadata/jvm/KmModule;)[B - public final fun write (Lkotlin/metadata/jvm/KmModule;Lkotlin/metadata/jvm/JvmMetadataVersion;)[B - public static synthetic fun write$default (Lkotlin/metadata/jvm/KotlinModuleMetadata$Companion;Lkotlin/metadata/jvm/KmModule;Lkotlin/metadata/jvm/JvmMetadataVersion;ILjava/lang/Object;)[B -} - -public final class kotlin/metadata/jvm/KotlinModuleMetadata$Writer { - public fun ()V - public final fun write ([I)[B - public static synthetic fun write$default (Lkotlin/metadata/jvm/KotlinModuleMetadata$Writer;[IILjava/lang/Object;)[B } public abstract interface annotation class kotlin/metadata/jvm/UnstableMetadataApi : java/lang/annotation/Annotation { diff --git a/libraries/kotlinx-metadata/jvm/src/kotlin/metadata/jvm/JvmAttributes.kt b/libraries/kotlinx-metadata/jvm/src/kotlin/metadata/jvm/JvmAttributes.kt index 90c58ebeb42..f20262fc4d5 100644 --- a/libraries/kotlinx-metadata/jvm/src/kotlin/metadata/jvm/JvmAttributes.kt +++ b/libraries/kotlinx-metadata/jvm/src/kotlin/metadata/jvm/JvmAttributes.kt @@ -3,7 +3,6 @@ * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ -@file:Suppress("DEPRECATION_ERROR") // flags will become internal eventually @file:JvmName("JvmAttributes") package kotlin.metadata.jvm @@ -11,6 +10,7 @@ package kotlin.metadata.jvm import kotlin.metadata.* import kotlin.metadata.internal.* import org.jetbrains.kotlin.metadata.deserialization.Flags +import kotlin.metadata.jvm.internal.jvm import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmFlags as JF /** @@ -55,3 +55,16 @@ public var KmClass.isCompiledInCompatibilityMode: Boolean by BooleanFlagDelegate private fun booleanFlag(f: Flags.BooleanFlagField): FlagImpl = FlagImpl(f.offset, f.bitWidth, 1) + +private var KmProperty.jvmFlags: Int + get() = jvm.jvmFlags + set(value) { + jvm.jvmFlags = value + } + + +private var KmClass.jvmFlags: Int + get() = jvm.jvmFlags + set(value) { + jvm.jvmFlags = value + } diff --git a/libraries/kotlinx-metadata/jvm/src/kotlin/metadata/jvm/JvmExtensionVisitors.kt b/libraries/kotlinx-metadata/jvm/src/kotlin/metadata/jvm/JvmExtensionVisitors.kt deleted file mode 100644 index b9b0ca3db2f..00000000000 --- a/libraries/kotlinx-metadata/jvm/src/kotlin/metadata/jvm/JvmExtensionVisitors.kt +++ /dev/null @@ -1,379 +0,0 @@ -/* - * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ -@file:Suppress("DEPRECATION_ERROR") // delegate implementation - -package kotlin.metadata.jvm - -import kotlin.metadata.* -import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmProtoBufUtil - -/** - * A visitor containing the common code to visit JVM extensions for Kotlin declaration containers, such as classes and package fragments. - */ -@Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) -public abstract class JvmDeclarationContainerExtensionVisitor @JvmOverloads constructor( - protected open val delegate: JvmDeclarationContainerExtensionVisitor? = null -) : KmDeclarationContainerExtensionVisitor { - /** - * Visits the metadata of a local delegated property used somewhere inside this container (but not in a nested declaration container). - * Note that for classes produced by the Kotlin compiler, such properties will have default accessors. - * - * The order of visited local delegated properties is important. The Kotlin compiler generates the corresponding property's index - * at the call site, so that reflection would be able to load the metadata of the property with that index at runtime. - * If an incorrect index is used, either the `KProperty<*>` object passed to delegate methods will point to the wrong property - * at runtime, or an exception will be thrown. - * - * @param flags property flags, consisting of [Flag.HAS_ANNOTATIONS], visibility flag, modality flag and [Flag.Property] flags - * @param name the name of the property - * @param getterFlags property accessor flags, consisting of [Flag.HAS_ANNOTATIONS], visibility flag, modality flag - * and [Flag.PropertyAccessor] flags - * @param setterFlags property accessor flags, consisting of [Flag.HAS_ANNOTATIONS], visibility flag, modality flag - * and [Flag.PropertyAccessor] flags - */ - public open fun visitLocalDelegatedProperty(flags: Int, name: String, getterFlags: Int, setterFlags: Int): KmPropertyVisitor? = - delegate?.visitLocalDelegatedProperty(flags, name, getterFlags, setterFlags) - - /** - * Visits the name of the module where this container is declared. - */ - public open fun visitModuleName(name: String) { - delegate?.visitModuleName(name) - } -} - -/** - * A visitor to visit JVM extensions for a class. - */ -@Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) -public open class JvmClassExtensionVisitor @JvmOverloads constructor( - delegate: JvmClassExtensionVisitor? = null -) : KmClassExtensionVisitor, JvmDeclarationContainerExtensionVisitor(delegate) { - override val delegate: JvmClassExtensionVisitor? - get() = super.delegate as JvmClassExtensionVisitor? - - final override val type: KmExtensionType - get() = TYPE - - /** - * Visits the JVM internal name of the original class this anonymous object is copied from. This method is called for - * anonymous objects copied from bodies of inline functions to the use site by the Kotlin compiler. - */ - public open fun visitAnonymousObjectOriginName(internalName: String) { - delegate?.visitAnonymousObjectOriginName(internalName) - } - - /** - * Visits the JVM-specific flags of the class, consisting of [JvmFlag.Class] flags. - */ - public open fun visitJvmFlags(flags: Int) { - delegate?.visitJvmFlags(flags) - } - - /** - * Visits the end of JVM extensions for the class. - */ - public open fun visitEnd() { - delegate?.visitEnd() - } - - public companion object { - /** - * The type of this extension visitor. - * - * @see KmExtensionType - */ - @JvmField - public val TYPE: KmExtensionType = KmExtensionType(JvmClassExtensionVisitor::class) - } -} - -/** - * A visitor to visit JVM extensions for a package fragment. - */ -@Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) -public open class JvmPackageExtensionVisitor @JvmOverloads constructor( - delegate: JvmPackageExtensionVisitor? = null -) : KmPackageExtensionVisitor, JvmDeclarationContainerExtensionVisitor(delegate) { - override val delegate: JvmPackageExtensionVisitor? - get() = super.delegate as JvmPackageExtensionVisitor? - - final override val type: KmExtensionType - get() = TYPE - - /** - * Visits the end of JVM extensions for the package fragment. - */ - public open fun visitEnd() { - delegate?.visitEnd() - } - - public companion object { - /** - * The type of this extension visitor. - * - * @see KmExtensionType - */ - @JvmField - public val TYPE: KmExtensionType = KmExtensionType(JvmPackageExtensionVisitor::class) - } -} - -/** - * A visitor to visit JVM extensions for a function. - */ -@Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) -public open class JvmFunctionExtensionVisitor @JvmOverloads constructor( - private val delegate: JvmFunctionExtensionVisitor? = null -) : KmFunctionExtensionVisitor { - final override val type: KmExtensionType - get() = TYPE - - /** - * Visits the JVM signature of the function, or null if the JVM signature of this function is unknown. - * - * Example: `JvmMethodSignature("equals", "(Ljava/lang/Object;)Z")` - * - * @param signature the signature of the function - */ - public open fun visit(signature: JvmMethodSignature?) { - delegate?.visit(signature) - } - - /** - * Visits the JVM internal name of the original class the lambda class for this function is copied from. - * This information is present for lambdas copied from bodies of inline functions to the use site by the Kotlin compiler. - */ - public open fun visitLambdaClassOriginName(internalName: String) { - delegate?.visitLambdaClassOriginName(internalName) - } - - /** - * Visits the end of JVM extensions for the function. - */ - public open fun visitEnd() { - delegate?.visitEnd() - } - - public companion object { - /** - * The type of this extension visitor. - * - * @see KmExtensionType - */ - @JvmField - public val TYPE: KmExtensionType = KmExtensionType(JvmFunctionExtensionVisitor::class) - } -} - -/** - * A visitor to visit JVM extensions for a property. - */ -@Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) -public open class JvmPropertyExtensionVisitor @JvmOverloads constructor( - private val delegate: JvmPropertyExtensionVisitor? = null -) : KmPropertyExtensionVisitor { - final override val type: KmExtensionType - get() = TYPE - - /** - * Visits JVM signatures of field and accessors generated for the property. - * - * @param jvmFlags JVM-specific flags of the property, consisting of [JvmFlag.Property] flags - * @param fieldSignature the signature of the backing field of the property, or `null` if this property has no backing field. - * Example: `JvmFieldSignature("X", "Ljava/lang/Object;")` - * @param getterSignature the signature of the property getter, or `null` if this property has no getter or its signature is unknown. - * Example: `JvmMethodSignature("getX", "()Ljava/lang/Object;")` - * @param setterSignature the signature of the property setter, or `null` if this property has no setter or its signature is unknown. - * Example: `JvmMethodSignature("setX", "(Ljava/lang/Object;)V")` - */ - public open fun visit( - jvmFlags: Int, - fieldSignature: JvmFieldSignature?, - getterSignature: JvmMethodSignature?, - setterSignature: JvmMethodSignature? - ) { - delegate?.visit(jvmFlags, fieldSignature, getterSignature, setterSignature) - - @Suppress("DEPRECATION_ERROR") - visit(fieldSignature, getterSignature, setterSignature) - } - - @Deprecated( - "Use visit(Flags, JvmFieldSignature?, JvmMethodSignature?, JvmMethodSignature?) instead.", - level = DeprecationLevel.ERROR, - replaceWith = ReplaceWith("visit(flagsOf(), fieldSignature, getterSignature, setterSignature)", "kotlinx.metadata.flagsOf") - ) - public open fun visit( - fieldSignature: JvmFieldSignature?, - getterSignature: JvmMethodSignature?, - setterSignature: JvmMethodSignature? - ) { - @Suppress("DEPRECATION_ERROR") - delegate?.visit(fieldSignature, getterSignature, setterSignature) - } - - /** - * Visits the JVM signature of a synthetic method which is generated to store annotations on a property in the bytecode. - * - * Example: `JvmMethodSignature("getX$annotations", "()V")` - * - * @param signature the signature of the synthetic method - */ - public open fun visitSyntheticMethodForAnnotations(signature: JvmMethodSignature?) { - delegate?.visitSyntheticMethodForAnnotations(signature) - } - - /** - * Visits the JVM signature of a synthetic method which is generated when a delegated property's delegate object is - * optimized out, e.g. because it is constant; in that case, a copy of that object can be obtained on demand by calling - * this method. It takes the property's receivers as arguments. - * - * Example: `JvmMethodSignature("getX$delegate", "(LMyClass;)LMyDelegate;")` - * - * @param signature the signature of the synthetic method - */ - public open fun visitSyntheticMethodForDelegate(signature: JvmMethodSignature?) { - delegate?.visitSyntheticMethodForDelegate(signature) - } - - /** - * Visits the end of JVM extensions for the property. - */ - public open fun visitEnd() { - delegate?.visitEnd() - } - - public companion object { - /** - * The type of this extension visitor. - * - * @see KmExtensionType - */ - @JvmField - public val TYPE: KmExtensionType = KmExtensionType(JvmPropertyExtensionVisitor::class) - } -} - -/** - * A visitor to visit JVM extensions for a constructor. - */ -@Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) -public open class JvmConstructorExtensionVisitor @JvmOverloads constructor( - private val delegate: JvmConstructorExtensionVisitor? = null -) : KmConstructorExtensionVisitor { - final override val type: KmExtensionType - get() = TYPE - - /** - * Visits the JVM signature of the constructor, or null if the JVM signature of this constructor is unknown. - * - * Example: `JvmMethodSignature("", "(Ljava/lang/Object;)V")` - * - * @param signature the signature of the constructor - */ - public open fun visit(signature: JvmMethodSignature?) { - delegate?.visit(signature) - } - - public companion object { - /** - * The type of this extension visitor. - * - * @see KmExtensionType - */ - @JvmField - public val TYPE: KmExtensionType = KmExtensionType(JvmConstructorExtensionVisitor::class) - } -} - -/** - * A visitor to visit JVM extensions for a type parameter. - */ -@Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) -public open class JvmTypeParameterExtensionVisitor @JvmOverloads constructor( - private val delegate: JvmTypeParameterExtensionVisitor? = null -) : KmTypeParameterExtensionVisitor { - final override val type: KmExtensionType - get() = TYPE - - /** - * Visits an annotation on the type parameter. - * - * @param annotation the annotation on the type parameter - */ - public open fun visitAnnotation(annotation: KmAnnotation) { - delegate?.visitAnnotation(annotation) - } - - /** - * Visits the end of JVM extensions for the type parameter. - */ - public open fun visitEnd() { - delegate?.visitEnd() - } - - public companion object { - /** - * The type of this extension visitor. - * - * @see KmExtensionType - */ - @JvmField - public val TYPE: KmExtensionType = KmExtensionType(JvmTypeParameterExtensionVisitor::class) - } -} - -/** - * A visitor to visit JVM extensions for a type. - */ -@Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) -public open class JvmTypeExtensionVisitor @JvmOverloads constructor( - private val delegate: JvmTypeExtensionVisitor? = null -) : KmTypeExtensionVisitor { - final override val type: KmExtensionType - get() = TYPE - - /** - * Visits the JVM-specific flags of a type. - * - * @param isRaw whether the type is seen as a raw type in Java - */ - public open fun visit(isRaw: Boolean) { - delegate?.visit(isRaw) - } - - /** - * Visits an annotation on the type. - * - * @param annotation the annotation on the type - */ - public open fun visitAnnotation(annotation: KmAnnotation) { - delegate?.visitAnnotation(annotation) - } - - /** - * Visits the end of JVM extensions for the type parameter. - */ - public open fun visitEnd() { - delegate?.visitEnd() - } - - public companion object { - /** - * The type of this extension visitor. - * - * @see KmExtensionType - */ - @JvmField - public val TYPE: KmExtensionType = KmExtensionType(JvmTypeExtensionVisitor::class) - - /** - * The type flexibility id, signifying that the visited type is a JVM platform type. - * - * @see KmTypeVisitor.visitFlexibleTypeUpperBound - */ - public const val PLATFORM_TYPE_ID: String = JvmProtoBufUtil.PLATFORM_TYPE_ID // TODO: move out of deprecated visitor - } -} diff --git a/libraries/kotlinx-metadata/jvm/src/kotlin/metadata/jvm/JvmExtensions.kt b/libraries/kotlinx-metadata/jvm/src/kotlin/metadata/jvm/JvmExtensions.kt index f331395c922..a3f76fe8680 100644 --- a/libraries/kotlinx-metadata/jvm/src/kotlin/metadata/jvm/JvmExtensions.kt +++ b/libraries/kotlinx-metadata/jvm/src/kotlin/metadata/jvm/JvmExtensions.kt @@ -42,19 +42,6 @@ public var KmClass.anonymousObjectOriginName: String? jvm.anonymousObjectOriginName = value } -/** - * JVM-specific flags of the class, consisting of [JvmFlag.Class] flags. - */ -@Deprecated( - "Flag API is deprecated. Please use corresponding member extensions on KmClass, such as KmClass.hasMethodBodiesInInterface", - level = DeprecationLevel.ERROR -) -public var KmClass.jvmFlags: Int - get() = jvm.jvmFlags - set(value) { - jvm.jvmFlags = value - } - /** * Metadata of local delegated properties used somewhere inside this package fragment (but not in any class). * Note that for classes produced by the Kotlin compiler, such properties will have default accessors. @@ -97,19 +84,6 @@ public var KmFunction.lambdaClassOriginName: String? jvm.lambdaClassOriginName = value } -/** - * JVM-specific flags of the property, consisting of [JvmFlag.Property] flags. - */ -@Deprecated( - "Flag API is deprecated. Please use corresponding member extensions on KmProperty, such as KmProperty.isMovedFromInterfaceCompanion", - level = DeprecationLevel.ERROR -) -public var KmProperty.jvmFlags: Int - get() = jvm.jvmFlags - set(value) { - jvm.jvmFlags = value - } - /** * JVM signature of the backing field of the property, or `null` if this property has no backing field. * diff --git a/libraries/kotlinx-metadata/jvm/src/kotlin/metadata/jvm/JvmFlag.kt b/libraries/kotlinx-metadata/jvm/src/kotlin/metadata/jvm/JvmFlag.kt deleted file mode 100644 index 8e2d0663064..00000000000 --- a/libraries/kotlinx-metadata/jvm/src/kotlin/metadata/jvm/JvmFlag.kt +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -@file:Suppress("DEPRECATION_ERROR") - -package kotlin.metadata.jvm - -import kotlin.metadata.Flag -import org.jetbrains.kotlin.metadata.deserialization.Flags as F -import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmFlags as JF - -private const val prefix = "Flag API is deprecated. Please use" - -/** - * JVM-specific flags in addition to common flags declared in [Flag]. - * - * @see Flag - * @see Flags - */ -@Deprecated("$prefix corresponding extensions on Km nodes, such as KmClass.hasMethodBodiesInInterface", level = DeprecationLevel.ERROR) -public object JvmFlag { - /** - * JVM-specific property flags in addition to common property flags declared in [Flag.Property]. - */ - @Deprecated("$prefix corresponding extension on KmProperty: KmProperty.isMovedFromInterfaceCompanion", level = DeprecationLevel.ERROR) - public object Property { - /** - * Applied to a property declared in an interface's companion object, signifies that its backing field is declared as a static - * field in the interface. In Kotlin code, this usually happens if the property is annotated with [JvmField]. - * - * Has no effect if the property is not declared in a companion object of some interface. - */ - @JvmField - @Deprecated("$prefix KmProperty.isMovedFromInterfaceCompanion", level = DeprecationLevel.ERROR) - public val IS_MOVED_FROM_INTERFACE_COMPANION: Flag = booleanFlag(JF.IS_MOVED_FROM_INTERFACE_COMPANION) - } - - /** - * JVM-specific class flags in addition to common class flags declared in [Flag.Class]. - */ - @Deprecated("$prefix corresponding extensions on KmClass", level = DeprecationLevel.ERROR) - public object Class { - /** - * Applied to an interface compiled with -Xjvm-default=all or all-compatibility. - * - * Without this flag or a `@JvmDefault` annotation on individual interface methods - * the Kotlin compiler moves all interface method bodies into a nested `DefaultImpls` - * class. - */ - @JvmField - @Deprecated("$prefix KmClass.hasMethodBodiesInInterface", level = DeprecationLevel.ERROR) - public val HAS_METHOD_BODIES_IN_INTERFACE: Flag = booleanFlag(JF.IS_COMPILED_IN_JVM_DEFAULT_MODE) - - /** - * Applied to an interface compiled with -Xjvm-default=all-compatibility. - * - * In compatibility mode we generate method bodies directly in the interface, - * but we also generate bridges in a nested `DefaultImpls` class for use by - * clients compiled without all-compatibility. - */ - @JvmField - @Deprecated("$prefix KmClass.isCompiledInCompatibilityMode", level = DeprecationLevel.ERROR) - public val IS_COMPILED_IN_COMPATIBILITY_MODE: Flag = booleanFlag(JF.IS_COMPILED_IN_COMPATIBILITY_MODE) - } - - internal fun booleanFlag(f: F.BooleanFlagField): Flag = - Flag(f.offset, f.bitWidth, 1) -} diff --git a/libraries/kotlinx-metadata/jvm/src/kotlin/metadata/jvm/JvmMemberSignature.kt b/libraries/kotlinx-metadata/jvm/src/kotlin/metadata/jvm/JvmMemberSignature.kt index 5391c2e335e..2f3f60cad02 100644 --- a/libraries/kotlinx-metadata/jvm/src/kotlin/metadata/jvm/JvmMemberSignature.kt +++ b/libraries/kotlinx-metadata/jvm/src/kotlin/metadata/jvm/JvmMemberSignature.kt @@ -26,18 +26,6 @@ public sealed class JvmMemberSignature { * In case of a field [name] and [descriptor] are concatenated with `:` separator, e.g. `value:Ljava/lang/String;` */ abstract override fun toString(): String - - // Two following declarations are deprecated since 0.6.1, should be error in 0.7.0+ - - @Deprecated("Deprecated for removal. Use descriptor instead", ReplaceWith("descriptor"), level = DeprecationLevel.ERROR) - public val desc: String get() = descriptor - - @Deprecated( - "asString() is deprecated as redundant. Use toString() instead", - ReplaceWith("toString()"), - level = DeprecationLevel.ERROR - ) - public fun asString(): String = toString() } /** diff --git a/libraries/kotlinx-metadata/jvm/src/kotlin/metadata/jvm/JvmMetadataUtil.kt b/libraries/kotlinx-metadata/jvm/src/kotlin/metadata/jvm/JvmMetadataUtil.kt index ad696da24ff..c55298a0c52 100644 --- a/libraries/kotlinx-metadata/jvm/src/kotlin/metadata/jvm/JvmMetadataUtil.kt +++ b/libraries/kotlinx-metadata/jvm/src/kotlin/metadata/jvm/JvmMetadataUtil.kt @@ -18,14 +18,6 @@ public fun ClassName.toJvmInternalName(): String = if (this.isLocalClassName()) substring(1) else replace('.', '$') -// Deprecated since 0.6.1, should be error in 0.7.0+ -@Deprecated( - "Renamed to toJvmInternalName() to avoid confusion with String properties", - ReplaceWith("toJvmInternalName()"), - level = DeprecationLevel.ERROR -) -public val ClassName.jvmInternalName: String get() = toJvmInternalName() - /** * Helper function to instantiate [Metadata]. * Contrary to a direct constructor call, this one accepts nullable parameters to substitute nulls with default values. diff --git a/libraries/kotlinx-metadata/jvm/src/kotlin/metadata/jvm/KotlinClassHeader.java b/libraries/kotlinx-metadata/jvm/src/kotlin/metadata/jvm/KotlinClassHeader.java index 41249680c47..8a57ed108c7 100644 --- a/libraries/kotlinx-metadata/jvm/src/kotlin/metadata/jvm/KotlinClassHeader.java +++ b/libraries/kotlinx-metadata/jvm/src/kotlin/metadata/jvm/KotlinClassHeader.java @@ -146,40 +146,4 @@ public final class KotlinClassHeader implements Metadata { } // TODO: equals, hashCode, etc as in Java Annotation contract? - - /** - * Use {@link KotlinClassMetadata#CLASS_KIND} instead - */ - @Deprecated - public static final int CLASS_KIND = 1; - - /** - * Use {@link KotlinClassMetadata#FILE_FACADE_KIND} instead - */ - @Deprecated - public static final int FILE_FACADE_KIND = 2; - - /** - * Use {@link KotlinClassMetadata#SYNTHETIC_CLASS_KIND} instead - */ - @Deprecated - public static final int SYNTHETIC_CLASS_KIND = 3; - - /** - * Use {@link KotlinClassMetadata#MULTI_FILE_CLASS_FACADE_KIND} instead - */ - @Deprecated - public static final int MULTI_FILE_CLASS_FACADE_KIND = 4; - - /** - * Use {@link KotlinClassMetadata#MULTI_FILE_CLASS_PART_KIND} instead - */ - @Deprecated - public static final int MULTI_FILE_CLASS_PART_KIND = 5; - - /** - * Use {@link kotlinx.metadata.jvm.JvmMetadataVersion#LATEST_STABLE_SUPPORTED} instead - */ - @Deprecated - public static final int[] COMPATIBLE_METADATA_VERSION = Arrays.copyOf(JvmMetadataVersion.INSTANCE.toArray(), 3); } diff --git a/libraries/kotlinx-metadata/jvm/src/kotlin/metadata/jvm/KotlinClassMetadata.kt b/libraries/kotlinx-metadata/jvm/src/kotlin/metadata/jvm/KotlinClassMetadata.kt index bae446080da..499cb315f06 100644 --- a/libraries/kotlinx-metadata/jvm/src/kotlin/metadata/jvm/KotlinClassMetadata.kt +++ b/libraries/kotlinx-metadata/jvm/src/kotlin/metadata/jvm/KotlinClassMetadata.kt @@ -2,19 +2,12 @@ * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ -@file:Suppress( - "DEPRECATION_ERROR", // Deprecated .accept implementation - "DEPRECATION", // COMPATIBLE_METADATA_VERSION as default param - "UNUSED_PARAMETER" // For deprecated Writer.write -) - package kotlin.metadata.jvm import kotlin.metadata.* import kotlin.metadata.internal.* import kotlin.metadata.jvm.internal.* import kotlin.metadata.jvm.internal.JvmReadUtils.readMetadataImpl -import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmMetadataVersion as CompilerMetadataVersion import org.jetbrains.kotlin.metadata.jvm.serialization.JvmStringTable import java.util.* @@ -114,53 +107,6 @@ public sealed class KotlinClassMetadata { Metadata(CLASS_KIND, version.toIntArray(), d1, d2, extraInt = flags) } } - - /** - * Returns a new [KmClass] instance created from this class metadata. - */ - @Deprecated( - "To avoid excessive copying, use .kmClass property instead. Note that it returns a view and not a copy.", - ReplaceWith("kmClass"), - DeprecationLevel.ERROR - ) - public fun toKmClass(): KmClass = KmClass().also { newKm -> kmClass.accept(newKm) } // defensive copy - - /** - * Makes the given visitor visit the metadata of this class. - * - * @param v the visitor that must visit this class - */ - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - public fun accept(v: KmClassVisitor): Unit = kmClass.accept(v) - - /** - * A [KmClassVisitor] that generates the metadata of a Kotlin class. - */ - @Deprecated( - "$WRITER_API_MESSAGE, such as KotlinClassMetadata.writeClass(kmClass, metadataVersion, extraInt)", - level = DeprecationLevel.ERROR - ) - public class Writer : ClassWriter(JvmStringTable()) { - /** - * Returns the metadata of the class that was written with this writer. - * - * @param metadataVersion metadata version to be written to the metadata (see [Metadata.metadataVersion]), - * [KotlinClassMetadata.COMPATIBLE_METADATA_VERSION] by default. Cannot be less (lexicographically) than `[1, 4]` - * @param extraInt the value of the class-level flags to be written to the metadata (see [Metadata.extraInt]), - * 0 by default - */ - @JvmOverloads - @Deprecated( - "$WRITER_API_MESSAGE, such as KotlinClassMetadata.writeClass(kmClass, metadataVersion, extraInt)", - level = DeprecationLevel.ERROR - ) - public fun write( - metadataVersion: IntArray = COMPATIBLE_METADATA_VERSION, - extraInt: Int = 0 - ): Class { - error("This method is no longer implemented. Migrate to KotlinClassMetadata.writeClass.") - } - } } /** @@ -206,53 +152,6 @@ public sealed class KotlinClassMetadata { Metadata(FILE_FACADE_KIND, version.toIntArray(), d1, d2, extraInt = flags) } } - - /** - * Creates a new [KmPackage] instance from this file facade metadata. - */ - @Deprecated( - "To avoid excessive copying, use .kmPackage property instead. Note that it returns a view and not a copy.", - ReplaceWith("kmPackage"), - DeprecationLevel.ERROR - ) - public fun toKmPackage(): KmPackage = KmPackage().also { newPkg -> kmPackage.accept(newPkg) } - - /** - * Makes the given visitor visit metadata of this file facade. - * - * @param v the visitor that must visit this file facade - */ - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - public fun accept(v: KmPackageVisitor): Unit = kmPackage.accept(v) - - /** - * A [KmPackageVisitor] that generates the metadata of a Kotlin file facade. - */ - @Deprecated( - "$WRITER_API_MESSAGE, such as KotlinClassMetadata.writeFileFacade(kmPackage, metadataVersion, extraInt)", - level = DeprecationLevel.ERROR - ) - public class Writer : PackageWriter(JvmStringTable()) { - /** - * Returns the metadata of the file facade that was written with this writer. - * - * @param metadataVersion metadata version to be written to the metadata (see [Metadata.metadataVersion]), - * [KotlinClassMetadata.COMPATIBLE_METADATA_VERSION] by default. Cannot be less (lexicographically) than `[1, 4]` - * @param extraInt the value of the class-level flags to be written to the metadata (see [Metadata.extraInt]), - * 0 by default - */ - @JvmOverloads - @Deprecated( - "$WRITER_API_MESSAGE, such as KotlinClassMetadata.writeFileFacade(kmPackage, metadataVersion, extraInt)", - level = DeprecationLevel.ERROR - ) - public fun write( - metadataVersion: IntArray = COMPATIBLE_METADATA_VERSION, - extraInt: Int = 0 - ): FileFacade { - error("This method is no longer implemented. Migrate to KotlinClassMetadata.writeFileFacade.") - } - } } /** @@ -305,67 +204,6 @@ public sealed class KotlinClassMetadata { */ public val isLambda: Boolean get() = kmLambda != null - - /** - * Creates a new [KmLambda] instance from this synthetic class metadata. - * Returns `null` if this synthetic class does not represent a lambda. - */ - @Deprecated( - "To avoid excessive copying, use .kmLambda property instead. Note that it returns a view and not a copy.", - ReplaceWith("kmLambda"), - DeprecationLevel.ERROR - ) - public fun toKmLambda(): KmLambda? = if (isLambda) KmLambda().apply(this::accept) else null - - /** - * Makes the given visitor visit metadata of this file facade if this synthetic class represents a Kotlin lambda - * (`isLambda` == true). - * - * Throws [IllegalArgumentException] if this synthetic class does not represent a Kotlin lambda. - * - * @param v the visitor that must visit this lambda - */ - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - public fun accept(v: KmLambdaVisitor) { - if (!isLambda) throw IllegalArgumentException( - "accept(KmLambdaVisitor) is only possible for synthetic classes which are lambdas (isLambda = true)" - ) - - kmLambda!!.accept(v) - } - - /** - * A [KmLambdaVisitor] that generates the metadata of a synthetic class. To generate metadata of a Kotlin lambda, - * call [Writer.visitFunction] and [Writer.visitEnd] on a newly created instance of this writer. If these methods are not called, - * the resulting metadata will represent a _non-lambda_ synthetic class. - */ - @Deprecated( - WRITER_API_MESSAGE + ": KotlinClassMetadata.writeLambda(kmLambda, metadataVersion, extraInt) " + - "or KotlinClassMetadata.writeSyntheticClass(metadataVersion, extraInt) for a non-lambda synthetic class", - level = DeprecationLevel.ERROR - ) - public class Writer : LambdaWriter(JvmStringTable()) { - /** - * Returns the metadata of the synthetic class that was written with this writer. - * - * @param metadataVersion metadata version to be written to the metadata (see [Metadata.metadataVersion]), - * [KotlinClassMetadata.COMPATIBLE_METADATA_VERSION] by default. Cannot be less (lexicographically) than `[1, 4]` - * @param extraInt the value of the class-level flags to be written to the metadata (see [Metadata.extraInt]), - * 0 by default - */ - @Deprecated( - WRITER_API_MESSAGE + ": KotlinClassMetadata.writeLambda(kmLambda, metadataVersion, extraInt) " + - "or KotlinClassMetadata.writeSyntheticClass(metadataVersion, extraInt) for a non-lambda synthetic class", - level = DeprecationLevel.ERROR - ) - @JvmOverloads - public fun write( - metadataVersion: IntArray = COMPATIBLE_METADATA_VERSION, - extraInt: Int = 0 - ): SyntheticClass { - error("This method is no longer implemented. Migrate to KotlinClassMetadata.writeLambda or KotlinClassMetadata.writeSyntheticClass.") - } - } } /** @@ -430,37 +268,6 @@ public sealed class KotlinClassMetadata { partClassNames.toTypedArray(), extraInt = flags ) } - - /** - * A writer that generates the metadata of a multi-file class facade. - */ - @Deprecated( - "$WRITER_API_MESSAGE, such as KotlinClassMetadata.writeMultiFileClassFacade(partClassNames, metadataVersion, extraInt)", - level = DeprecationLevel.ERROR - ) - public class Writer { - /** - * Returns the metadata of the multi-file class facade that was written with this writer. - * - * @param partClassNames JVM internal names of the part classes which this multi-file class combines - * @param metadataVersion metadata version to be written to the metadata (see [Metadata.metadataVersion]), - * [KotlinClassMetadata.COMPATIBLE_METADATA_VERSION] by default. Cannot be less (lexicographically) than `[1, 4]` - * @param extraInt the value of the class-level flags to be written to the metadata (see [Metadata.extraInt]), - * 0 by default - */ - @Deprecated( - "$WRITER_API_MESSAGE, such as KotlinClassMetadata.writeMultiFileClassFacade(partClassNames, metadataVersion, extraInt)", - level = DeprecationLevel.ERROR - ) - @JvmOverloads - public fun write( - partClassNames: List, - metadataVersion: IntArray = COMPATIBLE_METADATA_VERSION, - extraInt: Int = 0 - ): MultiFileClassFacade { - error("This method is no longer implemented. Migrate to KotlinClassMetadata.writeMultiFileClassFacade.") - } - } } /** @@ -516,57 +323,6 @@ public sealed class KotlinClassMetadata { ) } } - - /** - * Creates a new [KmPackage] instance from this multi-file class part metadata. - */ - @Deprecated( - "To avoid excessive copying, use .kmPackage property instead. Note that it returns a view and not a copy.", - ReplaceWith("kmPackage"), - DeprecationLevel.ERROR - ) - public fun toKmPackage(): KmPackage = KmPackage().also { newKmp -> kmPackage.accept(newKmp) } - - /** - * Makes the given visitor visit metadata of this multi-file class part. - * - * @param v the visitor that must visit this multi-file class part - */ - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - public fun accept(v: KmPackageVisitor) { - kmPackage.accept(v) - } - - /** - * A [KmPackageVisitor] that generates the metadata of a multi-file class part. - */ - @Deprecated( - "$WRITER_API_MESSAGE, such as KotlinClassMetadata.writeMultiFileClassPart(kmPackage, facadeClassName, metadataVersion, extraInt)", - level = DeprecationLevel.ERROR - ) - public class Writer : PackageWriter(JvmStringTable()) { - /** - * Returns the metadata of the multi-file class part that was written with this writer. - * - * @param facadeClassName JVM internal name of the corresponding multi-file class facade - * @param metadataVersion metadata version to be written to the metadata (see [Metadata.metadataVersion]), - * [KotlinClassMetadata.COMPATIBLE_METADATA_VERSION] by default. Cannot be less (lexicographically) than `[1, 4]` - * @param extraInt the value of the class-level flags to be written to the metadata (see [Metadata.extraInt]), - * 0 by default - */ - @Deprecated( - "$WRITER_API_MESSAGE, such as KotlinClassMetadata.writeMultiFileClassPart(kmPackage, facadeClassName, metadataVersion, extraInt)", - level = DeprecationLevel.ERROR - ) - @JvmOverloads - public fun write( - facadeClassName: String, - metadataVersion: IntArray = COMPATIBLE_METADATA_VERSION, - extraInt: Int = 0 - ): MultiFileClassPart { - error("This method is no longer implemented. Migrate to KotlinClassMetadata.writeMultifileClassPart.") - } - } } /** @@ -597,13 +353,6 @@ public sealed class KotlinClassMetadata { flags ) } - - @PublishedApi - @Deprecated("This declaration is intended for binary compatibility only", level = DeprecationLevel.HIDDEN) - internal companion object { - @JvmField // For binary compatibility with previous `data object Unknown` - public val INSTANCE: Unknown = Unknown(Metadata(kind = 99, metadataVersion = JvmMetadataVersion.LATEST_STABLE_SUPPORTED.toIntArray()), true) - } } /** @@ -627,152 +376,6 @@ public sealed class KotlinClassMetadata { return readStrict(metadata).apply(transformer).write() } - /** - * Writes contents of [kmClass] as the class metadata. - * - * @param metadataVersion metadata version to be written to the metadata (see [Metadata.metadataVersion]), - * [KotlinClassMetadata.COMPATIBLE_METADATA_VERSION] by default. Cannot be less (lexicographically) than `[1, 4]` - * @param extraInt the value of the class-level flags to be written to the metadata (see [Metadata.extraInt]), - * 0 by default - * - * @throws IllegalArgumentException if [kmClass] is not correct and cannot be written or if [metadataVersion] is not supported for writing. - */ - @JvmStatic - @JvmOverloads - @Deprecated("Use a KotlinClassMetadata.Class instance and its write() member function", level = DeprecationLevel.ERROR) - public fun writeClass( - kmClass: KmClass, - metadataVersion: IntArray = COMPATIBLE_METADATA_VERSION, - extraInt: Int = 0, - ): Metadata = Class(kmClass, JvmMetadataVersion(metadataVersion), extraInt).write() - - - /** - * Writes [kmPackage] contents as the file facade metadata. - * - * @param metadataVersion metadata version to be written to the metadata (see [Metadata.metadataVersion]), - * [KotlinClassMetadata.COMPATIBLE_METADATA_VERSION] by default. Cannot be less (lexicographically) than `[1, 4]` - * @param extraInt the value of the class-level flags to be written to the metadata (see [Metadata.extraInt]), - * 0 by default - * - * @throws IllegalArgumentException if [kmPackage] is not correct and cannot be written or if [metadataVersion] is not supported for writing. - */ - @JvmStatic - @JvmOverloads - @Deprecated("Use a KotlinClassMetadata.FileFacade instance and its write() member function", level = DeprecationLevel.ERROR) - public fun writeFileFacade( - kmPackage: KmPackage, - metadataVersion: IntArray = COMPATIBLE_METADATA_VERSION, - extraInt: Int = 0, - ): Metadata = FileFacade(kmPackage, JvmMetadataVersion(metadataVersion), extraInt).write() - - /** - * Writes [kmLambda] as the synthetic class metadata. - * - * @param metadataVersion metadata version to be written to the metadata (see [Metadata.metadataVersion]), - * [KotlinClassMetadata.COMPATIBLE_METADATA_VERSION] by default. Cannot be less (lexicographically) than `[1, 4]` - * @param extraInt the value of the class-level flags to be written to the metadata (see [Metadata.extraInt]), - * 0 by default - * - * @throws IllegalArgumentException if [kmLambda] is not correct and cannot be written or if [metadataVersion] is not supported for writing. - */ - @JvmStatic - @JvmOverloads - @Deprecated("Use a KotlinClassMetadata.SyntheticClass instance and its write() member function", level = DeprecationLevel.ERROR) - public fun writeLambda( - kmLambda: KmLambda, - metadataVersion: IntArray = COMPATIBLE_METADATA_VERSION, - extraInt: Int = 0, - ): Metadata = SyntheticClass(kmLambda, JvmMetadataVersion(metadataVersion), extraInt).write() - - /** - * Writes synthetic class metadata. - * - * @param metadataVersion metadata version to be written to the metadata (see [Metadata.metadataVersion]), - * [KotlinClassMetadata.COMPATIBLE_METADATA_VERSION] by default. Cannot be less (lexicographically) than `[1, 4]` - * @param extraInt the value of the class-level flags to be written to the metadata (see [Metadata.extraInt]), - * 0 by default - * - * @throws IllegalArgumentException if [metadataVersion] is not supported for writing. - */ - @JvmStatic - @JvmOverloads - @Deprecated("Use a KotlinClassMetadata.SyntheticClass instance and its write() member function", level = DeprecationLevel.ERROR) - public fun writeSyntheticClass( - metadataVersion: IntArray = COMPATIBLE_METADATA_VERSION, - extraInt: Int = 0, - ): Metadata = SyntheticClass(null, JvmMetadataVersion(metadataVersion), extraInt).write() - - /** - * Writes metadata of the multi-file class facade. - * - * @param partClassNames JVM internal names of the part classes which this multi-file class combines - * @param metadataVersion metadata version to be written to the metadata (see [Metadata.metadataVersion]), - * [KotlinClassMetadata.COMPATIBLE_METADATA_VERSION] by default. Cannot be less (lexicographically) than `[1, 4]` - * @param extraInt the value of the class-level flags to be written to the metadata (see [Metadata.extraInt]), - * 0 by default - * - * @throws IllegalArgumentException if [metadataVersion] is not supported for writing. - */ - @JvmStatic - @JvmOverloads - @Deprecated( - "Use a KotlinClassMetadata.MultiFileClassFacade instance and its write() member function", - level = DeprecationLevel.ERROR - ) - public fun writeMultiFileClassFacade( - partClassNames: List, metadataVersion: IntArray = COMPATIBLE_METADATA_VERSION, - extraInt: Int = 0, - ): Metadata = MultiFileClassFacade(partClassNames, JvmMetadataVersion(metadataVersion), extraInt).write() - - /** - * Writes the metadata of the multi-file class part. - * - * @param facadeClassName JVM internal name of the corresponding multi-file class facade - * @param metadataVersion metadata version to be written to the metadata (see [Metadata.metadataVersion]), - * [KotlinClassMetadata.COMPATIBLE_METADATA_VERSION] by default. Cannot be less (lexicographically) than `[1, 4]` - * @param extraInt the value of the class-level flags to be written to the metadata (see [Metadata.extraInt]), - * 0 by default - * - * @throws IllegalArgumentException if [kmPackage] is not correct and cannot be written or if [metadataVersion] is not supported for writing. - */ - @JvmStatic - @JvmOverloads - @Deprecated( - "Use a KotlinClassMetadata.MultiFileClassPart instance and its write() member function", - level = DeprecationLevel.ERROR - ) - public fun writeMultiFileClassPart( - kmPackage: KmPackage, - facadeClassName: String, - metadataVersion: IntArray = COMPATIBLE_METADATA_VERSION, - extraInt: Int = 0, - ): Metadata = MultiFileClassPart(kmPackage, facadeClassName, JvmMetadataVersion(metadataVersion), extraInt).write() - - /** - * Reads and parses the given annotation data of a Kotlin JVM class file and returns the correct type of [KotlinClassMetadata] encoded by - * this annotation, if metadata version is supported. - * - * [annotationData] may be obtained reflectively, constructed manually or with helper [kotlinx.metadata.jvm.Metadata] function, - * or equivalent [KotlinClassHeader] can be used. - * - * Metadata version is supported if it is greater or equal than 1.1, and less or equal than [COMPATIBLE_METADATA_VERSION] + 1 minor version. - * Note that metadata version is 1.1 for Kotlin < 1.4, and is equal to the language version starting from Kotlin 1.4. - * For example, if the latest Kotlin version is 1.7.0, the latest kotlinx-metadata-jvm can read binaries produced by Kotlin - * compilers from 1.0 to 1.8.* inclusively. - * - * @throws IllegalArgumentException if the metadata version is unsupported - * - * @see COMPATIBLE_METADATA_VERSION - */ - @JvmStatic - @Deprecated( - "read() throws an error if metadata version is too high. Use either readStrict() if you want to retain this behavior, or readLenient() if you want to try to read newer metadata.", - ReplaceWith("KotlinClassMetadata.readStrict(annotationData)"), - DeprecationLevel.ERROR - ) - public fun read(annotationData: Metadata): KotlinClassMetadata = readMetadataImpl(annotationData, lenient = false) - /** * Reads and parses the given annotation data of a Kotlin JVM class file and returns the correct type of [KotlinClassMetadata] encoded by * this annotation, if the metadata version is supported. @@ -867,28 +470,5 @@ public sealed class KotlinClassMetadata { * @see JvmMultifileClass */ public const val MULTI_FILE_CLASS_PART_KIND: Int = 5 - - /** - * The latest stable metadata version supported by this version of the library. - * The library can read in strict mode Kotlin metadata produced by Kotlin compilers from 1.0 up to and including this version + 1 minor. - * - * In other words, a metadata version is supported if it is greater or equal than 1.1, and less or equal than [COMPATIBLE_METADATA_VERSION] + 1 minor version. - * Note that a metadata version is 1.1 for Kotlin < 1.4, and is equal to the language version starting from Kotlin 1.4. - * - * For example, if the latest supported stable Kotlin version is 1.7.0, kotlinx-metadata-jvm can read binaries produced by Kotlin compilers from 1.0 - * to 1.8.* inclusively. In this case, this property will have the value `[1, 7, 0]`. - * - * @see Metadata.metadataVersion - */ - @JvmField - @Deprecated("Use JvmMetadataVersion.LATEST_STABLE_SUPPORTED instead", ReplaceWith("JvmMetadataVersion.LATEST_STABLE_SUPPORTED"), DeprecationLevel.ERROR) - public val COMPATIBLE_METADATA_VERSION: IntArray = CompilerMetadataVersion.INSTANCE.toArray().copyOf() - } } - -internal const val VISITOR_API_MESSAGE = - "Visitor API is deprecated as excessive and cumbersome. Please use nodes (such as KmClass) and their properties." - -internal const val WRITER_API_MESSAGE = - "Visitor Writer API is deprecated as excessive and cumbersome. Please use member functions of KotlinClassMetadata.Companion" diff --git a/libraries/kotlinx-metadata/jvm/src/kotlin/metadata/jvm/KotlinModuleMetadata.kt b/libraries/kotlinx-metadata/jvm/src/kotlin/metadata/jvm/KotlinModuleMetadata.kt index 9aa85a0f602..9eb91d46149 100644 --- a/libraries/kotlinx-metadata/jvm/src/kotlin/metadata/jvm/KotlinModuleMetadata.kt +++ b/libraries/kotlinx-metadata/jvm/src/kotlin/metadata/jvm/KotlinModuleMetadata.kt @@ -3,20 +3,12 @@ * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ -@file:Suppress( - "DEPRECATION", // COMPATIBLE_METADATA_VERSION - "DEPRECATION_ERROR", // KmModule.annotations - "UNUSED_PARAMETER" // For deprecated Writer.write -) - package kotlin.metadata.jvm import kotlin.metadata.* -import kotlin.metadata.jvm.KotlinClassMetadata.Companion.COMPATIBLE_METADATA_VERSION import kotlin.metadata.jvm.internal.JvmReadUtils.readModuleMetadataImpl import kotlin.metadata.jvm.internal.JvmReadUtils.throwIfNotCompatible import kotlin.metadata.jvm.internal.wrapIntoMetadataExceptionWhenNeeded -import kotlin.metadata.jvm.internal.wrapWriteIntoIAE import org.jetbrains.kotlin.metadata.jvm.JvmModuleProtoBuf import org.jetbrains.kotlin.metadata.jvm.deserialization.ModuleMapping import org.jetbrains.kotlin.metadata.jvm.deserialization.PackageParts @@ -46,16 +38,6 @@ public class KotlinModuleMetadata public constructor( */ public var version: JvmMetadataVersion, ) { - /** - * Visits metadata of this module with a new [KmModule] instance and returns that instance. - */ - @Deprecated( - "To avoid excessive copying, use .kmModule property instead. Note that it returns a view and not a copy.", - ReplaceWith("kmModule"), - DeprecationLevel.ERROR - ) - public fun toKmModule(): KmModule = KmModule().apply { kmModule.accept(this) } - /** * Encodes and writes this metadata of the Kotlin module file. * @@ -99,38 +81,6 @@ public class KotlinModuleMetadata public constructor( return b.build().serializeToByteArray(CompilerMetadataVersion(version.toIntArray(), false), 0) } - - /** - * A [KmModuleVisitor] that generates the metadata of a Kotlin JVM module file. - */ - @Deprecated( - "Writer API is deprecated as excessive and cumbersome. Please use KotlinModuleMetadata.write(kmModule, metadataVersion)", - level = DeprecationLevel.ERROR - ) - public class Writer { - /** - * Returns the metadata of the module file that was written with this writer. - * - * @param metadataVersion metadata version to be written to the metadata (see [Metadata.metadataVersion]), - * [KotlinClassMetadata.COMPATIBLE_METADATA_VERSION] by default - */ - @Deprecated( - "Writer API is deprecated as excessive and cumbersome. Please use KotlinModuleMetadata.write(kmModule, metadataVersion)", - level = DeprecationLevel.ERROR - ) - public fun write(metadataVersion: IntArray = COMPATIBLE_METADATA_VERSION): ByteArray { - error("This method is no longer implemented. Migrate to KotlinModuleMetadata.write.") - } - } - - /** - * Makes the given visitor visit the metadata of this module file. - * - * @param v the visitor that must visit this module file - */ - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - public fun accept(v: KmModuleVisitor): Unit = kmModule.accept(v) - /** * Collection of methods for reading and writing [KotlinModuleMetadata]. */ @@ -158,95 +108,19 @@ public class KotlinModuleMetadata public constructor( KotlinModuleMetadata(module, JvmMetadataVersion(result.version.toArray())) } } - - /** - * Writes the metadata of the Kotlin module file. - * - * @param metadataVersion metadata version to be written to the metadata (see [Metadata.metadataVersion]), - * [KotlinClassMetadata.COMPATIBLE_METADATA_VERSION] by default - * - * @throws IllegalArgumentException if [kmModule] is not correct and cannot be written or if [metadataVersion] is not supported for writing. - */ - @UnstableMetadataApi - @Deprecated("Use a KotlinModuleMetadata instance and its write() member function", level = DeprecationLevel.ERROR) - @JvmStatic - @JvmOverloads - public fun write(kmModule: KmModule, metadataVersion: JvmMetadataVersion = JvmMetadataVersion.LATEST_STABLE_SUPPORTED): ByteArray = wrapWriteIntoIAE { - return KotlinModuleMetadata(kmModule, metadataVersion).write() - } } } -/** - * A visitor to visit Kotlin JVM module files. - * - * When using this class, [visitEnd] must be called exactly once and after calls to all other visit* methods. - */ -@Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) -@UnstableMetadataApi -public abstract class KmModuleVisitor(private val delegate: KmModuleVisitor? = null) { - /** - * Visits the table of all single- and multi-file facades declared in some package of this module. - * - * Packages are separated by '/' in the names of file facades. - * - * @param fqName the fully qualified name of the package, separated by '.' - * @param fileFacades the list of single-file facades in this package - * @param multiFileClassParts the map of multi-file classes where keys are names of multi-file class parts, - * and values are names of the corresponding multi-file facades - */ - public open fun visitPackageParts(fqName: String, fileFacades: List, multiFileClassParts: Map) { - delegate?.visitPackageParts(fqName, fileFacades, multiFileClassParts) - } - - /** - * Visits the annotation on the module. - * - * @param annotation annotation on the module - */ - public open fun visitAnnotation(annotation: KmAnnotation) { - delegate?.visitAnnotation(annotation) - } - - /** - * Visits an `@OptionalExpectation`-annotated annotation class declared in this module. - * Such classes are not materialized to bytecode on JVM, but the Kotlin compiler stores their metadata in the module file on JVM, - * and loads it during compilation of dependent modules, in order to avoid reporting "unresolved reference" errors on usages. - * - * Multiplatform projects are an experimental feature of Kotlin, and their behavior and/or binary format - * may change in a subsequent release. - */ - public open fun visitOptionalAnnotationClass(): KmClassVisitor? = - delegate?.visitOptionalAnnotationClass() - - /** - * Visits the end of the module. - */ - public open fun visitEnd() { - delegate?.visitEnd() - } - - // TODO: JvmPackageName -} - /** * Represents a Kotlin JVM module file (`.kotlin_module` extension). */ @UnstableMetadataApi -public class KmModule : KmModuleVisitor() { +public class KmModule { /** * Table of all single- and multi-file facades declared in some package of this module, where keys are '.'-separated package names. */ public val packageParts: MutableMap = LinkedHashMap() - /** - * Annotations on the module. - * - * Currently, Kotlin does not provide functionality to specify annotations on modules. - */ - @Deprecated("This list is always empty and will be removed", level = DeprecationLevel.ERROR) - public val annotations: MutableList = ArrayList(0) - /** * `@OptionalExpectation`-annotated annotation classes declared in this module. * Such classes are not materialized to bytecode on JVM, but the Kotlin compiler stores their metadata in the module file on JVM, @@ -256,34 +130,6 @@ public class KmModule : KmModuleVisitor() { * may change in a subsequent release. */ public val optionalAnnotationClasses: MutableList = ArrayList(0) - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitPackageParts(fqName: String, fileFacades: List, multiFileClassParts: Map) { - packageParts[fqName] = KmPackageParts(fileFacades.toMutableList(), multiFileClassParts.toMutableMap()) - } - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitAnnotation(annotation: KmAnnotation) { - annotations.add(annotation) - } - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitOptionalAnnotationClass(): KmClass = - KmClass().also(optionalAnnotationClasses::add) - - /** - * Populates the given visitor with data in this module. - * - * @param visitor the visitor which will visit data in this module. - */ - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - public fun accept(visitor: KmModuleVisitor) { - for ((fqName, parts) in packageParts) { - visitor.visitPackageParts(fqName, parts.fileFacades, parts.multiFileClassParts) - } - annotations.forEach(visitor::visitAnnotation) - optionalAnnotationClasses.forEach { visitor.visitOptionalAnnotationClass()?.let(it::accept) } - } } /** diff --git a/libraries/kotlinx-metadata/jvm/src/kotlin/metadata/jvm/internal/JvmExtensionNodes.kt b/libraries/kotlinx-metadata/jvm/src/kotlin/metadata/jvm/internal/JvmExtensionNodes.kt index d7da3f57a7f..c12b558d1cc 100644 --- a/libraries/kotlinx-metadata/jvm/src/kotlin/metadata/jvm/internal/JvmExtensionNodes.kt +++ b/libraries/kotlinx-metadata/jvm/src/kotlin/metadata/jvm/internal/JvmExtensionNodes.kt @@ -2,8 +2,6 @@ * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ -@file:Suppress("DEPRECATION","DEPRECATION_ERROR") // inheritance of deprecated visitors will be removed with visitors - package kotlin.metadata.jvm.internal import kotlin.metadata.* @@ -11,104 +9,68 @@ import kotlin.metadata.internal.extensions.* import kotlin.metadata.jvm.* internal val KmClass.jvm: JvmClassExtension - get() = visitExtensions(JvmClassExtensionVisitor.TYPE) as JvmClassExtension + get() = getExtension(JvmClassExtension.TYPE) as JvmClassExtension internal val KmPackage.jvm: JvmPackageExtension - get() = visitExtensions(JvmPackageExtensionVisitor.TYPE) as JvmPackageExtension + get() = getExtension(JvmPackageExtension.TYPE) as JvmPackageExtension internal val KmFunction.jvm: JvmFunctionExtension - get() = visitExtensions(JvmFunctionExtensionVisitor.TYPE) as JvmFunctionExtension + get() = getExtension(JvmFunctionExtension.TYPE) as JvmFunctionExtension internal val KmProperty.jvm: JvmPropertyExtension - get() = visitExtensions(JvmPropertyExtensionVisitor.TYPE) as JvmPropertyExtension + get() = getExtension(JvmPropertyExtension.TYPE) as JvmPropertyExtension internal val KmConstructor.jvm: JvmConstructorExtension - get() = visitExtensions(JvmConstructorExtensionVisitor.TYPE) as JvmConstructorExtension + get() = getExtension(JvmConstructorExtension.TYPE) as JvmConstructorExtension internal val KmTypeParameter.jvm: JvmTypeParameterExtension - get() = visitExtensions(JvmTypeParameterExtensionVisitor.TYPE) as JvmTypeParameterExtension + get() = getExtension(JvmTypeParameterExtension.TYPE) as JvmTypeParameterExtension internal val KmType.jvm: JvmTypeExtension - get() = visitExtensions(JvmTypeExtensionVisitor.TYPE) as JvmTypeExtension + get() = getExtension(JvmTypeExtension.TYPE) as JvmTypeExtension -internal class JvmClassExtension : JvmClassExtensionVisitor(), KmClassExtension { +internal class JvmClassExtension : KmClassExtension { val localDelegatedProperties: MutableList = ArrayList(0) var moduleName: String? = null var anonymousObjectOriginName: String? = null var jvmFlags: Int = 0 - override fun visitLocalDelegatedProperty(flags: Int, name: String, getterFlags: Int, setterFlags: Int): KmPropertyVisitor = - KmProperty(flags, name, getterFlags, setterFlags).also { localDelegatedProperties.add(it) } + override val type: KmExtensionType + get() = TYPE - override fun visitModuleName(name: String) { - this.moduleName = name - } - - override fun visitAnonymousObjectOriginName(internalName: String) { - this.anonymousObjectOriginName = internalName - } - - override fun visitJvmFlags(flags: Int) { - this.jvmFlags = flags - } - - override fun accept(visitor: KmClassExtensionVisitor) { - require(visitor is JvmClassExtensionVisitor) - localDelegatedProperties.forEach { - @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") // getter.flags - visitor.visitLocalDelegatedProperty(it.flags, it.name, it.getter.flags, it.setterFlags)?.let(it::accept) - } - moduleName?.let(visitor::visitModuleName) - anonymousObjectOriginName?.let(visitor::visitAnonymousObjectOriginName) - jvmFlags.takeIf { it != 0 }?.let(visitor::visitJvmFlags) - visitor.visitEnd() + companion object { + val TYPE: KmExtensionType = KmExtensionType(JvmClassExtension::class) } } -internal class JvmPackageExtension : JvmPackageExtensionVisitor(), KmPackageExtension { +internal class JvmPackageExtension : KmPackageExtension { val localDelegatedProperties: MutableList = ArrayList(0) var moduleName: String? = null - override fun visitLocalDelegatedProperty(flags: Int, name: String, getterFlags: Int, setterFlags: Int): KmPropertyVisitor = - KmProperty(flags, name, getterFlags, setterFlags).also { localDelegatedProperties.add(it) } + override val type: KmExtensionType + get() = TYPE - override fun visitModuleName(name: String) { - this.moduleName = name - } - - override fun accept(visitor: KmPackageExtensionVisitor) { - require(visitor is JvmPackageExtensionVisitor) - localDelegatedProperties.forEach { - @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") // getter.flags - visitor.visitLocalDelegatedProperty(it.flags, it.name, it.getter.flags, it.setterFlags)?.let(it::accept) - } - moduleName?.let(visitor::visitModuleName) - visitor.visitEnd() + companion object { + @JvmField + val TYPE: KmExtensionType = KmExtensionType(JvmPackageExtension::class) } } -internal class JvmFunctionExtension : JvmFunctionExtensionVisitor(), KmFunctionExtension { +internal class JvmFunctionExtension : KmFunctionExtension { var signature: JvmMethodSignature? = null var lambdaClassOriginName: String? = null - override fun visit(signature: JvmMethodSignature?) { - this.signature = signature - } + override val type: KmExtensionType + get() = TYPE - override fun visitLambdaClassOriginName(internalName: String) { - this.lambdaClassOriginName = internalName - } - - override fun accept(visitor: KmFunctionExtensionVisitor) { - require(visitor is JvmFunctionExtensionVisitor) - visitor.visit(signature) - lambdaClassOriginName?.let(visitor::visitLambdaClassOriginName) - visitor.visitEnd() + companion object { + @JvmField + val TYPE: KmExtensionType = KmExtensionType(JvmFunctionExtension::class) } } -internal class JvmPropertyExtension : JvmPropertyExtensionVisitor(), KmPropertyExtension { +internal class JvmPropertyExtension : KmPropertyExtension { var jvmFlags: Int = 0 var fieldSignature: JvmFieldSignature? = null var getterSignature: JvmMethodSignature? = null @@ -116,78 +78,55 @@ internal class JvmPropertyExtension : JvmPropertyExtensionVisitor(), KmPropertyE var syntheticMethodForAnnotations: JvmMethodSignature? = null var syntheticMethodForDelegate: JvmMethodSignature? = null - override fun visit( - jvmFlags: Int, - fieldSignature: JvmFieldSignature?, - getterSignature: JvmMethodSignature?, - setterSignature: JvmMethodSignature? - ) { - this.jvmFlags = jvmFlags - this.fieldSignature = fieldSignature - this.getterSignature = getterSignature - this.setterSignature = setterSignature - } + override val type: KmExtensionType + get() = TYPE - override fun visitSyntheticMethodForAnnotations(signature: JvmMethodSignature?) { - this.syntheticMethodForAnnotations = signature - } - - override fun visitSyntheticMethodForDelegate(signature: JvmMethodSignature?) { - this.syntheticMethodForDelegate = signature - } - - override fun accept(visitor: KmPropertyExtensionVisitor) { - require(visitor is JvmPropertyExtensionVisitor) - visitor.visit(jvmFlags, fieldSignature, getterSignature, setterSignature) - visitor.visitSyntheticMethodForAnnotations(syntheticMethodForAnnotations) - visitor.visitSyntheticMethodForDelegate(syntheticMethodForDelegate) - visitor.visitEnd() + companion object { + @JvmField + val TYPE: KmExtensionType = KmExtensionType(JvmPropertyExtension::class) } } -internal class JvmConstructorExtension : JvmConstructorExtensionVisitor(), KmConstructorExtension { +internal class JvmConstructorExtension : KmConstructorExtension { var signature: JvmMethodSignature? = null - override fun visit(signature: JvmMethodSignature?) { - this.signature = signature - } + override val type: KmExtensionType + get() = TYPE - override fun accept(visitor: KmConstructorExtensionVisitor) { - require(visitor is JvmConstructorExtensionVisitor) - visitor.visit(signature) + companion object { + @JvmField + val TYPE: KmExtensionType = KmExtensionType(JvmConstructorExtension::class) } } -internal class JvmTypeParameterExtension : JvmTypeParameterExtensionVisitor(), KmTypeParameterExtension { +internal class JvmTypeParameterExtension : KmTypeParameterExtension { val annotations: MutableList = mutableListOf() - override fun visitAnnotation(annotation: KmAnnotation) { - annotations.add(annotation) - } + override val type: KmExtensionType + get() = TYPE - override fun accept(visitor: KmTypeParameterExtensionVisitor) { - require(visitor is JvmTypeParameterExtensionVisitor) - annotations.forEach(visitor::visitAnnotation) - visitor.visitEnd() + companion object { + @JvmField + val TYPE: KmExtensionType = KmExtensionType(JvmTypeParameterExtension::class) } } -internal class JvmTypeExtension : JvmTypeExtensionVisitor(), KmTypeExtension { +internal class JvmTypeExtension : KmTypeExtension { var isRaw: Boolean = false val annotations: MutableList = mutableListOf() - override fun visit(isRaw: Boolean) { - this.isRaw = isRaw - } + override val type: KmExtensionType + get() = TYPE - override fun visitAnnotation(annotation: KmAnnotation) { - annotations.add(annotation) - } + companion object { + @JvmField + val TYPE: KmExtensionType = KmExtensionType(JvmTypeExtension::class) - override fun accept(visitor: KmTypeExtensionVisitor) { - require(visitor is JvmTypeExtensionVisitor) - visitor.visit(isRaw) - annotations.forEach(visitor::visitAnnotation) - visitor.visitEnd() + /** + * The type flexibility id, signifying that the visited type is a JVM platform type. + * + * @see KmTypeVisitor.visitFlexibleTypeUpperBound + */ + const val PLATFORM_TYPE_ID: String = JvmProtoBufUtil.PLATFORM_TYPE_ID // TODO: move out of deprecated visitor } } diff --git a/libraries/kotlinx-metadata/jvm/src/kotlin/metadata/jvm/internal/JvmMetadataExtensions.kt b/libraries/kotlinx-metadata/jvm/src/kotlin/metadata/jvm/internal/JvmMetadataExtensions.kt index 1fca25022d2..5a343e6b8ec 100644 --- a/libraries/kotlinx-metadata/jvm/src/kotlin/metadata/jvm/internal/JvmMetadataExtensions.kt +++ b/libraries/kotlinx-metadata/jvm/src/kotlin/metadata/jvm/internal/JvmMetadataExtensions.kt @@ -223,13 +223,9 @@ internal class JvmMetadataExtensions : MetadataExtensions { override fun createPackageExtension(): KmPackageExtension = JvmPackageExtension() - @Suppress("DEPRECATION_ERROR") override fun createModuleFragmentExtensions(): KmModuleFragmentExtension = object : KmModuleFragmentExtension { override val type: KmExtensionType = KmExtensionType(KmModuleFragmentExtension::class) - - override fun accept(visitor: KmModuleFragmentExtensionVisitor) { - } } override fun createFunctionExtension(): KmFunctionExtension = JvmFunctionExtension() diff --git a/libraries/kotlinx-metadata/jvm/src/kotlin/metadata/jvm/internal/JvmReadUtils.kt b/libraries/kotlinx-metadata/jvm/src/kotlin/metadata/jvm/internal/JvmReadUtils.kt index 4e01f89c23b..537ac65c89b 100644 --- a/libraries/kotlinx-metadata/jvm/src/kotlin/metadata/jvm/internal/JvmReadUtils.kt +++ b/libraries/kotlinx-metadata/jvm/src/kotlin/metadata/jvm/internal/JvmReadUtils.kt @@ -5,7 +5,6 @@ package kotlin.metadata.jvm.internal -import kotlin.metadata.KmAnnotation import kotlin.metadata.KmClass import kotlin.metadata.KmLambda import kotlin.metadata.KmPackage @@ -69,11 +68,6 @@ internal object JvmReadUtils { ) } - for (annotation in data.moduleData.annotations) { - @Suppress("DEPRECATION_ERROR") - v.annotations.add(KmAnnotation(annotation, emptyMap())) - } - for (classProto in data.moduleData.optionalAnnotations) { v.optionalAnnotationClasses.add(classProto.toKmClass(data.moduleData.nameResolver, false)) } diff --git a/libraries/kotlinx-metadata/jvm/test/kotlin/metadata/test/Flag.kt b/libraries/kotlinx-metadata/jvm/test/kotlin/metadata/test/Flag.kt new file mode 100644 index 00000000000..0909d01e5c8 --- /dev/null +++ b/libraries/kotlinx-metadata/jvm/test/kotlin/metadata/test/Flag.kt @@ -0,0 +1,77 @@ +/* + * Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package kotlin.metadata.test + +import kotlin.metadata.internal.FlagImpl +import org.jetbrains.kotlin.metadata.ProtoBuf.Visibility as ProtoVisibility +import org.jetbrains.kotlin.metadata.deserialization.Flags as F + +fun Flag(field: F.FlagField<*>, value: Int) = FlagImpl(field.offset, field.bitWidth, value) + +fun Flag(field: F.BooleanFlagField) = Flag(field, 1) + +// Reduced copy of old Flag.kt for testing purposes. +class Flag private constructor() { + + companion object Common { + /** + * A visibility flag, signifying that the corresponding declaration is `internal`. + */ + val IS_INTERNAL = Flag(F.VISIBILITY, ProtoVisibility.INTERNAL_VALUE) + + /** + * A visibility flag, signifying that the corresponding declaration is `private`. + */ + @JvmField + val IS_PRIVATE = Flag(F.VISIBILITY, ProtoVisibility.PRIVATE_VALUE) + + /** + * A visibility flag, signifying that the corresponding declaration is `public`. + */ + @JvmField + val IS_PUBLIC = Flag(F.VISIBILITY, ProtoVisibility.PUBLIC_VALUE) + } + + object Class { + /** + * Signifies that the corresponding class is `data`. + */ + @JvmField + val IS_DATA = Flag(F.IS_DATA) + } + + object Constructor { + /** + * Signifies that the corresponding constructor has non-stable parameter names, i.e. cannot be called with named arguments. + */ + @JvmField + val HAS_NON_STABLE_PARAMETER_NAMES = Flag(F.IS_CONSTRUCTOR_WITH_NON_STABLE_PARAMETER_NAMES) + } + + object Function { + /** + * Signifies that the corresponding function is `operator`. + */ + @JvmField + val IS_OPERATOR = Flag(F.IS_OPERATOR) + + + /** + * Signifies that the corresponding function has non-stable parameter names, i.e. cannot be called with named arguments. + */ + @JvmField + val HAS_NON_STABLE_PARAMETER_NAMES = Flag(F.IS_FUNCTION_WITH_NON_STABLE_PARAMETER_NAMES) + } + + object Type { + /** + * Signifies that the corresponding type is marked as nullable, i.e. has a question mark at the end of its notation. + */ + @JvmField + val IS_NULLABLE = FlagImpl(0, 1, 1) + + } +} diff --git a/libraries/kotlinx-metadata/jvm/test/kotlin/metadata/test/FlagDelegatesTest.kt b/libraries/kotlinx-metadata/jvm/test/kotlin/metadata/test/FlagDelegatesTest.kt index 5eedd191965..14af1122231 100644 --- a/libraries/kotlinx-metadata/jvm/test/kotlin/metadata/test/FlagDelegatesTest.kt +++ b/libraries/kotlinx-metadata/jvm/test/kotlin/metadata/test/FlagDelegatesTest.kt @@ -7,10 +7,11 @@ package kotlin.metadata.test import kotlin.metadata.* import org.junit.Test +import kotlin.metadata.internal.FlagImpl +import kotlin.metadata.internal._flagAccess import kotlin.reflect.KMutableProperty0 import kotlin.test.* -@Suppress("DEPRECATION", "DEPRECATION_ERROR") // flags will become internal eventually class FlagDelegatesTest { private class Private @@ -26,29 +27,29 @@ class FlagDelegatesTest { assertEquals(Visibility.PRIVATE, p1.visibility) assertEquals(Visibility.PUBLIC, p2.visibility) - assertTrue(Flag.IS_PRIVATE(p1.flags)) - assertTrue(Flag.IS_PUBLIC(p2.flags)) + assertTrue(Flag.IS_PRIVATE(_flagAccess(p1))) + assertTrue(Flag.IS_PUBLIC(_flagAccess(p2))) p1.visibility = Visibility.PUBLIC p2.visibility = Visibility.INTERNAL - assertFalse(Flag.IS_PRIVATE(p1.flags)) - assertFalse(Flag.IS_PUBLIC(p2.flags)) + assertFalse(Flag.IS_PRIVATE(_flagAccess(p1))) + assertFalse(Flag.IS_PUBLIC(_flagAccess(p2))) - assertTrue(Flag.IS_PUBLIC(p1.flags)) - assertTrue(Flag.IS_INTERNAL(p2.flags)) + assertTrue(Flag.IS_PUBLIC(_flagAccess(p1))) + assertTrue(Flag.IS_INTERNAL(_flagAccess(p2))) val f = assertNotNull(p2.functions.find { it.name == "f" }) assertEquals(Visibility.PUBLIC, f.visibility) f.visibility = Visibility.PRIVATE - assertFalse(Flag.IS_PUBLIC(f.flags)) - assertTrue(Flag.IS_PRIVATE(f.flags)) + assertFalse(Flag.IS_PUBLIC(_flagAccess(f))) + assertTrue(Flag.IS_PRIVATE(_flagAccess(f))) } @Test fun testBooleanFlags() { val klass = Public::class.java.readMetadataAsKmClass() - fun doTest(prop: KMutableProperty0, flags: () -> Int, rawFlag: Flag) { + fun doTest(prop: KMutableProperty0, flags: () -> Int, rawFlag: FlagImpl) { assertFalse(prop.get()) assertFalse(rawFlag(flags())) @@ -59,14 +60,14 @@ class FlagDelegatesTest { } - doTest(klass::isData, klass::flags, Flag.Class.IS_DATA) + doTest(klass::isData, { _flagAccess(klass) }, Flag.Class.IS_DATA) val f = klass.functions.single { it.name == "f" } - doTest(f::isOperator, f::flags, Flag.Function.IS_OPERATOR) + doTest(f::isOperator, { _flagAccess(f) }, Flag.Function.IS_OPERATOR) val rt = f.returnType - doTest(rt::isNullable, rt::flags, Flag.Type.IS_NULLABLE) + doTest(rt::isNullable, { _flagAccess(rt) }, Flag.Type.IS_NULLABLE) } - @Suppress("UNUSED_PARAMETER") + @Suppress("UNUSED_PARAMETER", "unused") class PropertiesContainer { val defaultVal: String = "" @@ -121,7 +122,7 @@ class FlagDelegatesTest { setterParamCheck: (KmValueParameter?) -> Unit = { assertNull(it, "Should not be a setter parameter for $name") }, ) { with(propMap.getValue(name)) { - assertEquals(listOf(isVarProp, true, isVarProp), listOf(isVar, hasGetter, hasSetter), "for $name") + assertEquals(listOf(isVarProp, isVarProp), listOf(isVar, setter != null), "for $name") assertEquals(visibility, getter.visibility, "for $name") assertEquals(getterNotDefault, getter.isNotDefault, "for $name") diff --git a/libraries/kotlinx-metadata/jvm/test/kotlin/metadata/test/MetadataSmokeTest.kt b/libraries/kotlinx-metadata/jvm/test/kotlin/metadata/test/MetadataSmokeTest.kt index ab761dec6b5..d3ac0a695ee 100644 --- a/libraries/kotlinx-metadata/jvm/test/kotlin/metadata/test/MetadataSmokeTest.kt +++ b/libraries/kotlinx-metadata/jvm/test/kotlin/metadata/test/MetadataSmokeTest.kt @@ -12,6 +12,7 @@ import org.jetbrains.org.objectweb.asm.Opcodes import org.junit.Test import java.net.URLClassLoader import kotlin.coroutines.CoroutineContext +import kotlin.metadata.internal._flagAccess import kotlin.reflect.full.primaryConstructor import kotlin.test.* @@ -146,7 +147,6 @@ class MetadataSmokeTest { } @Test - @Suppress("DEPRECATION_ERROR") // flags will become internal eventually fun unstableParameterNames() { @Suppress("unused", "UNUSED_PARAMETER") class Test(a: String, b: Int, c: Boolean) { @@ -155,8 +155,8 @@ class MetadataSmokeTest { val classWithStableParameterNames = Test::class.java.readMetadataAsClass() - classWithStableParameterNames.kmClass.constructors.forEach { assertFalse(Flag.Constructor.HAS_NON_STABLE_PARAMETER_NAMES(it.flags)) } - classWithStableParameterNames.kmClass.functions.forEach { assertFalse(Flag.Function.HAS_NON_STABLE_PARAMETER_NAMES(it.flags)) } + classWithStableParameterNames.kmClass.constructors.forEach { assertFalse(Flag.Constructor.HAS_NON_STABLE_PARAMETER_NAMES(_flagAccess(it))) } + classWithStableParameterNames.kmClass.functions.forEach { assertFalse(Flag.Function.HAS_NON_STABLE_PARAMETER_NAMES(_flagAccess(it))) } classWithStableParameterNames.kmClass.constructors.forEach { assertFalse(it.hasNonStableParameterNames) } classWithStableParameterNames.kmClass.functions.forEach { assertFalse(it.hasNonStableParameterNames) } @@ -168,8 +168,8 @@ class MetadataSmokeTest { val classWithUnstableParameterNames = newMetadata.readAsKmClass() - classWithUnstableParameterNames.constructors.forEach { assertTrue(Flag.Constructor.HAS_NON_STABLE_PARAMETER_NAMES(it.flags)) } - classWithUnstableParameterNames.functions.forEach { assertTrue(Flag.Function.HAS_NON_STABLE_PARAMETER_NAMES(it.flags)) } + classWithUnstableParameterNames.constructors.forEach { assertTrue(Flag.Constructor.HAS_NON_STABLE_PARAMETER_NAMES(_flagAccess(it))) } + classWithUnstableParameterNames.functions.forEach { assertTrue(Flag.Function.HAS_NON_STABLE_PARAMETER_NAMES(_flagAccess(it))) } classWithUnstableParameterNames.constructors.forEach { assertTrue(it.hasNonStableParameterNames) } classWithUnstableParameterNames.functions.forEach { assertTrue(it.hasNonStableParameterNames) } diff --git a/libraries/kotlinx-metadata/klib/src/kotlinx/metadata/klib/impl/klibExtensionNodes.kt b/libraries/kotlinx-metadata/klib/src/kotlinx/metadata/klib/impl/klibExtensionNodes.kt index 1d1c4ca2046..2175b260e3c 100644 --- a/libraries/kotlinx-metadata/klib/src/kotlinx/metadata/klib/impl/klibExtensionNodes.kt +++ b/libraries/kotlinx-metadata/klib/src/kotlinx/metadata/klib/impl/klibExtensionNodes.kt @@ -2,45 +2,42 @@ * Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ -@file:Suppress("DEPRECATION_ERROR") // Extension visitors - package kotlinx.metadata.klib.impl import kotlinx.metadata.klib.* import kotlin.metadata.* import kotlin.metadata.internal.common.KmModuleFragment -import kotlin.metadata.internal.common.KmModuleFragmentExtensionVisitor import kotlin.metadata.internal.extensions.* internal val KmFunction.klibExtensions: KlibFunctionExtension - get() = visitExtensions(KlibFunctionExtensionVisitor.TYPE) as KlibFunctionExtension + get() = getExtension(KlibFunctionExtensionVisitor.TYPE) as KlibFunctionExtension internal val KmClass.klibExtensions: KlibClassExtension - get() = visitExtensions(KlibClassExtensionVisitor.TYPE) as KlibClassExtension + get() = getExtension(KlibClassExtensionVisitor.TYPE) as KlibClassExtension internal val KmType.klibExtensions: KlibTypeExtension - get() = visitExtensions(KlibTypeExtensionVisitor.TYPE) as KlibTypeExtension + get() = getExtension(KlibTypeExtensionVisitor.TYPE) as KlibTypeExtension internal val KmProperty.klibExtensions: KlibPropertyExtension - get() = visitExtensions(KlibPropertyExtensionVisitor.TYPE) as KlibPropertyExtension + get() = getExtension(KlibPropertyExtensionVisitor.TYPE) as KlibPropertyExtension internal val KmConstructor.klibExtensions: KlibConstructorExtension - get() = visitExtensions(KlibConstructorExtensionVisitor.TYPE) as KlibConstructorExtension + get() = getExtension(KlibConstructorExtensionVisitor.TYPE) as KlibConstructorExtension internal val KmTypeParameter.klibExtensions: KlibTypeParameterExtension - get() = visitExtensions(KlibTypeParameterExtensionVisitor.TYPE) as KlibTypeParameterExtension + get() = getExtension(KlibTypeParameterExtensionVisitor.TYPE) as KlibTypeParameterExtension internal val KmPackage.klibExtensions: KlibPackageExtension - get() = visitExtensions(KlibPackageExtensionVisitor.TYPE) as KlibPackageExtension + get() = getExtension(KlibPackageExtensionVisitor.TYPE) as KlibPackageExtension internal val KmModuleFragment.klibExtensions: KlibModuleFragmentExtension - get() = visitExtensions(KlibModuleFragmentExtensionVisitor.TYPE) as KlibModuleFragmentExtension + get() = getExtension(KlibModuleFragmentExtensionVisitor.TYPE) as KlibModuleFragmentExtension internal val KmTypeAlias.klibExtensions: KlibTypeAliasExtension - get() = visitExtensions(KlibTypeAliasExtensionVisitor.TYPE) as KlibTypeAliasExtension + get() = getExtension(KlibTypeAliasExtensionVisitor.TYPE) as KlibTypeAliasExtension internal val KmValueParameter.klibExtensions: KlibValueParameterExtension - get() = visitExtensions(KlibValueParameterExtensionVisitor.TYPE) as KlibValueParameterExtension + get() = getExtension(KlibValueParameterExtensionVisitor.TYPE) as KlibValueParameterExtension internal class KlibFunctionExtension : KlibFunctionExtensionVisitor(), KmFunctionExtension { @@ -60,7 +57,7 @@ internal class KlibFunctionExtension : KlibFunctionExtensionVisitor(), KmFunctio this.file = file } - override fun accept(visitor: KmFunctionExtensionVisitor) { + fun accept(visitor: KmFunctionExtension) { require(visitor is KlibFunctionExtensionVisitor) annotations.forEach(visitor::visitAnnotation) uniqId?.let(visitor::visitUniqId) @@ -91,7 +88,7 @@ internal class KlibClassExtension : KlibClassExtensionVisitor(), KmClassExtensio enumEntries += entry } - override fun accept(visitor: KmClassExtensionVisitor) { + fun accept(visitor: KmClassExtension) { require(visitor is KlibClassExtensionVisitor) annotations.forEach(visitor::visitAnnotation) enumEntries.forEach(visitor::visitEnumEntry) @@ -108,7 +105,7 @@ internal class KlibTypeExtension : KlibTypeExtensionVisitor(), KmTypeExtension { annotations += annotation } - override fun accept(visitor: KmTypeExtensionVisitor) { + fun accept(visitor: KmTypeExtension) { require(visitor is KlibTypeExtensionVisitor) annotations.forEach(visitor::visitAnnotation) } @@ -147,7 +144,7 @@ internal class KlibPropertyExtension : KlibPropertyExtensionVisitor(), KmPropert this.compileTimeValue = value } - override fun accept(visitor: KmPropertyExtensionVisitor) { + fun accept(visitor: KmPropertyExtension) { require(visitor is KlibPropertyExtensionVisitor) annotations.forEach(visitor::visitAnnotation) getterAnnotations.forEach(visitor::visitGetterAnnotation) @@ -171,7 +168,7 @@ internal class KlibConstructorExtension : KlibConstructorExtensionVisitor(), KmC this.uniqId = uniqId } - override fun accept(visitor: KmConstructorExtensionVisitor) { + fun accept(visitor: KmConstructorExtension) { require(visitor is KlibConstructorExtensionVisitor) annotations.forEach(visitor::visitAnnotation) uniqId?.let(visitor::visitUniqId) @@ -191,7 +188,7 @@ internal class KlibTypeParameterExtension : KlibTypeParameterExtensionVisitor(), this.uniqId = uniqId } - override fun accept(visitor: KmTypeParameterExtensionVisitor) { + fun accept(visitor: KmTypeParameterExtension) { require(visitor is KlibTypeParameterExtensionVisitor) annotations.forEach(visitor::visitAnnotation) uniqId?.let(visitor::visitUniqId) @@ -206,7 +203,7 @@ internal class KlibPackageExtension : KlibPackageExtensionVisitor(), KmPackageEx fqName = name } - override fun accept(visitor: KmPackageExtensionVisitor) { + fun accept(visitor: KmPackageExtension) { require(visitor is KlibPackageExtensionVisitor) fqName?.let(visitor::visitFqName) } @@ -230,7 +227,7 @@ internal class KlibModuleFragmentExtension : KlibModuleFragmentExtensionVisitor( this.className += className } - override fun accept(visitor: KmModuleFragmentExtensionVisitor) { + fun accept(visitor: KmModuleFragmentExtension) { require(visitor is KlibModuleFragmentExtensionVisitor) moduleFragmentFiles.forEach(visitor::visitFile) fqName?.let(visitor::visitFqName) @@ -245,7 +242,7 @@ internal class KlibTypeAliasExtension : KlibTypeAliasExtensionVisitor(), KmTypeA this.uniqId = uniqId } - override fun accept(visitor: KmTypeAliasExtensionVisitor) { + fun accept(visitor: KmTypeAliasExtension) { require(visitor is KlibTypeAliasExtensionVisitor) uniqId?.let(visitor::visitUniqId) } @@ -258,7 +255,7 @@ internal class KlibValueParameterExtension : KlibValueParameterExtensionVisitor( annotations += annotation } - override fun accept(visitor: KmValueParameterExtensionVisitor) { + fun accept(visitor: KmValueParameterExtension) { require(visitor is KlibValueParameterExtensionVisitor) annotations.forEach(visitor::visitAnnotation) } diff --git a/libraries/kotlinx-metadata/klib/src/kotlinx/metadata/klib/impl/klibMetadataExtensions.kt b/libraries/kotlinx-metadata/klib/src/kotlinx/metadata/klib/impl/klibMetadataExtensions.kt index 12d56a2387f..fae05e4ec84 100644 --- a/libraries/kotlinx-metadata/klib/src/kotlinx/metadata/klib/impl/klibMetadataExtensions.kt +++ b/libraries/kotlinx-metadata/klib/src/kotlinx/metadata/klib/impl/klibMetadataExtensions.kt @@ -18,7 +18,6 @@ import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.serialization.StringTableImpl -@Suppress("DEPRECATION_ERROR") internal class KlibMetadataExtensions : MetadataExtensions { private fun ReadContext.getSourceFile(index: Int) = @@ -28,7 +27,7 @@ internal class KlibMetadataExtensions : MetadataExtensions { strings.getStringIndex(file.name) override fun readClassExtensions(kmClass: KmClass, proto: ProtoBuf.Class, c: ReadContext) { - val extension = kmClass.visitExtensions(KlibClassExtensionVisitor.TYPE) as? KlibClassExtensionVisitor ?: return + val extension = kmClass.getExtension(KlibClassExtensionVisitor.TYPE) as? KlibClassExtensionVisitor ?: return proto.getExtension(KlibMetadataProtoBuf.classAnnotation).forEach { annotation -> extension.visitAnnotation(annotation.readAnnotation(c.strings)) @@ -49,7 +48,7 @@ internal class KlibMetadataExtensions : MetadataExtensions { } override fun readPackageExtensions(kmPackage: KmPackage, proto: ProtoBuf.Package, c: ReadContext) { - val extension = kmPackage.visitExtensions(KlibPackageExtensionVisitor.TYPE) as? KlibPackageExtensionVisitor ?: return + val extension = kmPackage.getExtension(KlibPackageExtensionVisitor.TYPE) as? KlibPackageExtensionVisitor ?: return proto.getExtensionOrNull(KlibMetadataProtoBuf.packageFqName)?.let { val fqName = (c.strings as NameResolverImpl).getPackageFqName(it) @@ -58,7 +57,7 @@ internal class KlibMetadataExtensions : MetadataExtensions { } override fun readModuleFragmentExtensions(kmModuleFragment: KmModuleFragment, proto: ProtoBuf.PackageFragment, c: ReadContext) { - val extension = kmModuleFragment.visitExtensions(KlibModuleFragmentExtensionVisitor.TYPE) as? KlibModuleFragmentExtensionVisitor ?: return + val extension = kmModuleFragment.getExtension(KlibModuleFragmentExtensionVisitor.TYPE) as? KlibModuleFragmentExtensionVisitor ?: return proto.getExtension(KlibMetadataProtoBuf.packageFragmentFiles) .map { c.getSourceFile(it) } @@ -70,7 +69,7 @@ internal class KlibMetadataExtensions : MetadataExtensions { } override fun readFunctionExtensions(kmFunction: KmFunction, proto: ProtoBuf.Function, c: ReadContext) { - val extension = kmFunction.visitExtensions(KlibFunctionExtensionVisitor.TYPE) as? KlibFunctionExtensionVisitor ?: return + val extension = kmFunction.getExtension(KlibFunctionExtensionVisitor.TYPE) as? KlibFunctionExtensionVisitor ?: return proto.getExtension(KlibMetadataProtoBuf.functionAnnotation).forEach { annotation -> extension.visitAnnotation(annotation.readAnnotation(c.strings)) @@ -85,7 +84,7 @@ internal class KlibMetadataExtensions : MetadataExtensions { } override fun readPropertyExtensions(kmProperty: KmProperty, proto: ProtoBuf.Property, c: ReadContext) { - val extension = kmProperty.visitExtensions(KlibPropertyExtensionVisitor.TYPE) as? KlibPropertyExtensionVisitor ?: return + val extension = kmProperty.getExtension(KlibPropertyExtensionVisitor.TYPE) as? KlibPropertyExtensionVisitor ?: return proto.getExtension(KlibMetadataProtoBuf.propertyAnnotation).forEach { annotation -> extension.visitAnnotation(annotation.readAnnotation(c.strings)) @@ -106,7 +105,7 @@ internal class KlibMetadataExtensions : MetadataExtensions { } override fun readConstructorExtensions(kmConstructor: KmConstructor, proto: ProtoBuf.Constructor, c: ReadContext) { - val extension = kmConstructor.visitExtensions(KlibConstructorExtensionVisitor.TYPE) as? KlibConstructorExtensionVisitor ?: return + val extension = kmConstructor.getExtension(KlibConstructorExtensionVisitor.TYPE) as? KlibConstructorExtensionVisitor ?: return proto.getExtension(KlibMetadataProtoBuf.constructorAnnotation).forEach { annotation -> extension.visitAnnotation(annotation.readAnnotation(c.strings)) @@ -117,7 +116,7 @@ internal class KlibMetadataExtensions : MetadataExtensions { } override fun readTypeParameterExtensions(kmTypeParameter: KmTypeParameter, proto: ProtoBuf.TypeParameter, c: ReadContext) { - val extension = kmTypeParameter.visitExtensions(KlibTypeParameterExtensionVisitor.TYPE) as? KlibTypeParameterExtensionVisitor ?: return + val extension = kmTypeParameter.getExtension(KlibTypeParameterExtensionVisitor.TYPE) as? KlibTypeParameterExtensionVisitor ?: return proto.getExtension(KlibMetadataProtoBuf.typeParameterAnnotation).forEach { annotation -> extension.visitAnnotation(annotation.readAnnotation(c.strings)) @@ -128,7 +127,7 @@ internal class KlibMetadataExtensions : MetadataExtensions { } override fun readTypeExtensions(kmType: KmType, proto: ProtoBuf.Type, c: ReadContext) { - val extension = kmType.visitExtensions(KlibTypeExtensionVisitor.TYPE) as? KlibTypeExtensionVisitor ?: return + val extension = kmType.getExtension(KlibTypeExtensionVisitor.TYPE) as? KlibTypeExtensionVisitor ?: return proto.getExtension(KlibMetadataProtoBuf.typeAnnotation).forEach { annotation -> extension.visitAnnotation(annotation.readAnnotation(c.strings)) @@ -136,7 +135,7 @@ internal class KlibMetadataExtensions : MetadataExtensions { } override fun readTypeAliasExtensions(kmTypeAlias: KmTypeAlias, proto: ProtoBuf.TypeAlias, c: ReadContext) { - val extension = kmTypeAlias.visitExtensions(KlibTypeAliasExtensionVisitor.TYPE) as? KlibTypeAliasExtensionVisitor ?: return + val extension = kmTypeAlias.getExtension(KlibTypeAliasExtensionVisitor.TYPE) as? KlibTypeAliasExtensionVisitor ?: return proto.getExtension(KlibMetadataProtoBuf.typeAliasUniqId).let { descriptorUniqId -> extension.visitUniqId(descriptorUniqId.readUniqId()) @@ -144,7 +143,7 @@ internal class KlibMetadataExtensions : MetadataExtensions { } override fun readValueParameterExtensions(kmValueParameter: KmValueParameter, proto: ProtoBuf.ValueParameter, c: ReadContext) { - val extension = kmValueParameter.visitExtensions(KlibValueParameterExtensionVisitor.TYPE) as? KlibValueParameterExtensionVisitor ?: return + val extension = kmValueParameter.getExtension(KlibValueParameterExtensionVisitor.TYPE) as? KlibValueParameterExtensionVisitor ?: return proto.getExtension(KlibMetadataProtoBuf.parameterAnnotation).forEach { annotation -> extension.visitAnnotation(annotation.readAnnotation(c.strings)) diff --git a/libraries/kotlinx-metadata/klib/src/kotlinx/metadata/klib/klibMetadataExtensionVisitors.kt b/libraries/kotlinx-metadata/klib/src/kotlinx/metadata/klib/klibMetadataExtensionVisitors.kt index 6ed4b0f4be0..bce78f8ea2e 100644 --- a/libraries/kotlinx-metadata/klib/src/kotlinx/metadata/klib/klibMetadataExtensionVisitors.kt +++ b/libraries/kotlinx-metadata/klib/src/kotlinx/metadata/klib/klibMetadataExtensionVisitors.kt @@ -2,14 +2,12 @@ * Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ -@file:Suppress("DEPRECATION_ERROR") // Extension visitors - package kotlinx.metadata.klib import kotlin.metadata.* -import kotlin.metadata.internal.common.KmModuleFragmentExtensionVisitor +import kotlin.metadata.internal.extensions.* -abstract class KlibFunctionExtensionVisitor : KmFunctionExtensionVisitor { +abstract class KlibFunctionExtensionVisitor : KmFunctionExtension { abstract fun visitAnnotation(annotation: KmAnnotation) @@ -25,7 +23,7 @@ abstract class KlibFunctionExtensionVisitor : KmFunctionExtensionVisitor { } } -abstract class KlibClassExtensionVisitor : KmClassExtensionVisitor { +abstract class KlibClassExtensionVisitor : KmClassExtension { abstract fun visitAnnotation(annotation: KmAnnotation) @@ -43,7 +41,7 @@ abstract class KlibClassExtensionVisitor : KmClassExtensionVisitor { } } -abstract class KlibTypeExtensionVisitor : KmTypeExtensionVisitor { +abstract class KlibTypeExtensionVisitor : KmTypeExtension { abstract fun visitAnnotation(annotation: KmAnnotation) @@ -55,7 +53,7 @@ abstract class KlibTypeExtensionVisitor : KmTypeExtensionVisitor { } } -abstract class KlibPropertyExtensionVisitor : KmPropertyExtensionVisitor { +abstract class KlibPropertyExtensionVisitor : KmPropertyExtension { abstract fun visitAnnotation(annotation: KmAnnotation) @@ -77,7 +75,7 @@ abstract class KlibPropertyExtensionVisitor : KmPropertyExtensionVisitor { } } -abstract class KlibConstructorExtensionVisitor : KmConstructorExtensionVisitor { +abstract class KlibConstructorExtensionVisitor : KmConstructorExtension { abstract fun visitAnnotation(annotation: KmAnnotation) @@ -91,7 +89,7 @@ abstract class KlibConstructorExtensionVisitor : KmConstructorExtensionVisitor { } } -abstract class KlibTypeParameterExtensionVisitor : KmTypeParameterExtensionVisitor { +abstract class KlibTypeParameterExtensionVisitor : KmTypeParameterExtension { abstract fun visitAnnotation(annotation: KmAnnotation) @@ -105,7 +103,7 @@ abstract class KlibTypeParameterExtensionVisitor : KmTypeParameterExtensionVisit } } -abstract class KlibPackageExtensionVisitor : KmPackageExtensionVisitor { +abstract class KlibPackageExtensionVisitor : KmPackageExtension { abstract fun visitFqName(name: String) @@ -117,7 +115,7 @@ abstract class KlibPackageExtensionVisitor : KmPackageExtensionVisitor { } } -abstract class KlibModuleFragmentExtensionVisitor : KmModuleFragmentExtensionVisitor { +abstract class KlibModuleFragmentExtensionVisitor : KmModuleFragmentExtension { abstract fun visitFile(file: KlibSourceFile) @@ -133,7 +131,7 @@ abstract class KlibModuleFragmentExtensionVisitor : KmModuleFragmentExtensionVis } } -abstract class KlibTypeAliasExtensionVisitor : KmTypeAliasExtensionVisitor { +abstract class KlibTypeAliasExtensionVisitor : KmTypeAliasExtension { abstract fun visitUniqId(uniqId: UniqId) @@ -145,7 +143,7 @@ abstract class KlibTypeAliasExtensionVisitor : KmTypeAliasExtensionVisitor { } } -abstract class KlibValueParameterExtensionVisitor : KmValueParameterExtensionVisitor { +abstract class KlibValueParameterExtensionVisitor : KmValueParameterExtension { abstract fun visitAnnotation(annotation: KmAnnotation) diff --git a/libraries/kotlinx-metadata/src/kotlin/metadata/Annotations.kt b/libraries/kotlinx-metadata/src/kotlin/metadata/Annotations.kt index 7764112dcd8..5ea20e7d7e5 100644 --- a/libraries/kotlinx-metadata/src/kotlin/metadata/Annotations.kt +++ b/libraries/kotlinx-metadata/src/kotlin/metadata/Annotations.kt @@ -159,23 +159,7 @@ public sealed class KmAnnotationArgument { * * @property className FQ name of the referenced class. */ - @Suppress("DEPRECATION_ERROR") - public data class KClassValue @Deprecated( - "Use single-argument constructor instead or ArrayKClassValue", - level = DeprecationLevel.ERROR - ) constructor( - val className: ClassName, - @Deprecated( - "Use ArrayKClassValue instead", - level = DeprecationLevel.ERROR - ) val arrayDimensionCount: Int - ) : KmAnnotationArgument() { - public constructor(className: ClassName) : this(className, 0) - - init { - require(arrayDimensionCount == 0) { "KClassValue must not have array dimensions. For Array::class, use ArrayKClassValue." } - } - + public data class KClassValue(val className: ClassName) : KmAnnotationArgument() { override fun toString(): String = "KClassValue($className)" } diff --git a/libraries/kotlinx-metadata/src/kotlin/metadata/Attributes.kt b/libraries/kotlinx-metadata/src/kotlin/metadata/Attributes.kt index 7a8a2bdd85b..1376b2f3cc7 100644 --- a/libraries/kotlinx-metadata/src/kotlin/metadata/Attributes.kt +++ b/libraries/kotlinx-metadata/src/kotlin/metadata/Attributes.kt @@ -3,7 +3,6 @@ * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ -@file:Suppress("DEPRECATION_ERROR") // flags will become internal eventually @file:JvmName("Attributes") package kotlin.metadata @@ -295,18 +294,6 @@ public var KmProperty.kind: MemberKind by memberKindDelegate(KmProperty::flags) */ public var KmProperty.isVar: Boolean by propertyBooleanFlag(FlagImpl(ProtoFlags.IS_VAR)) -/** - * Indicates that the corresponding property has a getter. - */ -@Deprecated("Kotlin properties always have getters", ReplaceWith("true"), DeprecationLevel.ERROR) -public var KmProperty.hasGetter: Boolean by propertyBooleanFlag(FlagImpl(ProtoFlags.HAS_GETTER)) - -/** - * Indicates that the corresponding property has a setter. - */ -@Deprecated("Check .setter for nullability instead", ReplaceWith("this.setter != null"), DeprecationLevel.ERROR) -public var KmProperty.hasSetter: Boolean by propertyBooleanFlag(FlagImpl(ProtoFlags.HAS_SETTER)) - /** * Indicates that the corresponding property is `const`. */ diff --git a/libraries/kotlinx-metadata/src/kotlin/metadata/ClassName.kt b/libraries/kotlinx-metadata/src/kotlin/metadata/ClassName.kt index 1edfd36e7ba..ebd4f580c6a 100644 --- a/libraries/kotlinx-metadata/src/kotlin/metadata/ClassName.kt +++ b/libraries/kotlinx-metadata/src/kotlin/metadata/ClassName.kt @@ -24,10 +24,3 @@ public typealias ClassName = String // Not a value class because of Java usages * A class name represents a local class or an anonymous object if it starts with '.' (dot). */ public fun ClassName.isLocalClassName(): Boolean = this.startsWith(".") - -@Deprecated( - "Renamed to isLocalClassName() to avoid confusion with String properties", - ReplaceWith("isLocalClassName()"), - level = DeprecationLevel.ERROR -) -public val ClassName.isLocal: Boolean get() = isLocalClassName() diff --git a/libraries/kotlinx-metadata/src/kotlin/metadata/Contracts.kt b/libraries/kotlinx-metadata/src/kotlin/metadata/Contracts.kt new file mode 100644 index 00000000000..f645d9770d1 --- /dev/null +++ b/libraries/kotlinx-metadata/src/kotlin/metadata/Contracts.kt @@ -0,0 +1,158 @@ +/* + * Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package kotlin.metadata + +import kotlin.contracts.ExperimentalContracts + +/** + * Represents a contract of a Kotlin function. + * + * Contracts are an internal feature of the standard Kotlin library, and their behavior and/or binary format + * may change in a subsequent release. + */ +@ExperimentalContracts +public class KmContract { + /** + * Effects of this contract. + */ + public val effects: MutableList = ArrayList(1) +} + +/** + * Represents an effect (a part of the contract of a Kotlin function). + * + * Contracts are an internal feature of the standard Kotlin library, and their behavior and/or binary format + * may change in a subsequent release. + * + * @property type type of the effect + * @property invocationKind optional number of invocations of the lambda parameter of this function, + * specified further in the effect expression + */ +@ExperimentalContracts +public class KmEffect( + public var type: KmEffectType, + public var invocationKind: KmEffectInvocationKind?, +) { + /** + * Arguments of the effect constructor, i.e. the constant value for the [KmEffectType.RETURNS_CONSTANT] effect, + * or the parameter reference for the [KmEffectType.CALLS] effect. + */ + public val constructorArguments: MutableList = ArrayList(1) + + /** + * Conclusion of the effect. If this value is set, the effect represents an implication with this value as the right-hand side. + */ + public var conclusion: KmEffectExpression? = null +} + +/** + * Represents an effect expression, the contents of an effect (a part of the contract of a Kotlin function). + * + * Contracts are an internal feature of the standard Kotlin library, and their behavior and/or binary format + * may change in a subsequent release. + * + * Various effect expression attributes can be read and manipulated via extension properties, + * such as [KmEffectExpression.isNegated]. + */ +@ExperimentalContracts +public class KmEffectExpression { + internal var flags: Int = 0 + + /** + * Optional 1-based index of the value parameter of the function, for effects which assert something about + * the function parameters. Index 0 means the extension receiver parameter. + */ + public var parameterIndex: Int? = null + + /** + * Constant value used in the effect expression. + */ + public var constantValue: KmConstantValue? = null + + /** + * Type used as the target of an `is`-expression in the effect expression. + */ + public var isInstanceType: KmType? = null + + /** + * Arguments of an `&&`-expression. If this list is non-empty, the resulting effect expression is a conjunction of this expression + * and elements of the list. + */ + public val andArguments: MutableList = ArrayList(0) + + /** + * Arguments of an `||`-expression. If this list is non-empty, the resulting effect expression is a disjunction of this expression + * and elements of the list. + */ + public val orArguments: MutableList = ArrayList(0) +} + +/** + * Represents a constant value used in an effect expression. + * + * Contracts are an internal feature of the standard Kotlin library, and their behavior and/or binary format + * may change in a subsequent release. + * + * @property value the constant value. May be `true`, `false` or `null` + */ +@ExperimentalContracts +public data class KmConstantValue(val value: Any?) + + +/** + * Type of an effect (a part of the contract of a Kotlin function). + * + * Contracts are an internal feature of the standard Kotlin library, and their behavior and/or binary format + * may change in a subsequent release. + */ +@ExperimentalContracts +public enum class KmEffectType { + /** + * Represents `returns(value)` contract effect: + * a situation when a function returns normally with the specified return value. + * Return value is stored in the [KmEffect.constructorArguments]. + */ + RETURNS_CONSTANT, + + /** + * Represents `callsInPlace` contract effect: + * A situation when the referenced lambda is invoked in place (optionally) specified number of times. + * + * Referenced lambda is stored in the [KmEffect.constructorArguments]. + * Number of invocations, if specified, is stored in [KmEffect.invocationKind]. + */ + CALLS, + + /** + * Represents `returnsNotNull` contract effect: + * a situation when a function returns normally with any value that is not null. + */ + RETURNS_NOT_NULL, +} + +/** + * Number of invocations of a lambda parameter specified by an effect (a part of the contract of a Kotlin function). + * + * Contracts are an internal feature of the standard Kotlin library, and their behavior and/or binary format + * may change in a subsequent release. + */ +@ExperimentalContracts +public enum class KmEffectInvocationKind { + /** + * A function parameter will be invoked one time or not invoked at all. + */ + AT_MOST_ONCE, + + /** + * A function parameter will be invoked exactly one time. + */ + EXACTLY_ONCE, + + /** + * A function parameter will be invoked one or more times. + */ + AT_LEAST_ONCE, +} diff --git a/libraries/kotlinx-metadata/src/kotlin/metadata/Extensions.kt b/libraries/kotlinx-metadata/src/kotlin/metadata/Extensions.kt deleted file mode 100644 index 4d842509571..00000000000 --- a/libraries/kotlinx-metadata/src/kotlin/metadata/Extensions.kt +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ -@file:Suppress("DEPRECATION_ERROR") - -package kotlin.metadata - -import kotlin.reflect.KClass - -/** - * A type of the extension visitor expected by the code that uses the visitor API. - * - * Each declaration which can have platform-specific extensions in the metadata has a method `visitExtensions` in its visitor, e.g.: - * - * open fun visitExtensions(type: KmExtensionType): KmFunctionExtensionVisitor? - * - * The client code is supposed to return the extension visitor corresponding to the given type, or to return `null` if the type is - * of no interest to that code. Each platform-specific extension visitor has a [KmExtensionType] instance declared in the `TYPE` property - * its companion object. For example, to load JVM extensions on a function, one could do: - * ``` - * override fun visitExtensions(type: KmExtensionType): KmFunctionExtensionVisitor? { - * if (type != JvmFunctionExtensionVisitor.TYPE) return null - * - * return object : JvmFunctionExtensionVisitor() { - * ... - * } - * } - * ``` - * In case an extension visitor of an unrelated type is returned, the code using the visitor API must ignore that visitor. - */ -@Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) -public class KmExtensionType(private val klass: KClass) { - override fun equals(other: Any?): Boolean = - other is KmExtensionType && klass == other.klass - - override fun hashCode(): Int = - klass.hashCode() - - override fun toString(): String = - klass.java.name -} - -/** - * A base interface for all extension visitors. - */ -@Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) -public interface KmExtensionVisitor { - /** - * Type of this extension visitor. - */ - public val type: KmExtensionType -} - -/** - * A visitor to visit platform-specific extensions for a declaration container, such as a class or a package fragment. - */ -@Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) -public interface KmDeclarationContainerExtensionVisitor : KmExtensionVisitor - -/** - * A visitor to visit platform-specific extensions for a class. - */ -@Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) -public interface KmClassExtensionVisitor : KmDeclarationContainerExtensionVisitor - -/** - * A visitor to visit platform-specific extensions for a package fragment. - */ -@Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) -public interface KmPackageExtensionVisitor : KmDeclarationContainerExtensionVisitor - -/** - * A visitor to visit platform-specific extensions for a function. - */ -@Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) -public interface KmFunctionExtensionVisitor : KmExtensionVisitor - -/** - * A visitor to visit platform-specific extensions for a property. - */ -@Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) -public interface KmPropertyExtensionVisitor : KmExtensionVisitor - -/** - * A visitor to visit platform-specific extensions for a constructor. - */ -@Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) -public interface KmConstructorExtensionVisitor : KmExtensionVisitor - -/** - * A visitor to visit platform-specific extensions for a type parameter. - */ -@Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) -public interface KmTypeParameterExtensionVisitor : KmExtensionVisitor - -/** - * A visitor to visit platform-specific extensions for a type. - */ -@Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) -public interface KmTypeExtensionVisitor : KmExtensionVisitor - -/** - * A visitor to visit platform-specific extensions for a type alias. - */ -@Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) -public interface KmTypeAliasExtensionVisitor : KmExtensionVisitor - -/** - * A visitor to visit platform-specific extensions for a value parameter. - */ -@Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) -public interface KmValueParameterExtensionVisitor : KmExtensionVisitor diff --git a/libraries/kotlinx-metadata/src/kotlin/metadata/Flag.kt b/libraries/kotlinx-metadata/src/kotlin/metadata/Flag.kt deleted file mode 100644 index bd19a080bbb..00000000000 --- a/libraries/kotlinx-metadata/src/kotlin/metadata/Flag.kt +++ /dev/null @@ -1,611 +0,0 @@ -/* - * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -package kotlin.metadata - -import kotlin.metadata.internal.IgnoreInApiDump -import org.jetbrains.kotlin.metadata.ProtoBuf.* -import org.jetbrains.kotlin.metadata.ProtoBuf.Class.Kind as ClassKind -import org.jetbrains.kotlin.metadata.deserialization.Flags as F -import org.jetbrains.kotlin.metadata.ProtoBuf.Modality as ProtoModality -import org.jetbrains.kotlin.metadata.ProtoBuf.Visibility as ProtoVisibility -import org.jetbrains.kotlin.metadata.ProtoBuf.MemberKind as ProtoMemberKind - -private const val prefix = "Flag API is deprecated. Please use" - -/** - * Represents a boolean flag that is either present or not in a Kotlin declaration. A "flag" is a boolean trait that is either present - * or not in a declaration. To check whether the flag is present in the bitmask, call [Flag.invoke] on the flag, passing the bitmask - * as the argument: - * - * override fun visitFunction(flags: Flags, name: String): KmFunctionVisitor? { - * if (Flag.Function.IS_INLINE(flags)) { - * ... - * } - * } - * - * To construct a bitmask out of several flags, call [flagsOf] on the needed flags: - * - * v.visitFunction(flagsOf(Flag.Function.IS_DECLARATION, Flag.Function.IS_INLINE), "foo") - * - * Flags common to multiple kinds of Kotlin declarations ("common flags") are declared in [Flag.Common]. - * Flags applicable to specific kinds of declarations ("declaration-specific flags") are declared in nested objects of the [Flag] object. - * - * Some flags are mutually exclusive, i.e. there are "flag groups" such that no more than one flag from each group can be present - * in the same bitmask. Among common flags, there are the following flag groups: - * * visibility flags: [IS_INTERNAL], [IS_PRIVATE], [IS_PROTECTED], [IS_PUBLIC], [IS_PRIVATE_TO_THIS], [IS_LOCAL] - * * modality flags: [IS_FINAL], [IS_OPEN], [IS_ABSTRACT], [IS_SEALED] - * - * Some declaration-specific flags form other flag groups, see the documentation of the corresponding containers for more information. - * - * @see Flags - * @see flagsOf - */ -@Deprecated("$prefix corresponding extensions on Km nodes, such as KmClass.visibility", level = DeprecationLevel.ERROR) -@Suppress("DEPRECATION_ERROR") -public class Flag public constructor(internal val offset: Int, internal val bitWidth: Int, internal val value: Int) { - - // Implementation copies FlagImpl to avoid reusing of deprecated declarations. - @IgnoreInApiDump - internal constructor(field: F.FlagField<*>, value: Int) : this(field.offset, field.bitWidth, value) - - @IgnoreInApiDump - internal constructor(field: F.BooleanFlagField) : this(field, 1) - - internal operator fun plus(flags: Int): Int = - (flags and (((1 shl bitWidth) - 1) shl offset).inv()) + (value shl offset) - - /** - * Checks whether the flag is present in the given bitmask. - */ - public operator fun invoke(flags: Int): Boolean = (flags ushr offset) and ((1 shl bitWidth) - 1) == value - - /** @suppress deprecated */ - @Deprecated("$prefix corresponding extensions on Km nodes, such as KmClass.visibility", level = DeprecationLevel.ERROR) - public companion object Common { - /** - * Signifies that the corresponding declaration has at least one annotation. - * - * This flag is useful for reading Kotlin metadata on JVM efficiently. On JVM, most of the annotations are written not to the Kotlin - * metadata, but directly on the corresponding declarations in the class file. This flag can be used as an optimization to avoid - * reading annotations from the class file (which can be slow) in case when a declaration has no annotations. - */ - @JvmField - @Deprecated("$prefix corresponding extension on a node, e.g. KmClass.hasAnnotations", level = DeprecationLevel.ERROR) - public val HAS_ANNOTATIONS: Flag = Flag(F.HAS_ANNOTATIONS) - - - /** - * A visibility flag, signifying that the corresponding declaration is `internal`. - */ - @JvmField - @Deprecated("$prefix visibility extension on a node, e.g. KmClass.visibility", level = DeprecationLevel.ERROR) - public val IS_INTERNAL: Flag = Flag(F.VISIBILITY, ProtoVisibility.INTERNAL_VALUE) - - /** - * A visibility flag, signifying that the corresponding declaration is `private`. - */ - @JvmField - @Deprecated("$prefix visibility extension on a node, e.g. KmClass.visibility", level = DeprecationLevel.ERROR) - public val IS_PRIVATE: Flag = Flag(F.VISIBILITY, ProtoVisibility.PRIVATE_VALUE) - - /** - * A visibility flag, signifying that the corresponding declaration is `protected`. - */ - @JvmField - @Deprecated("$prefix visibility extension on a node, e.g. KmClass.visibility", level = DeprecationLevel.ERROR) - public val IS_PROTECTED: Flag = Flag(F.VISIBILITY, ProtoVisibility.PROTECTED_VALUE) - - /** - * A visibility flag, signifying that the corresponding declaration is `public`. - */ - @JvmField - @Deprecated("$prefix visibility extension on a node, e.g. KmClass.visibility", level = DeprecationLevel.ERROR) - public val IS_PUBLIC: Flag = Flag(F.VISIBILITY, ProtoVisibility.PUBLIC_VALUE) - - /** - * A visibility flag, signifying that the corresponding declaration is "private-to-this", which is a non-denotable visibility of - * private members in Kotlin which are callable only on the same instance of the declaring class. - */ - @JvmField - @Deprecated("$prefix visibility extension on a node, e.g. KmClass.visibility", level = DeprecationLevel.ERROR) - public val IS_PRIVATE_TO_THIS: Flag = Flag(F.VISIBILITY, ProtoVisibility.PRIVATE_TO_THIS_VALUE) - - /** - * A visibility flag, signifying that the corresponding declaration is local, i.e. declared inside a code block - * and not visible from the outside. - */ - @JvmField - @Deprecated("$prefix visibility extension on a node, e.g. KmClass.visibility", level = DeprecationLevel.ERROR) - public val IS_LOCAL: Flag = Flag(F.VISIBILITY, ProtoVisibility.LOCAL_VALUE) - - - /** - * A modality flag, signifying that the corresponding declaration is `final`. - */ - @JvmField - @Deprecated("$prefix modality extension on a node, e.g. KmClass.modality or KmFunction.modality", level = DeprecationLevel.ERROR) - public val IS_FINAL: Flag = Flag(F.MODALITY, ProtoModality.FINAL_VALUE) - - /** - * A modality flag, signifying that the corresponding declaration is `open`. - */ - @JvmField - @Deprecated("$prefix modality extension on a node, e.g. KmClass.modality or KmFunction.modality", level = DeprecationLevel.ERROR) - public val IS_OPEN: Flag = Flag(F.MODALITY, ProtoModality.OPEN_VALUE) - - /** - * A modality flag, signifying that the corresponding declaration is `abstract`. - */ - @JvmField - @Deprecated("$prefix modality extension on a node, e.g. KmClass.modality or KmFunction.modality", level = DeprecationLevel.ERROR) - public val IS_ABSTRACT: Flag = Flag(F.MODALITY, ProtoModality.ABSTRACT_VALUE) - - /** - * A modality flag, signifying that the corresponding declaration is `sealed`. - */ - @JvmField - @Deprecated("$prefix modality extension on a node, e.g. KmClass.modality", level = DeprecationLevel.ERROR) - public val IS_SEALED: Flag = Flag(F.MODALITY, ProtoModality.SEALED_VALUE) - } - - /** - * A container of flags applicable to Kotlin classes, including interfaces, objects, enum classes and annotation classes. - * - * In addition to the common flag groups, the following flag groups exist for class flags: - * * class kind flags: [IS_CLASS], [IS_INTERFACE], [IS_ENUM_CLASS], [IS_ENUM_ENTRY], [IS_ANNOTATION_CLASS], [IS_OBJECT], - * [IS_COMPANION_OBJECT] - */ - @Deprecated("$prefix corresponding extension on a KmClass", level = DeprecationLevel.ERROR) - public object Class { - /** - * A class kind flag, signifying that the corresponding class is a usual `class`. - */ - @JvmField - @Deprecated("$prefix KmClass.kind", level = DeprecationLevel.ERROR) - public val IS_CLASS: Flag = Flag(F.CLASS_KIND, ClassKind.CLASS_VALUE) - - /** - * A class kind flag, signifying that the corresponding class is an `interface`. - */ - @JvmField - @Deprecated("$prefix KmClass.kind", level = DeprecationLevel.ERROR) - public val IS_INTERFACE: Flag = Flag(F.CLASS_KIND, ClassKind.INTERFACE_VALUE) - - /** - * A class kind flag, signifying that the corresponding class is an `enum class`. - */ - @JvmField - @Deprecated("$prefix KmClass.kind", level = DeprecationLevel.ERROR) - public val IS_ENUM_CLASS: Flag = Flag(F.CLASS_KIND, ClassKind.ENUM_CLASS_VALUE) - - /** - * A class kind flag, signifying that the corresponding class is an enum entry. - */ - @JvmField - @Deprecated("$prefix KmClass.kind", level = DeprecationLevel.ERROR) - public val IS_ENUM_ENTRY: Flag = Flag(F.CLASS_KIND, ClassKind.ENUM_ENTRY_VALUE) - - /** - * A class kind flag, signifying that the corresponding class is an `annotation class`. - */ - @JvmField - @Deprecated("$prefix KmClass.kind", level = DeprecationLevel.ERROR) - public val IS_ANNOTATION_CLASS: Flag = Flag(F.CLASS_KIND, ClassKind.ANNOTATION_CLASS_VALUE) - - /** - * A class kind flag, signifying that the corresponding class is a non-companion `object`. - */ - @JvmField - @Deprecated("$prefix KmClass.kind", level = DeprecationLevel.ERROR) - public val IS_OBJECT: Flag = Flag(F.CLASS_KIND, ClassKind.OBJECT_VALUE) - - /** - * A class kind flag, signifying that the corresponding class is a `companion object`. - */ - @JvmField - @Deprecated("$prefix KmClass.kind", level = DeprecationLevel.ERROR) - public val IS_COMPANION_OBJECT: Flag = Flag(F.CLASS_KIND, ClassKind.COMPANION_OBJECT_VALUE) - - - /** - * Signifies that the corresponding class is `inner`. - */ - @JvmField - @Deprecated("$prefix KmClass.isInner", level = DeprecationLevel.ERROR) - public val IS_INNER: Flag = Flag(F.IS_INNER) - - /** - * Signifies that the corresponding class is `data`. - */ - @JvmField - @Deprecated("$prefix KmClass.isData", level = DeprecationLevel.ERROR) - public val IS_DATA: Flag = Flag(F.IS_DATA) - - /** - * Signifies that the corresponding class is `external`. - */ - @JvmField - @Deprecated("$prefix KmClass.isExternal", level = DeprecationLevel.ERROR) - public val IS_EXTERNAL: Flag = Flag(F.IS_EXTERNAL_CLASS) - - /** - * Signifies that the corresponding class is `expect`. - */ - @JvmField - @Deprecated("$prefix KmClass.isExpect", level = DeprecationLevel.ERROR) - public val IS_EXPECT: Flag = Flag(F.IS_EXPECT_CLASS) - - @JvmField - @Deprecated( - "Use IS_VALUE instead, which returns true if the class is either a pre-1.5 inline class, or a 1.5+ value class.", - level = DeprecationLevel.ERROR - ) - @Suppress("unused") - public val IS_INLINE: Flag = Flag(F.IS_VALUE_CLASS) - - /** - * Signifies that the corresponding class is either a pre-Kotlin-1.5 `inline` class, or a 1.5+ `value` class. - */ - @JvmField - @Deprecated("$prefix KmClass.isValue", level = DeprecationLevel.ERROR) - public val IS_VALUE: Flag = Flag(F.IS_VALUE_CLASS) - - /** - * Signifies that the corresponding class is a functional interface, i.e. marked with the keyword `fun`. - */ - @JvmField - @Deprecated("$prefix KmClass.isFun", level = DeprecationLevel.ERROR) - public val IS_FUN: Flag = Flag(F.IS_FUN_INTERFACE) - - /** - * Signifies that the corresponding enum class has ".entries" property in bytecode. - * Always `false` for not enum classes. - */ - @JvmField - @Deprecated("$prefix KmClass.hasEnumEntries", level = DeprecationLevel.ERROR) - public val HAS_ENUM_ENTRIES: Flag = Flag(F.HAS_ENUM_ENTRIES) - } - - /** - * A container of flags applicable to Kotlin constructors. - */ - public object Constructor { - @JvmField - @Deprecated("Use IS_SECONDARY which holds inverted value instead.", level = DeprecationLevel.ERROR) - @Suppress("unused") - public val IS_PRIMARY: Flag = Flag(F.IS_SECONDARY, 0) - - /** - * Signifies that the corresponding constructor is secondary, i.e. declared not in the class header, but in the class body. - */ - @JvmField - @Deprecated("$prefix KmConstructor.isSecondary", level = DeprecationLevel.ERROR) - public val IS_SECONDARY: Flag = Flag(F.IS_SECONDARY) - - /** - * Signifies that the corresponding constructor has non-stable parameter names, i.e. cannot be called with named arguments. - */ - @JvmField - @Deprecated("$prefix KmConstructor.hasNonStableParameterNames", level = DeprecationLevel.ERROR) - public val HAS_NON_STABLE_PARAMETER_NAMES: Flag = Flag(F.IS_CONSTRUCTOR_WITH_NON_STABLE_PARAMETER_NAMES) - } - - /** - * A container of flags applicable to Kotlin functions. - * - * In addition to the common flag groups, the following flag groups exist for function flags: - * * member kind flags: [IS_DECLARATION], [IS_FAKE_OVERRIDE], [IS_DELEGATION], [IS_SYNTHESIZED] - */ - public object Function { - /** - * A member kind flag, signifying that the corresponding function is explicitly declared in the containing class. - */ - @JvmField - @Deprecated("$prefix KmFunction.kind", level = DeprecationLevel.ERROR) - public val IS_DECLARATION: Flag = Flag(F.MEMBER_KIND, ProtoMemberKind.DECLARATION_VALUE) - - /** - * A member kind flag, signifying that the corresponding function exists in the containing class because a function with a suitable - * signature exists in a supertype. This flag is not written by the Kotlin compiler and its effects are unspecified. - */ - @JvmField - @Deprecated("$prefix KmFunction.kind", level = DeprecationLevel.ERROR) - public val IS_FAKE_OVERRIDE: Flag = Flag(F.MEMBER_KIND, ProtoMemberKind.FAKE_OVERRIDE_VALUE) - - /** - * A member kind flag, signifying that the corresponding function exists in the containing class because it has been produced - * by interface delegation (delegation "by"). - */ - @JvmField - @Deprecated("$prefix KmFunction.kind", level = DeprecationLevel.ERROR) - public val IS_DELEGATION: Flag = Flag(F.MEMBER_KIND, ProtoMemberKind.DELEGATION_VALUE) - - /** - * A member kind flag, signifying that the corresponding function exists in the containing class because it has been synthesized - * by the compiler and has no declaration in the source code. - */ - @JvmField - @Deprecated("$prefix KmFunction.kind", level = DeprecationLevel.ERROR) - public val IS_SYNTHESIZED: Flag = Flag(F.MEMBER_KIND, ProtoMemberKind.SYNTHESIZED_VALUE) - - /** - * Signifies that the corresponding function is `operator`. - */ - @JvmField - @Deprecated("$prefix KmFunction.isOperator", level = DeprecationLevel.ERROR) - public val IS_OPERATOR: Flag = Flag(F.IS_OPERATOR) - - /** - * Signifies that the corresponding function is `infix`. - */ - @JvmField - @Deprecated("$prefix KmFunction.isInfix", level = DeprecationLevel.ERROR) - public val IS_INFIX: Flag = Flag(F.IS_INFIX) - - /** - * Signifies that the corresponding function is `inline`. - */ - @JvmField - @Deprecated("$prefix KmFunction.isInline", level = DeprecationLevel.ERROR) - public val IS_INLINE: Flag = Flag(F.IS_INLINE) - - /** - * Signifies that the corresponding function is `tailrec`. - */ - @JvmField - @Deprecated("$prefix KmFunction.isTailrec", level = DeprecationLevel.ERROR) - public val IS_TAILREC: Flag = Flag(F.IS_TAILREC) - - /** - * Signifies that the corresponding function is `external`. - */ - @JvmField - @Deprecated("$prefix KmFunction.isExternalFunction", level = DeprecationLevel.ERROR) - public val IS_EXTERNAL: Flag = Flag(F.IS_EXTERNAL_FUNCTION) - - /** - * Signifies that the corresponding function is `suspend`. - */ - @JvmField - @Deprecated("$prefix KmFunction.isSuspend", level = DeprecationLevel.ERROR) - public val IS_SUSPEND: Flag = Flag(F.IS_SUSPEND) - - /** - * Signifies that the corresponding function is `expect`. - */ - @JvmField - @Deprecated("$prefix KmFunction.isExpectFunction", level = DeprecationLevel.ERROR) - public val IS_EXPECT: Flag = Flag(F.IS_EXPECT_FUNCTION) - - /** - * Signifies that the corresponding function has non-stable parameter names, i.e. cannot be called with named arguments. - */ - @JvmField - @Deprecated("$prefix KmFunction.isFunctionWithNonStableParameterNames", level = DeprecationLevel.ERROR) - public val HAS_NON_STABLE_PARAMETER_NAMES: Flag = Flag(F.IS_FUNCTION_WITH_NON_STABLE_PARAMETER_NAMES) - } - - /** - * A container of flags applicable to Kotlin properties. - * - * In addition to the common flag groups, the following flag groups exist for property flags: - * * member kind flags: [IS_DECLARATION], [IS_FAKE_OVERRIDE], [IS_DELEGATION], [IS_SYNTHESIZED] - */ - public object Property { - /** - * A member kind flag, signifying that the corresponding property is explicitly declared in the containing class. - */ - @JvmField - @Deprecated("$prefix KmProperty.kind", level = DeprecationLevel.ERROR) - public val IS_DECLARATION: Flag = Flag(F.MEMBER_KIND, ProtoMemberKind.DECLARATION_VALUE) - - /** - * A member kind flag, signifying that the corresponding property exists in the containing class because a property with a suitable - * signature exists in a supertype. This flag is not written by the Kotlin compiler and its effects are unspecified. - */ - @JvmField - @Deprecated("$prefix KmProperty.kind", level = DeprecationLevel.ERROR) - public val IS_FAKE_OVERRIDE: Flag = Flag(F.MEMBER_KIND, ProtoMemberKind.FAKE_OVERRIDE_VALUE) - - /** - * A member kind flag, signifying that the corresponding property exists in the containing class because it has been produced - * by interface delegation (delegation "by"). - */ - @JvmField - @Deprecated("$prefix KmProperty.kind", level = DeprecationLevel.ERROR) - public val IS_DELEGATION: Flag = Flag(F.MEMBER_KIND, ProtoMemberKind.DELEGATION_VALUE) - - /** - * A member kind flag, signifying that the corresponding property exists in the containing class because it has been synthesized - * by the compiler and has no declaration in the source code. - */ - @JvmField - @Deprecated("$prefix KmProperty.kind", level = DeprecationLevel.ERROR) - public val IS_SYNTHESIZED: Flag = Flag(F.MEMBER_KIND, ProtoMemberKind.SYNTHESIZED_VALUE) - - /** - * Signifies that the corresponding property is `var`. - */ - @JvmField - @Deprecated("$prefix KmProperty.isVar", level = DeprecationLevel.ERROR) - public val IS_VAR: Flag = Flag(F.IS_VAR) - - /** - * Signifies that the corresponding property has a getter. - */ - @JvmField - @Deprecated("$prefix KmProperty.hasGetter", level = DeprecationLevel.ERROR) - public val HAS_GETTER: Flag = Flag(F.HAS_GETTER) - - /** - * Signifies that the corresponding property has a setter. - */ - @JvmField - @Deprecated("$prefix KmProperty.hasSetter", level = DeprecationLevel.ERROR) - public val HAS_SETTER: Flag = Flag(F.HAS_SETTER) - - /** - * Signifies that the corresponding property is `const`. - */ - @JvmField - @Deprecated("$prefix KmProperty.isConst", level = DeprecationLevel.ERROR) - public val IS_CONST: Flag = Flag(F.IS_CONST) - - /** - * Signifies that the corresponding property is `lateinit`. - */ - @JvmField - @Deprecated("$prefix KmProperty.isLateinit", level = DeprecationLevel.ERROR) - public val IS_LATEINIT: Flag = Flag(F.IS_LATEINIT) - - /** - * Signifies that the corresponding property has a constant value. On JVM, this flag allows an optimization similarly to - * [F.HAS_ANNOTATIONS]: constant values of properties are written to the bytecode directly, and this flag can be used to avoid - * reading the value from the bytecode in case there isn't one. - */ - @JvmField - @Deprecated("$prefix KmProperty.hasConstant", level = DeprecationLevel.ERROR) - public val HAS_CONSTANT: Flag = Flag(F.HAS_CONSTANT) - - /** - * Signifies that the corresponding property is `external`. - */ - @JvmField - @Deprecated("$prefix KmProperty.isExternal", level = DeprecationLevel.ERROR) - public val IS_EXTERNAL: Flag = Flag(F.IS_EXTERNAL_PROPERTY) - - /** - * Signifies that the corresponding property is a delegated property. - */ - @JvmField - @Deprecated("$prefix KmProperty.isDelegated", level = DeprecationLevel.ERROR) - public val IS_DELEGATED: Flag = Flag(F.IS_DELEGATED) - - /** - * Signifies that the corresponding property is `expect`. - */ - @JvmField - @Deprecated("$prefix KmProperty.isExpect", level = DeprecationLevel.ERROR) - public val IS_EXPECT: Flag = Flag(F.IS_EXPECT_PROPERTY) - } - - - /** - * A container of flags applicable to Kotlin property getters and setters. - */ - public object PropertyAccessor { - /** - * Signifies that the corresponding property accessor is not default, i.e. it has a body and/or annotations in the source code. - */ - @JvmField - @Deprecated("$prefix KmPropertyAccessorAttributes.isNotDefault", level = DeprecationLevel.ERROR) - public val IS_NOT_DEFAULT: Flag = Flag(F.IS_NOT_DEFAULT) - - /** - * Signifies that the corresponding property accessor is `external`. - */ - @JvmField - @Deprecated("$prefix KmPropertyAccessorAttributes.isExternal", level = DeprecationLevel.ERROR) - public val IS_EXTERNAL: Flag = Flag(F.IS_EXTERNAL_ACCESSOR) - - /** - * Signifies that the corresponding property accessor is `inline`. - */ - @JvmField - @Deprecated("$prefix KmPropertyAccessorAttributes.isInline", level = DeprecationLevel.ERROR) - public val IS_INLINE: Flag = Flag(F.IS_INLINE_ACCESSOR) - } - - /** - * A container of flags applicable to Kotlin types. - */ - public object Type { - /** - * Signifies that the corresponding type is marked as nullable, i.e. has a question mark at the end of its notation. - */ - @JvmField - @Deprecated("$prefix KmType.isNullable", level = DeprecationLevel.ERROR) - public val IS_NULLABLE: Flag = Flag(0, 1, 1) - - /** - * Signifies that the corresponding type is `suspend`. - */ - @JvmField - @Deprecated("$prefix KmType.isSuspend", level = DeprecationLevel.ERROR) - public val IS_SUSPEND: Flag = Flag(F.SUSPEND_TYPE.offset + 1, F.SUSPEND_TYPE.bitWidth, 1) - - /** - * Signifies that the corresponding type is - * [definitely non-null](https://kotlinlang.org/docs/whatsnew17.html#stable-definitely-non-nullable-types). - */ - @JvmField - @Deprecated("$prefix KmType.isDefinitelyNonNull", level = DeprecationLevel.ERROR) - public val IS_DEFINITELY_NON_NULL: Flag = Flag(F.DEFINITELY_NOT_NULL_TYPE.offset + 1, F.DEFINITELY_NOT_NULL_TYPE.bitWidth, 1) - } - - /** - * A container of flags applicable to Kotlin type parameters. - */ - public object TypeParameter { - /** - * Signifies that the corresponding type parameter is `reified`. - */ - @JvmField - @Deprecated("$prefix KmTypeParameter.isReified", level = DeprecationLevel.ERROR) - public val IS_REIFIED: Flag = Flag(0, 1, 1) - } - - /** - * A container of flags applicable to Kotlin value parameters. - */ - public object ValueParameter { - /** - * Signifies that the corresponding value parameter declares a default value. Note that the default value itself can be a complex - * expression and is not available via metadata. Also note that in case of an override of a parameter with default value, the - * parameter in the derived method does _not_ declare the default value ([DECLARES_DEFAULT_VALUE] == false), but the parameter is - * still optional at the call site because the default value from the base method is used. - */ - @JvmField - @Deprecated("$prefix KmValueParameter.declaresDefaultValue", level = DeprecationLevel.ERROR) - public val DECLARES_DEFAULT_VALUE: Flag = Flag(F.DECLARES_DEFAULT_VALUE) - - /** - * Signifies that the corresponding value parameter is `crossinline`. - */ - @JvmField - @Deprecated("$prefix KmValueParameter.isCrossinline", level = DeprecationLevel.ERROR) - public val IS_CROSSINLINE: Flag = Flag(F.IS_CROSSINLINE) - - /** - * Signifies that the corresponding value parameter is `noinline`. - */ - @JvmField - @Deprecated("$prefix KmValueParameter.isNoinline", level = DeprecationLevel.ERROR) - public val IS_NOINLINE: Flag = Flag(F.IS_NOINLINE) - } - - /** - * A container of flags applicable to Kotlin effect expressions. - * - * Contracts are an internal feature of the standard Kotlin library, and their behavior and/or binary format - * may change in a subsequent release. - */ - public object EffectExpression { - /** - * Signifies that the corresponding effect expression should be negated to compute the proposition or the conclusion of an effect. - */ - @JvmField - @Deprecated("$prefix KmEffectExpression.isNegated", level = DeprecationLevel.ERROR) - public val IS_NEGATED: Flag = Flag(F.IS_NEGATED) - - /** - * Signifies that the corresponding effect expression checks whether a value of some variable is `null`. - */ - @JvmField - @Deprecated("$prefix KmEffectExpression.isNullCheckPredicate", level = DeprecationLevel.ERROR) - public val IS_NULL_CHECK_PREDICATE: Flag = Flag(F.IS_NULL_CHECK_PREDICATE) - } -} diff --git a/libraries/kotlinx-metadata/src/kotlin/metadata/Flags.kt b/libraries/kotlinx-metadata/src/kotlin/metadata/Flags.kt deleted file mode 100644 index d337087c6ca..00000000000 --- a/libraries/kotlinx-metadata/src/kotlin/metadata/Flags.kt +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -@file:JvmName("FlagsKt") - -package kotlin.metadata - -import kotlin.metadata.internal.FlagImpl - -/** - * Declaration flags are represented as bitmasks of this type. - * - * @see Flag - */ -@Deprecated( - "Flags API is deprecated and this typealias will be removed. Use Int directly and then migrate to corresponding Km nodes extensions, e.g. KmClass.visibility", - ReplaceWith("Int"), - DeprecationLevel.ERROR -) -public typealias Flags = Int - -/** - * Combines several flags into an integer bitmask. - * - * Note that in case several mutually exclusive flags are passed (for example, several visibility flags), the resulting bitmask will - * hold the value of the latest flag. For example, `flagsOf(Flag.IS_PRIVATE, Flag.IS_PUBLIC, Flag.IS_INTERNAL)` is the same as - * `flagsOf(Flag.IS_INTERNAL)`. - */ -@Suppress("DEPRECATION_ERROR") -@Deprecated( - "Flags API is deprecated and this function will be removed. Create Km nodes directly and then use corresponding Km nodes extensions, e.g. KmClass.visibility", - level = DeprecationLevel.ERROR -) -public fun flagsOf(vararg flags: Flag): Int = - flags.fold(0) { acc, flag -> flag + acc } diff --git a/libraries/kotlinx-metadata/src/kotlin/metadata/Nodes.kt b/libraries/kotlinx-metadata/src/kotlin/metadata/Nodes.kt index 56e7796784d..65b5c7f61aa 100644 --- a/libraries/kotlinx-metadata/src/kotlin/metadata/Nodes.kt +++ b/libraries/kotlinx-metadata/src/kotlin/metadata/Nodes.kt @@ -40,13 +40,8 @@ public interface KmDeclarationContainer { * Precise kind of the class can be obtained via [KmClass.kind]. * Various class attributes can be read and manipulated via extension properties, such as [KmClass.visibility] or [KmClass.isData]. */ -@Suppress("DEPRECATION", "DEPRECATION_ERROR") -public class KmClass : KmClassVisitor(), KmDeclarationContainer { - /** - * Class flags, consisting of [Flag.HAS_ANNOTATIONS], visibility flag, modality flag and [Flag.Class] flags. - */ - @Deprecated("$flagAccessPrefix KmClass, such as KmClass.visibility", level = DeprecationLevel.ERROR) - public var flags: Int = 0 +public class KmClass : KmDeclarationContainer { + internal var flags: Int = 0 /** * Name of the class. @@ -126,105 +121,6 @@ public class KmClass : KmClassVisitor(), KmDeclarationContainer { internal val extensions: List = MetadataExtensions.INSTANCES.map(MetadataExtensions::createClassExtension) - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visit(flags: Int, name: ClassName) { - this.flags = flags - this.name = name - } - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitTypeParameter(flags: Int, name: String, id: Int, variance: KmVariance): KmTypeParameterVisitor = - KmTypeParameter(flags, name, id, variance).addTo(typeParameters) - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitSupertype(flags: Int): KmTypeVisitor = - KmType(flags).addTo(supertypes) - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitFunction(flags: Int, name: String): KmFunctionVisitor = - KmFunction(flags, name).addTo(functions) - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitProperty(flags: Int, name: String, getterFlags: Int, setterFlags: Int): KmPropertyVisitor = - KmProperty(flags, name, getterFlags, setterFlags).addTo(properties) - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitTypeAlias(flags: Int, name: String): KmTypeAliasVisitor = - KmTypeAlias(flags, name).addTo(typeAliases) - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitConstructor(flags: Int): KmConstructorVisitor = - KmConstructor(flags).addTo(constructors) - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitCompanionObject(name: String) { - this.companionObject = name - } - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitNestedClass(name: String) { - nestedClasses.add(name) - } - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitEnumEntry(name: String) { - enumEntries.add(name) - } - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitSealedSubclass(name: ClassName) { - sealedSubclasses.add(name) - } - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitInlineClassUnderlyingPropertyName(name: String) { - inlineClassUnderlyingPropertyName = name - } - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitInlineClassUnderlyingType(flags: Int): KmTypeVisitor = - KmType(flags).also { inlineClassUnderlyingType = it } - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - @ExperimentalContextReceivers - override fun visitContextReceiverType(flags: Int): KmTypeVisitor = - KmType(flags).addTo(contextReceiverTypes) - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitVersionRequirement(): KmVersionRequirementVisitor = - KmVersionRequirement().addTo(versionRequirements) - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitExtensions(type: KmExtensionType): KmClassExtensionVisitor = - extensions.singleOfType(type) - - /** - * Populates the given visitor with data in this class. - * - * @param visitor the visitor which will visit data in this class - */ - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - @OptIn(ExperimentalContextReceivers::class) - public fun accept(visitor: KmClassVisitor) { - visitor.visit(flags, name) - typeParameters.forEach { visitor.visitTypeParameter(it.flags, it.name, it.id, it.variance)?.let(it::accept) } - supertypes.forEach { visitor.visitSupertype(it.flags)?.let(it::accept) } - functions.forEach { visitor.visitFunction(it.flags, it.name)?.let(it::accept) } - properties.forEach { visitor.visitProperty(it.flags, it.name, it.getter.flags, it.setterFlags)?.let(it::accept) } - typeAliases.forEach { visitor.visitTypeAlias(it.flags, it.name)?.let(it::accept) } - constructors.forEach { visitor.visitConstructor(it.flags)?.let(it::accept) } - companionObject?.let(visitor::visitCompanionObject) - nestedClasses.forEach(visitor::visitNestedClass) - enumEntries.forEach(visitor::visitEnumEntry) - sealedSubclasses.forEach(visitor::visitSealedSubclass) - inlineClassUnderlyingPropertyName?.let(visitor::visitInlineClassUnderlyingPropertyName) - inlineClassUnderlyingType?.let { visitor.visitInlineClassUnderlyingType(it.flags)?.let(it::accept) } - contextReceiverTypes.forEach { visitor.visitContextReceiverType(it.flags)?.let(it::accept) } - versionRequirements.forEach { visitor.visitVersionRequirement()?.let(it::accept) } - extensions.forEach { visitor.visitExtensions(it.type)?.let(it::accept) } - visitor.visitEnd() - } } /** @@ -232,8 +128,7 @@ public class KmClass : KmClassVisitor(), KmDeclarationContainer { * Package fragments are produced from single file facades and multi-file class parts. * Note that a package fragment does not contain any classes, as classes are not a part of file facades and have their own metadata. */ -@Suppress("DEPRECATION", "DEPRECATION_ERROR") -public class KmPackage : KmPackageVisitor(), KmDeclarationContainer { +public class KmPackage : KmDeclarationContainer { /** * Functions in the package fragment. */ @@ -251,62 +146,16 @@ public class KmPackage : KmPackageVisitor(), KmDeclarationContainer { internal val extensions: List = MetadataExtensions.INSTANCES.map(MetadataExtensions::createPackageExtension) - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitFunction(flags: Int, name: String): KmFunctionVisitor = - KmFunction(flags, name).addTo(functions) - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitProperty(flags: Int, name: String, getterFlags: Int, setterFlags: Int): KmPropertyVisitor = - KmProperty(flags, name, getterFlags, setterFlags).addTo(properties) - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitTypeAlias(flags: Int, name: String): KmTypeAliasVisitor = - KmTypeAlias(flags, name).addTo(typeAliases) - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitExtensions(type: KmExtensionType): KmPackageExtensionVisitor = - extensions.singleOfType(type) - - /** - * Populates the given visitor with data in this package fragment. - * - * @param visitor the visitor which will visit data in this package fragment - */ - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - public fun accept(visitor: KmPackageVisitor) { - functions.forEach { visitor.visitFunction(it.flags, it.name)?.let(it::accept) } - properties.forEach { visitor.visitProperty(it.flags, it.name, it.getter.flags, it.setterFlags)?.let(it::accept) } - typeAliases.forEach { visitor.visitTypeAlias(it.flags, it.name)?.let(it::accept) } - extensions.forEach { visitor.visitExtensions(it.type)?.let(it::accept) } - visitor.visitEnd() - } } /** * Represents a synthetic class generated for a Kotlin lambda. */ -@Suppress("DEPRECATION", "DEPRECATION_ERROR") -public class KmLambda : KmLambdaVisitor() { +public class KmLambda { /** * Signature of the synthetic anonymous function, representing the lambda. */ public lateinit var function: KmFunction - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitFunction(flags: Int, name: String): KmFunctionVisitor = - KmFunction(flags, name).also { function = it } - - /** - * Populates the given visitor with data in this lambda. - * - * @param visitor the visitor which will visit data in this lambda - */ - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - public fun accept(visitor: KmLambdaVisitor) { - visitor.visitFunction(function.flags, function.name)?.let(function::accept) - visitor.visitEnd() - } } /** @@ -315,11 +164,7 @@ public class KmLambda : KmLambdaVisitor() { * Various constructor attributes can be read and manipulated via extension properties, * such as [KmConstructor.visibility] or [KmConstructor.isSecondary]. */ -@Suppress("DEPRECATION", "DEPRECATION_ERROR") -public class KmConstructor @Deprecated(flagsCtorDeprecated, level = DeprecationLevel.ERROR) constructor( - @Deprecated("$flagAccessPrefix KmConstructor, such as KmConstructor.visibility", level = DeprecationLevel.ERROR) public var flags: Int, -) : - KmConstructorVisitor() { +public class KmConstructor internal constructor(internal var flags: Int) { public constructor() : this(0) /** @@ -334,31 +179,6 @@ public class KmConstructor @Deprecated(flagsCtorDeprecated, level = DeprecationL internal val extensions: List = MetadataExtensions.INSTANCES.map(MetadataExtensions::createConstructorExtension) - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitValueParameter(flags: Int, name: String): KmValueParameterVisitor = - KmValueParameter(flags, name).addTo(valueParameters) - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitVersionRequirement(): KmVersionRequirementVisitor = - KmVersionRequirement().addTo(versionRequirements) - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitExtensions(type: KmExtensionType): KmConstructorExtensionVisitor = - extensions.singleOfType(type) - - /** - * Populates the given visitor with data in this constructor. - * - * @param visitor the visitor which will visit data in this class - */ - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - public fun accept(visitor: KmConstructorVisitor) { - valueParameters.forEach { visitor.visitValueParameter(it.flags, it.name)?.let(it::accept) } - versionRequirements.forEach { visitor.visitVersionRequirement()?.let(it::accept) } - extensions.forEach { visitor.visitExtensions(it.type)?.let(it::accept) } - visitor.visitEnd() - } } /** @@ -369,11 +189,7 @@ public class KmConstructor @Deprecated(flagsCtorDeprecated, level = DeprecationL * * @property name the name of the function */ -@Suppress("DEPRECATION", "DEPRECATION_ERROR") -public class KmFunction @Deprecated(flagsCtorDeprecated, level = DeprecationLevel.ERROR) constructor( - @Deprecated("$flagAccessPrefix KmFunction, such as KmFunction.visibility", level = DeprecationLevel.ERROR) public var flags: Int, - public var name: String, -) : KmFunctionVisitor() { +public class KmFunction internal constructor(internal var flags: Int, public var name: String) { public constructor(name: String) : this(0, name) @@ -416,59 +232,6 @@ public class KmFunction @Deprecated(flagsCtorDeprecated, level = DeprecationLeve internal val extensions: List = MetadataExtensions.INSTANCES.map(MetadataExtensions::createFunctionExtension) - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitTypeParameter(flags: Int, name: String, id: Int, variance: KmVariance): KmTypeParameterVisitor = - KmTypeParameter(flags, name, id, variance).addTo(typeParameters) - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitReceiverParameterType(flags: Int): KmTypeVisitor = - KmType(flags).also { receiverParameterType = it } - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - @ExperimentalContextReceivers - override fun visitContextReceiverType(flags: Int): KmTypeVisitor = - KmType(flags).addTo(contextReceiverTypes) - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitValueParameter(flags: Int, name: String): KmValueParameterVisitor = - KmValueParameter(flags, name).addTo(valueParameters) - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitReturnType(flags: Int): KmTypeVisitor = - KmType(flags).also { returnType = it } - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitVersionRequirement(): KmVersionRequirementVisitor = - KmVersionRequirement().addTo(versionRequirements) - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - @ExperimentalContracts - override fun visitContract(): KmContractVisitor = - KmContract().also { contract = it } - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitExtensions(type: KmExtensionType): KmFunctionExtensionVisitor = - extensions.singleOfType(type) - - /** - * Populates the given visitor with data in this function. - * - * @param visitor the visitor which will visit data in this function - */ - @OptIn(ExperimentalContextReceivers::class) - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - public fun accept(visitor: KmFunctionVisitor) { - typeParameters.forEach { visitor.visitTypeParameter(it.flags, it.name, it.id, it.variance)?.let(it::accept) } - receiverParameterType?.let { visitor.visitReceiverParameterType(it.flags)?.let(it::accept) } - contextReceiverTypes.forEach { visitor.visitContextReceiverType(it.flags)?.let(it::accept) } - valueParameters.forEach { visitor.visitValueParameter(it.flags, it.name)?.let(it::accept) } - visitor.visitReturnType(returnType.flags)?.let(returnType::accept) - versionRequirements.forEach { visitor.visitVersionRequirement()?.let(it::accept) } - @OptIn(ExperimentalContracts::class) contract?.let { visitor.visitContract()?.let(it::accept) } - extensions.forEach { visitor.visitExtensions(it.type)?.let(it::accept) } - visitor.visitEnd() - } } /** @@ -491,14 +254,12 @@ public class KmPropertyAccessorAttributes internal constructor(internal var flag * * @property name the name of the property */ -@Suppress("DEPRECATION", "DEPRECATION_ERROR") -public class KmProperty @Deprecated(flagsCtorDeprecated, level = DeprecationLevel.ERROR) constructor( - @Deprecated("$flagAccessPrefix KmProperty, such as KmProperty.visibility", level = DeprecationLevel.ERROR) public var flags: Int, +public class KmProperty internal constructor( + internal var flags: Int, public var name: String, getterFlags: Int, setterFlags: Int, -) : KmPropertyVisitor() { - +) { public constructor(name: String) : this(0, name, 0, 0) // needed for reading/writing flags back to protobuf as a whole pack @@ -527,41 +288,6 @@ public class KmProperty @Deprecated(flagsCtorDeprecated, level = DeprecationLeve field = new } - /** - * A legacy accessor for getter attributes. - * - * Property accessor flags, consisting of [Flag.HAS_ANNOTATIONS], visibility flag, modality flag - * and [Flag.PropertyAccessor] flags. - */ - @Deprecated("$flagAccessPrefix KmProperty.getter, such as KmProperty.getter.isNotDefault", level = DeprecationLevel.ERROR) - public var getterFlags: Int - get() = getter.flags - set(value) { - getter.flags = value - } - - /** - * A legacy accessor to setter attributes. - * - * Property accessor flags, consisting of [Flag.HAS_ANNOTATIONS], visibility flag, modality flag - * and [Flag.PropertyAccessor] flags. - * - * Note that, for compatibility reasons, flags are present even the property is `val` and `setter` is null. - * In that case, flags for hasAnnotation, visibility and modality are copied from properties' flag, which may lead - * to incorrect results. For example, when property is annotated, [setterFlags] will also return true for [Flag.Common.HAS_ANNOTATIONS], - * even though there is no setter nor annotations on it. - * - * Setting this property when setter is absent changes the value, but does not create new [setter]. - * This behavior is for compatibility only and will be removed in future versions. - */ - @Deprecated("$flagAccessPrefix KmProperty.setter, such as KmProperty.setter.isNotDefault", level = DeprecationLevel.ERROR) - public var setterFlags: Int = setterFlags // It's either the correct flags from deserializer, or always 0 in the case of hand-created property - get() = setter?.flags ?: field - set(value) { - setter?.flags = value - field = value - } - /** * Type parameters of the property. */ @@ -603,53 +329,6 @@ public class KmProperty @Deprecated(flagsCtorDeprecated, level = DeprecationLeve internal val extensions: List = MetadataExtensions.INSTANCES.map(MetadataExtensions::createPropertyExtension) - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitTypeParameter(flags: Int, name: String, id: Int, variance: KmVariance): KmTypeParameterVisitor = - KmTypeParameter(flags, name, id, variance).addTo(typeParameters) - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitReceiverParameterType(flags: Int): KmTypeVisitor = - KmType(flags).also { receiverParameterType = it } - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - @ExperimentalContextReceivers - override fun visitContextReceiverType(flags: Int): KmTypeVisitor = - KmType(flags).addTo(contextReceiverTypes) - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitSetterParameter(flags: Int, name: String): KmValueParameterVisitor = - KmValueParameter(flags, name).also { setterParameter = it } - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitReturnType(flags: Int): KmTypeVisitor = - KmType(flags).also { returnType = it } - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitVersionRequirement(): KmVersionRequirementVisitor = - KmVersionRequirement().addTo(versionRequirements) - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitExtensions(type: KmExtensionType): KmPropertyExtensionVisitor = - extensions.singleOfType(type) - - /** - * Populates the given visitor with data in this property. - * - * @param visitor the visitor which will visit data in this property - */ - @OptIn(ExperimentalContextReceivers::class) - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - public fun accept(visitor: KmPropertyVisitor) { - typeParameters.forEach { visitor.visitTypeParameter(it.flags, it.name, it.id, it.variance)?.let(it::accept) } - receiverParameterType?.let { visitor.visitReceiverParameterType(it.flags)?.let(it::accept) } - contextReceiverTypes.forEach { visitor.visitContextReceiverType(it.flags)?.let(it::accept) } - setterParameter?.let { visitor.visitSetterParameter(it.flags, it.name)?.let(it::accept) } - visitor.visitReturnType(returnType.flags)?.let(returnType::accept) - versionRequirements.forEach { visitor.visitVersionRequirement()?.let(it::accept) } - extensions.forEach { visitor.visitExtensions(it.type)?.let(it::accept) } - visitor.visitEnd() - } } /** @@ -660,11 +339,10 @@ public class KmProperty @Deprecated(flagsCtorDeprecated, level = DeprecationLeve * * @property name the name of the type alias */ -@Suppress("DEPRECATION", "DEPRECATION_ERROR") -public class KmTypeAlias @Deprecated(flagsCtorDeprecated, level = DeprecationLevel.ERROR) constructor( - @Deprecated("$flagAccessPrefix KmTypeAlias, such as KmTypeAlias.visibility", level = DeprecationLevel.ERROR) public var flags: Int, +public class KmTypeAlias internal constructor( + internal var flags: Int, public var name: String, -) : KmTypeAliasVisitor() { +) { public constructor(name: String) : this(0, name) @@ -696,47 +374,6 @@ public class KmTypeAlias @Deprecated(flagsCtorDeprecated, level = DeprecationLev internal val extensions: List = MetadataExtensions.INSTANCES.mapNotNull(MetadataExtensions::createTypeAliasExtension) - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitTypeParameter(flags: Int, name: String, id: Int, variance: KmVariance): KmTypeParameterVisitor = - KmTypeParameter(flags, name, id, variance).addTo(typeParameters) - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitUnderlyingType(flags: Int): KmTypeVisitor = - KmType(flags).also { underlyingType = it } - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitExpandedType(flags: Int): KmTypeVisitor = - KmType(flags).also { expandedType = it } - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitAnnotation(annotation: KmAnnotation) { - annotations.add(annotation) - } - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitExtensions(type: KmExtensionType): KmTypeAliasExtensionVisitor? = - extensions.singleOfType(type) - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitVersionRequirement(): KmVersionRequirementVisitor = - KmVersionRequirement().addTo(versionRequirements) - - /** - * Populates the given visitor with data in this type alias. - * - * @param visitor the visitor which will visit data in this type alias - */ - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - public fun accept(visitor: KmTypeAliasVisitor) { - typeParameters.forEach { visitor.visitTypeParameter(it.flags, it.name, it.id, it.variance)?.let(it::accept) } - visitor.visitUnderlyingType(underlyingType.flags)?.let(underlyingType::accept) - visitor.visitExpandedType(expandedType.flags)?.let(expandedType::accept) - annotations.forEach(visitor::visitAnnotation) - versionRequirements.forEach { visitor.visitVersionRequirement()?.let(it::accept) } - extensions.forEach { visitor.visitExtensions(it.type)?.let(it::accept) } - visitor.visitEnd() - } } /** @@ -747,14 +384,10 @@ public class KmTypeAlias @Deprecated(flagsCtorDeprecated, level = DeprecationLev * * @property name the name of the value parameter */ -@Suppress("DEPRECATION", "DEPRECATION_ERROR") -public class KmValueParameter @Deprecated(flagsCtorDeprecated, level = DeprecationLevel.ERROR) constructor( - @Deprecated( - "$flagAccessPrefix KmValueParameter, such as KmValueParameter.declaresDefaultValue", - level = DeprecationLevel.ERROR - ) public var flags: Int, +public class KmValueParameter internal constructor( + internal var flags: Int, public var name: String, -) : KmValueParameterVisitor() { +) { public constructor(name: String) : this(0, name) @@ -771,31 +404,6 @@ public class KmValueParameter @Deprecated(flagsCtorDeprecated, level = Deprecati internal val extensions: List = MetadataExtensions.INSTANCES.mapNotNull(MetadataExtensions::createValueParameterExtension) - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitType(flags: Int): KmTypeVisitor = - KmType(flags).also { type = it } - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitVarargElementType(flags: Int): KmTypeVisitor = - KmType(flags).also { varargElementType = it } - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitExtensions(type: KmExtensionType): KmValueParameterExtensionVisitor? = - extensions.singleOfType(type) - - /** - * Populates the given visitor with data in this value parameter. - * - * @param visitor the visitor which will visit data in this value parameter - */ - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - public fun accept(visitor: KmValueParameterVisitor) { - visitor.visitType(type.flags)?.let(type::accept) - varargElementType?.let { visitor.visitVarargElementType(it.flags)?.let(it::accept) } - extensions.forEach { visitor.visitExtensions(it.type)?.let(it::accept) } - visitor.visitEnd() - } } /** @@ -809,16 +417,12 @@ public class KmValueParameter @Deprecated(flagsCtorDeprecated, level = Deprecati * the name is not enough (e.g. `class A { fun foo(t: T) }`) * @property variance the declaration-site variance of the type parameter */ -@Suppress("DEPRECATION", "DEPRECATION_ERROR") -public class KmTypeParameter @Deprecated(flagsCtorDeprecated, level = DeprecationLevel.ERROR) constructor( - @Deprecated( - "$flagAccessPrefix KmTypeParameter, such as KmTypeParameter.isReified", - level = DeprecationLevel.ERROR - ) public var flags: Int, +public class KmTypeParameter internal constructor( + internal var flags: Int, public var name: String, public var id: Int, public var variance: KmVariance, -) : KmTypeParameterVisitor() { +) { public constructor(name: String, id: Int, variance: KmVariance) : this(0, name, id, variance) @@ -829,26 +433,6 @@ public class KmTypeParameter @Deprecated(flagsCtorDeprecated, level = Deprecatio internal val extensions: List = MetadataExtensions.INSTANCES.map(MetadataExtensions::createTypeParameterExtension) - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitUpperBound(flags: Int): KmTypeVisitor = - KmType(flags).addTo(upperBounds) - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitExtensions(type: KmExtensionType): KmTypeParameterExtensionVisitor = - extensions.singleOfType(type) - - /** - * Populates the given visitor with data in this type parameter. - * - * @param visitor the visitor which will visit data in this type parameter - */ - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - public fun accept(visitor: KmTypeParameterVisitor) { - upperBounds.forEach { visitor.visitUpperBound(it.flags)?.let(it::accept) } - extensions.forEach { visitor.visitExtensions(it.type)?.let(it::accept) } - visitor.visitEnd() - } } /** @@ -857,10 +441,9 @@ public class KmTypeParameter @Deprecated(flagsCtorDeprecated, level = Deprecatio * Various type attributes can be read and manipulated via extension properties, * such as [KmType.isNullable]. */ -@Suppress("DEPRECATION", "DEPRECATION_ERROR") -public class KmType @Deprecated(flagsCtorDeprecated, level = DeprecationLevel.ERROR) constructor( - @Deprecated("$flagAccessPrefix KmType, such as KmType.isNullable", level = DeprecationLevel.ERROR) public var flags: Int, -) : KmTypeVisitor() { +public class KmType internal constructor( + internal var flags: Int, +) { public constructor() : this(0) @@ -906,75 +489,6 @@ public class KmType @Deprecated(flagsCtorDeprecated, level = DeprecationLevel.ER internal val extensions: List = MetadataExtensions.INSTANCES.map(MetadataExtensions::createTypeExtension) - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitClass(name: ClassName) { - classifier = KmClassifier.Class(name) - } - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitTypeAlias(name: ClassName) { - classifier = KmClassifier.TypeAlias(name) - } - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitTypeParameter(id: Int) { - classifier = KmClassifier.TypeParameter(id) - } - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitArgument(flags: Int, variance: KmVariance): KmTypeVisitor = - KmType(flags).also { arguments.add(KmTypeProjection(variance, it)) } - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitStarProjection() { - arguments.add(KmTypeProjection.STAR) - } - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitAbbreviatedType(flags: Int): KmTypeVisitor = - KmType(flags).also { abbreviatedType = it } - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitOuterType(flags: Int): KmTypeVisitor = - KmType(flags).also { outerType = it } - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitFlexibleTypeUpperBound(flags: Int, typeFlexibilityId: String?): KmTypeVisitor = - KmType(flags).also { flexibleTypeUpperBound = KmFlexibleTypeUpperBound(it, typeFlexibilityId) } - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitExtensions(type: KmExtensionType): KmTypeExtensionVisitor = - extensions.singleOfType(type) - - /** - * Populates the given visitor with data in this type. - * - * @param visitor the visitor which will visit data in this type - * @throws IllegalArgumentException if type metadata is inconsistent - */ - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - public fun accept(visitor: KmTypeVisitor) { - when (val classifier = classifier) { - is KmClassifier.Class -> visitor.visitClass(classifier.name) - is KmClassifier.TypeParameter -> visitor.visitTypeParameter(classifier.id) - is KmClassifier.TypeAlias -> visitor.visitTypeAlias(classifier.name) - } - arguments.forEach { argument -> - if (argument == KmTypeProjection.STAR) visitor.visitStarProjection() - else { - val (variance, type) = argument - if (variance == null || type == null) - throw InconsistentKotlinMetadataException("Variance and type must be set for non-star type projection") - visitor.visitArgument(type.flags, variance)?.let(type::accept) - } - } - abbreviatedType?.let { visitor.visitAbbreviatedType(it.flags)?.let(it::accept) } - outerType?.let { visitor.visitOuterType(it.flags)?.let(it::accept) } - flexibleTypeUpperBound?.let { visitor.visitFlexibleTypeUpperBound(it.type.flags, it.typeFlexibilityId)?.let(it.type::accept) } - extensions.forEach { visitor.visitExtensions(it.type)?.let(it::accept) } - visitor.visitEnd() - } } /** @@ -983,8 +497,7 @@ public class KmType @Deprecated(flagsCtorDeprecated, level = DeprecationLevel.ER * Version requirement is an internal feature of the Kotlin compiler and the standard Kotlin library, * enabled, for example, with the internal [kotlin.internal.RequireKotlin] annotation. */ -@Suppress("DEPRECATION", "DEPRECATION_ERROR") -public class KmVersionRequirement : KmVersionRequirementVisitor() { +public class KmVersionRequirement { /** * Kind of the version that this declaration requires. */ @@ -1010,31 +523,6 @@ public class KmVersionRequirement : KmVersionRequirementVisitor() { */ public lateinit var version: KmVersion - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visit(kind: KmVersionRequirementVersionKind, level: KmVersionRequirementLevel, errorCode: Int?, message: String?) { - this.kind = kind - this.level = level - this.errorCode = errorCode - this.message = message - } - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitVersion(major: Int, minor: Int, patch: Int) { - this.version = KmVersion(major, minor, patch) - } - - /** - * Populates the given visitor with data in this version requirement. - * - * @param visitor the visitor which will visit data in this version requirement - */ - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - public fun accept(visitor: KmVersionRequirementVisitor) { - visitor.visit(kind, level, errorCode, message) - visitor.visitVersion(version.major, version.minor, version.patch) - visitor.visitEnd() - } - /** * Returns the String representation of this KmVersionRequirement object, consisting of * [kind], [level], [version], [errorCode], and [message]. @@ -1044,169 +532,6 @@ public class KmVersionRequirement : KmVersionRequirementVisitor() { } } -/** - * Represents a contract of a Kotlin function. - * - * Contracts are an internal feature of the standard Kotlin library, and their behavior and/or binary format - * may change in a subsequent release. - */ -@ExperimentalContracts -@Suppress("DEPRECATION", "DEPRECATION_ERROR") -public class KmContract : KmContractVisitor() { - /** - * Effects of this contract. - */ - public val effects: MutableList = ArrayList(1) - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitEffect(type: KmEffectType, invocationKind: KmEffectInvocationKind?): KmEffectVisitor = - KmEffect(type, invocationKind).addTo(effects) - - /** - * Populates the given visitor with data in this contract. - * - * @param visitor the visitor which will visit data in this contract - */ - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - public fun accept(visitor: KmContractVisitor) { - effects.forEach { visitor.visitEffect(it.type, it.invocationKind)?.let(it::accept) } - visitor.visitEnd() - } -} - -/** - * Represents an effect (a part of the contract of a Kotlin function). - * - * Contracts are an internal feature of the standard Kotlin library, and their behavior and/or binary format - * may change in a subsequent release. - * - * @property type type of the effect - * @property invocationKind optional number of invocations of the lambda parameter of this function, - * specified further in the effect expression - */ -@ExperimentalContracts -@Suppress("DEPRECATION", "DEPRECATION_ERROR") -public class KmEffect( - public var type: KmEffectType, - public var invocationKind: KmEffectInvocationKind? -) : KmEffectVisitor() { - /** - * Arguments of the effect constructor, i.e. the constant value for the [KmEffectType.RETURNS_CONSTANT] effect, - * or the parameter reference for the [KmEffectType.CALLS] effect. - */ - public val constructorArguments: MutableList = ArrayList(1) - - /** - * Conclusion of the effect. If this value is set, the effect represents an implication with this value as the right-hand side. - */ - public var conclusion: KmEffectExpression? = null - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitConstructorArgument(): KmEffectExpressionVisitor = - KmEffectExpression().addTo(constructorArguments) - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitConclusionOfConditionalEffect(): KmEffectExpressionVisitor = - KmEffectExpression().also { conclusion = it } - - /** - * Populates the given visitor with data in this effect. - * - * @param visitor the visitor which will visit data in this effect - */ - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - public fun accept(visitor: KmEffectVisitor) { - constructorArguments.forEach { visitor.visitConstructorArgument()?.let(it::accept) } - conclusion?.let { visitor.visitConclusionOfConditionalEffect()?.let(it::accept) } - visitor.visitEnd() - } -} - -/** - * Represents an effect expression, the contents of an effect (a part of the contract of a Kotlin function). - * - * Contracts are an internal feature of the standard Kotlin library, and their behavior and/or binary format - * may change in a subsequent release. - * - * Various effect expression attributes can be read and manipulated via extension properties, - * such as [KmEffectExpression.isNegated]. - */ -@ExperimentalContracts -@Suppress("DEPRECATION", "DEPRECATION_ERROR") -public class KmEffectExpression : KmEffectExpressionVisitor() { - /** - * Effect expression flags, consisting of [Flag.EffectExpression] flags. - */ - @Deprecated("$flagAccessPrefix KmEffectExpression, such as KmEffectExpression.isNegated", level = DeprecationLevel.ERROR) - public var flags: Int = flagsOf() - - /** - * Optional 1-based index of the value parameter of the function, for effects which assert something about - * the function parameters. Index 0 means the extension receiver parameter. - */ - public var parameterIndex: Int? = null - - /** - * Constant value used in the effect expression. - */ - public var constantValue: KmConstantValue? = null - - /** - * Type used as the target of an `is`-expression in the effect expression. - */ - public var isInstanceType: KmType? = null - - /** - * Arguments of an `&&`-expression. If this list is non-empty, the resulting effect expression is a conjunction of this expression - * and elements of the list. - */ - public val andArguments: MutableList = ArrayList(0) - - /** - * Arguments of an `||`-expression. If this list is non-empty, the resulting effect expression is a disjunction of this expression - * and elements of the list. - */ - public val orArguments: MutableList = ArrayList(0) - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visit(flags: Int, parameterIndex: Int?) { - this.flags = flags - this.parameterIndex = parameterIndex - } - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitConstantValue(value: Any?) { - constantValue = KmConstantValue(value) - } - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitIsInstanceType(flags: Int): KmTypeVisitor = - KmType(flags).also { isInstanceType = it } - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitAndArgument(): KmEffectExpressionVisitor = - KmEffectExpression().addTo(andArguments) - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitOrArgument(): KmEffectExpressionVisitor = - KmEffectExpression().addTo(orArguments) - - /** - * Populates the given visitor with data in this effect expression. - * - * @param visitor the visitor which will visit data in this effect expression - */ - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - public fun accept(visitor: KmEffectExpressionVisitor) { - visitor.visit(flags, parameterIndex) - constantValue?.let { visitor.visitConstantValue(it.value) } - isInstanceType?.let { visitor.visitIsInstanceType(it.flags)?.let(it::accept) } - andArguments.forEach { visitor.visitAndArgument()?.let(it::accept) } - orArguments.forEach { visitor.visitOrArgument()?.let(it::accept) } - visitor.visitEnd() - } -} - /** * Represents a classifier of a Kotlin type. A classifier is a class, type parameter, or type alias. * For example, in `MutableMap`, `MutableMap` is the classifier. @@ -1265,6 +590,27 @@ public data class KmTypeProjection(var variance: KmVariance?, var type: KmType?) */ public data class KmFlexibleTypeUpperBound(var type: KmType, var typeFlexibilityId: String?) +/** + * Variance applied to a type parameter on the declaration site (*declaration-site variance*), + * or to a type in a projection (*use-site variance*). + */ +public enum class KmVariance { + /** + * The affected type parameter or type is *invariant*, which means it has no variance applied to it. + */ + INVARIANT, + + /** + * The affected type parameter or type is *contravariant*. Denoted by the `in` modifier in the source code. + */ + IN, + + /** + * The affected type parameter or type is *covariant*. Denoted by the `out` modifier in the source code. + */ + OUT, +} + /** * Represents a version used in a version requirement. * @@ -1281,22 +627,57 @@ public data class KmVersion(val major: Int, val minor: Int, val patch: Int) { } /** - * Represents a constant value used in an effect expression. - * - * Contracts are an internal feature of the standard Kotlin library, and their behavior and/or binary format - * may change in a subsequent release. - * - * @property value the constant value. May be `true`, `false` or `null` + * Severity of the diagnostic reported by the compiler when a version requirement is not satisfied. */ -@ExperimentalContracts -public data class KmConstantValue(val value: Any?) +public enum class KmVersionRequirementLevel { + /** + * Represents a diagnostic with 'WARNING' severity. + */ + WARNING, -internal fun T.addTo(collection: MutableCollection): T { - collection.add(this) - return this + /** + * Represents a diagnostic with 'ERROR' severity. + */ + ERROR, + + /** + * Excludes the declaration from the resolution process completely when the version requirement is not satisfied. + */ + HIDDEN, } -private const val flagsCtorDeprecated = - "Constructor with flags is deprecated, use constructor without flags and assign them or corresponding extension properties directly." +/** + * The kind of the version that is required by a version requirement. + */ +public enum class KmVersionRequirementVersionKind { + /** + * Indicates that certain language version is required. + */ + LANGUAGE_VERSION, -private const val flagAccessPrefix = "Flag API is deprecated. Please use corresponding member extensions on" + /** + * Indicates that certain compiler version is required. + */ + COMPILER_VERSION, + + /** + * Indicates that certain API version is required. + */ + API_VERSION, + + /** + * Represents a version requirement not successfully parsed from the metadata. + * + * The old metadata format (from Kotlin 1.3 and earlier) did not have enough information for correct parsing of version requirements in some cases, + * so a stub of this kind is inserted instead. + * + * [KmVersionRequirement] with this kind always has [KmVersionRequirementLevel.HIDDEN] level, `256.256.256` [KmVersionRequirement.version], + * and `null` [KmVersionRequirement.errorCode] and [KmVersionRequirement.message]. + * + * Version requirements of this kind are being ignored by writers (i.e., are not written back). + * + * See the following issues for details: [KT-60870](https://youtrack.jetbrains.com/issue/KT-60870), [KT-25120](https://youtrack.jetbrains.com/issue/KT-25120) + */ + UNKNOWN + ; +} diff --git a/libraries/kotlinx-metadata/src/kotlin/metadata/Visitors.kt b/libraries/kotlinx-metadata/src/kotlin/metadata/Visitors.kt deleted file mode 100644 index 1c0e5ea9b6c..00000000000 --- a/libraries/kotlinx-metadata/src/kotlin/metadata/Visitors.kt +++ /dev/null @@ -1,1002 +0,0 @@ -/* - * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -package kotlin.metadata - -import kotlin.contracts.ExperimentalContracts - -internal const val VISITOR_API_MESSAGE = - "Visitor API is deprecated as excessive and cumbersome. Please use nodes (such as KmClass) and their properties." - -/** - * A visitor containing the common code to visit Kotlin declaration containers, such as classes and package fragments. - */ -@Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) -@Suppress("DEPRECATION_ERROR") -public abstract class KmDeclarationContainerVisitor @JvmOverloads constructor(protected open val delegate: KmDeclarationContainerVisitor? = null) { - /** - * Visits a function in the container. - * - * @param flags function flags, consisting of [Flag.HAS_ANNOTATIONS], visibility flag, modality flag and [Flag.Function] flags - * @param name the name of the function - */ - public open fun visitFunction(flags: Int, name: String): KmFunctionVisitor? = - delegate?.visitFunction(flags, name) - - /** - * Visits a property in the container. - * - * @param flags property flags, consisting of [Flag.HAS_ANNOTATIONS], visibility flag, modality flag and [Flag.Property] flags - * @param name the name of the property - * @param getterFlags property accessor flags, consisting of [Flag.HAS_ANNOTATIONS], visibility flag, modality flag - * and [Flag.PropertyAccessor] flags - * @param setterFlags property accessor flags, consisting of [Flag.HAS_ANNOTATIONS], visibility flag, modality flag - * and [Flag.PropertyAccessor] flags - */ - public open fun visitProperty(flags: Int, name: String, getterFlags: Int, setterFlags: Int): KmPropertyVisitor? = - delegate?.visitProperty(flags, name, getterFlags, setterFlags) - - /** - * Visits a type alias in the container. - * - * @param flags type alias flags, consisting of [Flag.HAS_ANNOTATIONS] and visibility flag - * @param name the name of the type alias - */ - public open fun visitTypeAlias(flags: Int, name: String): KmTypeAliasVisitor? = - delegate?.visitTypeAlias(flags, name) - - /** - * Visits the extensions of the given type on the container. - * - * @param type the type of extension visitor to be returned - */ - public open fun visitExtensions(type: KmExtensionType): KmDeclarationContainerExtensionVisitor? = delegate?.visitExtensions(type) -} - -/** - * A visitor to visit Kotlin classes, including interfaces, objects, enum classes and annotation classes. - * - * When using this class, [visit] must be called first, followed by zero or more [visitTypeParameter] calls, followed by zero or more calls - * to other visit* methods, followed by [visitEnd]. - */ -@Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) -@Suppress("DEPRECATION_ERROR") -public abstract class KmClassVisitor @JvmOverloads constructor(delegate: KmClassVisitor? = null) : KmDeclarationContainerVisitor(delegate) { - override val delegate: KmClassVisitor? - get() = super.delegate as KmClassVisitor? - - /** - * Visits the basic information about the class. - * - * @param flags class flags, consisting of [Flag.HAS_ANNOTATIONS], visibility flag, modality flag and [Flag.Class] flags - * @param name the name of the class - */ - public open fun visit(flags: Int, name: ClassName) { - delegate?.visit(flags, name) - } - - /** - * Visits a type parameter of the class. - * - * @param flags type parameter flags, consisting of [Flag.TypeParameter] flags - * @param name the name of the type parameter - * @param id the id of the type parameter, useful to be able to uniquely identify the type parameter in different contexts where - * the name isn't enough (e.g. `class A { fun foo(t: T) }`) - * @param variance the declaration-site variance of the type parameter - */ - public open fun visitTypeParameter(flags: Int, name: String, id: Int, variance: KmVariance): KmTypeParameterVisitor? = - delegate?.visitTypeParameter(flags, name, id, variance) - - /** - * Visits a supertype of the class. - * - * @param flags type flags, consisting of [Flag.Type] flags - */ - public open fun visitSupertype(flags: Int): KmTypeVisitor? = - delegate?.visitSupertype(flags) - - /** - * Visits a constructor of the class. - * - * @param flags constructor flags, consisting of [Flag.HAS_ANNOTATIONS], visibility flag and [Flag.Constructor] flags - */ - public open fun visitConstructor(flags: Int): KmConstructorVisitor? = - delegate?.visitConstructor(flags) - - /** - * Visits the name of the companion object of this class, if it has one. - * - * @param name the name of the companion object - */ - public open fun visitCompanionObject(name: String) { - delegate?.visitCompanionObject(name) - } - - /** - * Visits the name of a nested class of this class. - * - * @param name the name of a nested class - */ - public open fun visitNestedClass(name: String) { - delegate?.visitNestedClass(name) - } - - /** - * Visits the name of an enum entry, if this class is an enum class. - * - * @param name the name of an enum entry - */ - public open fun visitEnumEntry(name: String) { - delegate?.visitEnumEntry(name) - } - - /** - * Visits the name of a direct subclass of this class, if this class is `sealed`. - * - * @param name the name of a direct subclass - */ - public open fun visitSealedSubclass(name: ClassName) { - delegate?.visitSealedSubclass(name) - } - - /** - * Visits the name of the underlying property, if this class is `inline`. - * - * @param name the name of the underlying property. - */ - public open fun visitInlineClassUnderlyingPropertyName(name: String) { - delegate?.visitInlineClassUnderlyingPropertyName(name) - } - - /** - * Visits the type of the underlying property, if this class is `inline`. - * - * @param flags type flags, consisting of [Flag.Type] flags - */ - public open fun visitInlineClassUnderlyingType(flags: Int): KmTypeVisitor? = - delegate?.visitInlineClassUnderlyingType(flags) - - /** - * Visits the type of a context receiver of the class. - * - * @param flags type flags, consisting of [Flag.Type] flags - */ - @ExperimentalContextReceivers - public open fun visitContextReceiverType(flags: Int): KmTypeVisitor? = - delegate?.visitContextReceiverType(flags) - - /** - * Visits the version requirement on this class. - */ - public open fun visitVersionRequirement(): KmVersionRequirementVisitor? = - delegate?.visitVersionRequirement() - - /** - * Visits the extensions of the given type on the class. - * - * @param type the type of extension visitor to be returned - */ - override fun visitExtensions(type: KmExtensionType): KmClassExtensionVisitor? = - delegate?.visitExtensions(type) - - /** - * Visits the end of the class. - */ - public open fun visitEnd() { - delegate?.visitEnd() - } -} - -/** - * A visitor to visit Kotlin package fragments, including single file facades and multi-file class parts. - * - * When using this class, [visitEnd] must be called exactly once and after calls to all other visit* methods. - */ -@Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) -@Suppress("DEPRECATION_ERROR") -public abstract class KmPackageVisitor @JvmOverloads constructor(delegate: KmPackageVisitor? = null) : - KmDeclarationContainerVisitor(delegate) { - override val delegate: KmPackageVisitor? - get() = super.delegate as KmPackageVisitor? - - /** - * Visits the extensions of the given type on the package fragment. - * - * @param type the type of extension visitor to be returned - */ - override fun visitExtensions(type: KmExtensionType): KmPackageExtensionVisitor? = - delegate?.visitExtensions(type) - - /** - * Visits the end of the package fragment. - */ - public open fun visitEnd() { - delegate?.visitEnd() - } -} - -/** - * A visitor to visit the metadata of a synthetic class generated for a Kotlin lambda. - * - * When using this class, [visitFunction] must be called first, followed by [visitEnd]. - */ -@Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) -@Suppress("DEPRECATION_ERROR") -public abstract class KmLambdaVisitor @JvmOverloads constructor(private val delegate: KmLambdaVisitor? = null) { - /** - * Visits the signature of a synthetic anonymous function, representing the lambda. - * - * @param flags function flags, consisting of [Flag.HAS_ANNOTATIONS], visibility flag, modality flag and [Flag.Function] flags - * @param name the name of the function (usually `""` or `""` for lambdas emitted by the Kotlin compiler) - */ - public open fun visitFunction(flags: Int, name: String): KmFunctionVisitor? = - delegate?.visitFunction(flags, name) - - /** - * Visits the end of the lambda. - */ - public open fun visitEnd() { - delegate?.visitEnd() - } -} - -/** - * A visitor to visit a constructor of a Kotlin class. - * - * When using this class, [visitEnd] must be called exactly once and after calls to all other visit* methods. - */ -@Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) -@Suppress("DEPRECATION_ERROR") -public abstract class KmConstructorVisitor @JvmOverloads constructor(private val delegate: KmConstructorVisitor? = null) { - /** - * Visits a value parameter of the constructor. - * - * @param flags value parameter flags, consisting of [Flag.ValueParameter] flags - * @param name the name of the value parameter - */ - public open fun visitValueParameter(flags: Int, name: String): KmValueParameterVisitor? = - delegate?.visitValueParameter(flags, name) - - /** - * Visits the version requirement on this constructor. - */ - public open fun visitVersionRequirement(): KmVersionRequirementVisitor? = - delegate?.visitVersionRequirement() - - /** - * Visits the extensions of the given type on the constructor. - * - * @param type the type of extension visitor to be returned - */ - public open fun visitExtensions(type: KmExtensionType): KmConstructorExtensionVisitor? = - delegate?.visitExtensions(type) - - /** - * Visits the end of the constructor. - */ - public open fun visitEnd() { - delegate?.visitEnd() - } -} - -/** - * A visitor to visit a Kotlin function declaration. - * - * When using this class, zero or more calls to [visitTypeParameter] must be done first, followed by zero or more calls - * to other visit* methods, followed by [visitEnd]. - */ -@Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) -@Suppress("DEPRECATION_ERROR") -public abstract class KmFunctionVisitor @JvmOverloads constructor(private val delegate: KmFunctionVisitor? = null) { - /** - * Visits a type parameter of the function. - * - * @param flags type parameter flags, consisting of [Flag.TypeParameter] flags - * @param name the name of the type parameter - * @param id the id of the type parameter, useful to be able to uniquely identify the type parameter in different contexts where - * the name isn't enough (e.g. `class A { fun foo(t: T) }`) - * @param variance the declaration-site variance of the type parameter - */ - public open fun visitTypeParameter(flags: Int, name: String, id: Int, variance: KmVariance): KmTypeParameterVisitor? = - delegate?.visitTypeParameter(flags, name, id, variance) - - /** - * Visits the type of the receiver of the function if this is an extension function. - * - * @param flags type flags, consisting of [Flag.Type] flags - */ - public open fun visitReceiverParameterType(flags: Int): KmTypeVisitor? = - delegate?.visitReceiverParameterType(flags) - - /** - * Visits the type of the context receiver of the function. - * - * @param flags type flags, consisting of [Flag.Type] flags - */ - @ExperimentalContextReceivers - public open fun visitContextReceiverType(flags: Int): KmTypeVisitor? = - delegate?.visitContextReceiverType(flags) - - /** - * Visits a value parameter of the function. - * - * @param flags value parameter flags, consisting of [Flag.ValueParameter] flags - * @param name the name of the value parameter - */ - public open fun visitValueParameter(flags: Int, name: String): KmValueParameterVisitor? = - delegate?.visitValueParameter(flags, name) - - /** - * Visits the return type of the function. - * - * @param flags type flags, consisting of [Flag.Type] flags - */ - public open fun visitReturnType(flags: Int): KmTypeVisitor? = - delegate?.visitReturnType(flags) - - /** - * Visits the version requirement on this function. - */ - public open fun visitVersionRequirement(): KmVersionRequirementVisitor? = - delegate?.visitVersionRequirement() - - /** - * Visits the contract of the function. - */ - @ExperimentalContracts - public open fun visitContract(): KmContractVisitor? = - delegate?.visitContract() - - /** - * Visits the extensions of the given type on the function. - * - * @param type the type of extension visitor to be returned - */ - public open fun visitExtensions(type: KmExtensionType): KmFunctionExtensionVisitor? = - delegate?.visitExtensions(type) - - /** - * Visits the end of the function. - */ - public open fun visitEnd() { - delegate?.visitEnd() - } -} - -/** - * A visitor to visit a Kotlin property declaration. - * - * When using this class, zero or more calls to [visitTypeParameter] must be done first, followed by zero or more calls - * to other visit* methods, followed by [visitEnd]. - */ -@Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) -@Suppress("DEPRECATION_ERROR") -public abstract class KmPropertyVisitor @JvmOverloads constructor(private val delegate: KmPropertyVisitor? = null) { - /** - * Visits a type parameter of the property. - * - * @param flags type parameter flags, consisting of [Flag.TypeParameter] flags - * @param name the name of the type parameter - * @param id the id of the type parameter, useful to be able to uniquely identify the type parameter in different contexts where - * the name isn't enough (e.g. `class A { fun foo(t: T) }`) - * @param variance the declaration-site variance of the type parameter - */ - public open fun visitTypeParameter(flags: Int, name: String, id: Int, variance: KmVariance): KmTypeParameterVisitor? = - delegate?.visitTypeParameter(flags, name, id, variance) - - /** - * Visits the type of the receiver of the property if this is an extension property. - * - * @param flags type flags, consisting of [Flag.Type] flags - */ - public open fun visitReceiverParameterType(flags: Int): KmTypeVisitor? = - delegate?.visitReceiverParameterType(flags) - - /** - * Visits the type of a context receiver of the property. - * - * @param flags type flags, consisting of [Flag.Type] flags - */ - @ExperimentalContextReceivers - public open fun visitContextReceiverType(flags: Int): KmTypeVisitor? = - delegate?.visitContextReceiverType(flags) - - /** - * Visits a value parameter of the setter of this property, if this is a `var` property. - * - * @param flags value parameter flags, consisting of [Flag.ValueParameter] flags - * @param name the name of the value parameter (`""` for properties emitted by the Kotlin compiler) - */ - public open fun visitSetterParameter(flags: Int, name: String): KmValueParameterVisitor? = - delegate?.visitSetterParameter(flags, name) - - /** - * Visits the type of the property. - * - * @param flags type flags, consisting of [Flag.Type] flags - */ - public open fun visitReturnType(flags: Int): KmTypeVisitor? = - delegate?.visitReturnType(flags) - - /** - * Visits the version requirement on this property. - */ - public open fun visitVersionRequirement(): KmVersionRequirementVisitor? = - delegate?.visitVersionRequirement() - - /** - * Visits the extensions of the given type on the property. - * - * @param type the type of extension visitor to be returned - */ - public open fun visitExtensions(type: KmExtensionType): KmPropertyExtensionVisitor? = - delegate?.visitExtensions(type) - - /** - * Visits the end of the property. - */ - public open fun visitEnd() { - delegate?.visitEnd() - } -} - -/** - * A visitor to visit a Kotlin type alias declaration. - * - * When using this class, zero or more calls to [visitTypeParameter] must be done first, followed by zero or more calls - * to other visit* methods, followed by [visitEnd]. - */ -@Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) -@Suppress("DEPRECATION_ERROR") -public abstract class KmTypeAliasVisitor @JvmOverloads constructor(private val delegate: KmTypeAliasVisitor? = null) { - /** - * Visits a type parameter of the type alias. - * - * @param flags type parameter flags, consisting of [Flag.TypeParameter] flags - * @param name the name of the type parameter - * @param id the id of the type parameter, useful to be able to uniquely identify the type parameter in different contexts where - * the name isn't enough (e.g. `class A { fun foo(t: T) }`) - * @param variance the declaration-site variance of the type parameter - */ - public open fun visitTypeParameter(flags: Int, name: String, id: Int, variance: KmVariance): KmTypeParameterVisitor? = - delegate?.visitTypeParameter(flags, name, id, variance) - - /** - * Visits the underlying type of the type alias, i.e. the type in the right-hand side of the type alias declaration. - * - * @param flags type flags, consisting of [Flag.Type] flags - */ - public open fun visitUnderlyingType(flags: Int): KmTypeVisitor? = - delegate?.visitUnderlyingType(flags) - - /** - * Visits the expanded type of the type alias, i.e. the full expansion of the underlying type, where all type aliases are substituted - * with their expanded types. If no type aliases are used in the underlying type, expanded type is equal to the underlying type. - * - * @param flags type flags, consisting of [Flag.Type] flags - */ - public open fun visitExpandedType(flags: Int): KmTypeVisitor? = - delegate?.visitExpandedType(flags) - - /** - * Visits the annotation on the type alias. - * - * @param annotation annotation on the type alias - */ - public open fun visitAnnotation(annotation: KmAnnotation) { - delegate?.visitAnnotation(annotation) - } - - /** - * Visits the version requirement on this type alias. - */ - public open fun visitVersionRequirement(): KmVersionRequirementVisitor? = - delegate?.visitVersionRequirement() - - /** - * Visits the extensions of the given type on the type alias. - * - * @param type the type of extension visitor to be returned - */ - public open fun visitExtensions(type: KmExtensionType): KmTypeAliasExtensionVisitor? = - delegate?.visitExtensions(type) - - /** - * Visits the end of the type alias. - */ - public open fun visitEnd() { - delegate?.visitEnd() - } -} - -/** - * A visitor to visit a value parameter of a Kotlin constructor, function or property setter. - * - * When using this class, either [visitType] or [visitVarargElementType] must be called first (depending on whether the value parameter - * is `vararg` or not), followed by [visitEnd]. - */ -@Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) -@Suppress("DEPRECATION_ERROR") -public abstract class KmValueParameterVisitor @JvmOverloads constructor(private val delegate: KmValueParameterVisitor? = null) { - /** - * Visits the type of the value parameter, if this is **not** a `vararg` parameter. - * - * @param flags type flags, consisting of [Flag.Type] flags - */ - public open fun visitType(flags: Int): KmTypeVisitor? = - delegate?.visitType(flags) - - /** - * Visits the type of the value parameter, if this is a `vararg` parameter. - * - * @param flags type flags, consisting of [Flag.Type] flags - */ - public open fun visitVarargElementType(flags: Int): KmTypeVisitor? = - delegate?.visitVarargElementType(flags) - - /** - * Visits the extensions of the given type on the value parameter. - * - * @param type the type of extension visitor to be returned - */ - public open fun visitExtensions(type: KmExtensionType): KmValueParameterExtensionVisitor? = - delegate?.visitExtensions(type) - - /** - * Visits the end of the value parameter. - */ - public open fun visitEnd() { - delegate?.visitEnd() - } -} - -/** - * A visitor to visit a type parameter of a Kotlin class, function, property or type alias. - * - * When using this class, zero or more [visitUpperBound] calls must be done first, followed by [visitEnd]. - */ -@Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) -@Suppress("DEPRECATION_ERROR") -public abstract class KmTypeParameterVisitor @JvmOverloads constructor(private val delegate: KmTypeParameterVisitor? = null) { - /** - * Visits the upper bound of the type parameter. - * - * @param flags type flags, consisting of [Flag.Type] flags - */ - public open fun visitUpperBound(flags: Int): KmTypeVisitor? = - delegate?.visitUpperBound(flags) - - /** - * Visits the extensions of the given type on the type parameter. - * - * @param type the type of extension visitor to be returned - */ - public open fun visitExtensions(type: KmExtensionType): KmTypeParameterExtensionVisitor? = - delegate?.visitExtensions(type) - - /** - * Visits the end of the type parameter. - */ - public open fun visitEnd() { - delegate?.visitEnd() - } -} - -/** - * A visitor to visit a type. The type must have a classifier which is one of: a class [visitClass], type parameter [visitTypeParameter] - * or type alias [visitTypeAlias]. If the type's classifier is a class or a type alias, it can have type arguments ([visitArgument] and - * [visitStarProjection]). If the type's classifier is an inner class, it can have the outer type ([visitOuterType]), which captures - * the generic type arguments of the outer class. Also, each type can have an abbreviation ([visitAbbreviatedType]) in case a type alias - * was used originally at this site in the declaration (all types are expanded by default for metadata produced by the Kotlin compiler). - * If [visitFlexibleTypeUpperBound] is called, this type is regarded as a flexible type, and its contents represent the lower bound, - * and the result of the call represents the upper bound. - * - * When using this class, [visitEnd] must be called exactly once and after calls to all other visit* methods. - */ -@Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) -@Suppress("DEPRECATION_ERROR") -public abstract class KmTypeVisitor @JvmOverloads constructor(private val delegate: KmTypeVisitor? = null) { - /** - * Visits the name of the class, if this type's classifier is a class. - * - * @param name the name of the class - */ - public open fun visitClass(name: ClassName) { - delegate?.visitClass(name) - } - - /** - * Visits the name of the type alias, if this type's classifier is a type alias. Note that all types are expanded for metadata produced - * by the Kotlin compiler, so the type with a type alias classifier may only appear in a call to [visitAbbreviatedType]. - * - * @param name the name of the type alias - */ - public open fun visitTypeAlias(name: ClassName) { - delegate?.visitTypeAlias(name) - } - - /** - * Visits the id of the type parameter, if this type's classifier is a type parameter. - * - * @param id id of the type parameter - */ - public open fun visitTypeParameter(id: Int) { - delegate?.visitTypeParameter(id) - } - - /** - * Visits the type projection used in a type argument of the type based on a class or on a type alias. - * For example, in `MutableMap`, `in String?` is the type projection which is the first type argument of the type. - * - * @param flags type flags, consisting of [Flag.Type] flags - * @param variance the variance of the type projection - */ - public open fun visitArgument(flags: Int, variance: KmVariance): KmTypeVisitor? = - delegate?.visitArgument(flags, variance) - - /** - * Visits the star (`*`) projection used in a type argument of the type based on a class or on a type alias. - * For example, in `MutableMap`, `*` is the star projection which is the second type argument of the type. - */ - public open fun visitStarProjection() { - delegate?.visitStarProjection() - } - - /** - * Visits the abbreviation of this type. Note that all types are expanded for metadata produced by the Kotlin compiler. For example: - * - * typealias A = MutableList - * - * fun foo(a: A) {} - * - * The type of the `foo`'s parameter in the metadata is actually `MutableList`, and its abbreviation is `A`. - * - * @param flags type flags, consisting of [Flag.Type] flags - */ - public open fun visitAbbreviatedType(flags: Int): KmTypeVisitor? = - delegate?.visitAbbreviatedType(flags) - - /** - * Visits the outer type, if this type's classifier is an inner class. For example: - * - * class A { inner class B } - * - * fun foo(a: A<*>.B) {} - * - * The type of the `foo`'s parameter in the metadata is `B` (a type whose classifier is class `B`, and it has one type argument, - * type `Byte?`), and its outer type is `A<*>` (a type whose classifier is class `A`, and it has one type argument, star projection). - * - * @param flags type flags, consisting of [Flag.Type] flags - */ - public open fun visitOuterType(flags: Int): KmTypeVisitor? = - delegate?.visitOuterType(flags) - - /** - * Visits the upper bound of the type, marking it as flexible and its contents as the lower bound. Flexible types in Kotlin include - * platform types in Kotlin/JVM and `dynamic` type in Kotlin/JS. - * - * @param flags type flags, consisting of [Flag.Type] flags - * @param typeFlexibilityId id of the kind of flexibility this type has. For example, "kotlin.jvm.PlatformType" for JVM platform types, - * or "kotlin.DynamicType" for JS dynamic type - */ - public open fun visitFlexibleTypeUpperBound(flags: Int, typeFlexibilityId: String?): KmTypeVisitor? = - delegate?.visitFlexibleTypeUpperBound(flags, typeFlexibilityId) - - /** - * Visits the extensions of the given type on the type. - * - * @param type the type of extension visitor to be returned - */ - public open fun visitExtensions(type: KmExtensionType): KmTypeExtensionVisitor? = - delegate?.visitExtensions(type) - - /** - * Visits the end of the type. - */ - public open fun visitEnd() { - delegate?.visitEnd() - } -} - -/** - * A visitor to visit the contents of a version requirement on a Kotlin declaration. - * - * Version requirement is an internal feature of the Kotlin compiler and the standard Kotlin library, - * enabled for example with the internal [kotlin.internal.RequireKotlin] annotation. - * - * When using this class, [visit] must be called first, followed by [visitVersion], followed by [visitEnd]. - */ -@Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) -public abstract class KmVersionRequirementVisitor @JvmOverloads constructor(@Suppress("DEPRECATION_ERROR") private val delegate: KmVersionRequirementVisitor? = null) { - /** - * Visits the description of this version requirement. - * - * @param kind the kind of the version that this declaration requires: compiler, language or API version - * @param level the level of the diagnostic that must be reported on the usages of the declaration in case - * the version requirement is not satisfied - * @param errorCode optional error code to be displayed in the diagnostic - * @param message optional message to be displayed in the diagnostic - */ - public open fun visit(kind: KmVersionRequirementVersionKind, level: KmVersionRequirementLevel, errorCode: Int?, message: String?) { - delegate?.visit(kind, level, errorCode, message) - } - - /** - * Visits the version required by this requirement. - * - * @param major the major component of the version (e.g. "1" in "1.2.3") - * @param minor the minor component of the version (e.g. "2" in "1.2.3") - * @param patch the patch component of the version (e.g. "3" in "1.2.3") - */ - public open fun visitVersion(major: Int, minor: Int, patch: Int) { - delegate?.visitVersion(major, minor, patch) - } - - /** - * Visits the end of the version requirement. - */ - public open fun visitEnd() { - delegate?.visitEnd() - } -} - -/** - * A visitor to visit the contents of the contract of a Kotlin function. - * - * Contracts are an internal feature of the standard Kotlin library, and their behavior and/or binary format - * may change in a subsequent release. - * - * When using this class, zero or more calls to [visitEffect] must be done first, followed by [visitEnd]. - */ -@Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) -@Suppress("DEPRECATION_ERROR") -@ExperimentalContracts -public abstract class KmContractVisitor @JvmOverloads constructor(private val delegate: KmContractVisitor? = null) { - /** - * Visits an effect of this contract. - * - * @param type type of the effect - * @param invocationKind optional number of invocations of the lambda parameter of this function, - * specified further in the effect expression - */ - public open fun visitEffect(type: KmEffectType, invocationKind: KmEffectInvocationKind?): KmEffectVisitor? = - delegate?.visitEffect(type, invocationKind) - - /** - * Visits the end of the contract. - */ - public open fun visitEnd() { - delegate?.visitEnd() - } -} - -/** - * A visitor to visit an effect (a part of the contract of a Kotlin function). - * - * Contracts are an internal feature of the standard Kotlin library, and their behavior and/or binary format - * may change in a subsequent release. - * - * When using this class, zero or more calls to [visitConstructorArgument] or [visitConclusionOfConditionalEffect] must be done first, - * followed by [visitEnd]. - */ -@Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) -@Suppress("DEPRECATION_ERROR") -@ExperimentalContracts -public abstract class KmEffectVisitor @JvmOverloads constructor(private val delegate: KmEffectVisitor? = null) { - /** - * Visits the optional argument of the effect constructor, i.e. the constant value for the [KmEffectType.RETURNS_CONSTANT] effect, - * or the parameter reference for the [KmEffectType.CALLS] effect. - */ - public open fun visitConstructorArgument(): KmEffectExpressionVisitor? = - delegate?.visitConstructorArgument() - - /** - * Visits the optional conclusion of the effect. If this method is called, the effect represents an implication with the - * right-hand side handled by the returned visitor. - */ - public open fun visitConclusionOfConditionalEffect(): KmEffectExpressionVisitor? = - delegate?.visitConclusionOfConditionalEffect() - - /** - * Visits the end of the effect. - */ - public open fun visitEnd() { - delegate?.visitEnd() - } -} - -/** - * A visitor to visit the effect expression, the contents of an effect (a part of the contract of a Kotlin function). - * - * Contracts are an internal feature of the standard Kotlin library, and their behavior and/or binary format - * may change in a subsequent release. - * - * When using this class, [visit] must be called first, followed by zero or more calls to other visit* methods, followed by [visitEnd]. - */ -@Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) -@Suppress("DEPRECATION_ERROR") -@ExperimentalContracts -public abstract class KmEffectExpressionVisitor @JvmOverloads constructor(private val delegate: KmEffectExpressionVisitor? = null) { - /** - * Visits the basic information of the effect expression. - * - * @param flags effect expression flags, consisting of [Flag.EffectExpression] flags - * @param parameterIndex optional 1-based index of the value parameter of the function, for effects which assert something about - * the function parameters. The index 0 means the extension receiver parameter - */ - public open fun visit(flags: Int, parameterIndex: Int?) { - delegate?.visit(flags, parameterIndex) - } - - /** - * Visits the constant value used in the effect expression. May be `true`, `false` or `null`. - * - * @param value the constant value - */ - public open fun visitConstantValue(value: Any?) { - delegate?.visitConstantValue(value) - } - - /** - * Visits the type used as the target of an `is`-expression in the effect expression. - * - * @param flags type flags, consisting of [Flag.Type] flags - */ - public open fun visitIsInstanceType(flags: Int): KmTypeVisitor? = - delegate?.visitIsInstanceType(flags) - - /** - * Visits the argument of an `&&`-expression. If this method is called, the expression represents the left-hand side and - * the returned visitor handles the right-hand side. - */ - public open fun visitAndArgument(): KmEffectExpressionVisitor? = - delegate?.visitAndArgument() - - /** - * Visits the argument of an `||`-expression. If this method is called, the expression represents the left-hand side and - * the returned visitor handles the right-hand side. - */ - public open fun visitOrArgument(): KmEffectExpressionVisitor? = - delegate?.visitOrArgument() - - /** - * Visits the end of the effect expression. - */ - public open fun visitEnd() { - delegate?.visitEnd() - } -} - -/** - * Variance applied to a type parameter on the declaration site (*declaration-site variance*), - * or to a type in a projection (*use-site variance*). - */ -public enum class KmVariance { - /** - * The affected type parameter or type is *invariant*, which means it has no variance applied to it. - */ - INVARIANT, - - /** - * The affected type parameter or type is *contravariant*. Denoted by the `in` modifier in the source code. - */ - IN, - - /** - * The affected type parameter or type is *covariant*. Denoted by the `out` modifier in the source code. - */ - OUT, -} - -/** - * Type of an effect (a part of the contract of a Kotlin function). - * - * Contracts are an internal feature of the standard Kotlin library, and their behavior and/or binary format - * may change in a subsequent release. - */ -@ExperimentalContracts -public enum class KmEffectType { - /** - * Represents `returns(value)` contract effect: - * a situation when a function returns normally with the specified return value. - * Return value is stored in the [KmEffect.constructorArguments]. - */ - RETURNS_CONSTANT, - - /** - * Represents `callsInPlace` contract effect: - * A situation when the referenced lambda is invoked in place (optionally) specified number of times. - * - * Referenced lambda is stored in the [KmEffect.constructorArguments]. - * Number of invocations, if specified, is stored in [KmEffect.invocationKind]. - */ - CALLS, - - /** - * Represents `returnsNotNull` contract effect: - * a situation when a function returns normally with any value that is not null. - */ - RETURNS_NOT_NULL, -} - -/** - * Number of invocations of a lambda parameter specified by an effect (a part of the contract of a Kotlin function). - * - * Contracts are an internal feature of the standard Kotlin library, and their behavior and/or binary format - * may change in a subsequent release. - */ -@ExperimentalContracts -public enum class KmEffectInvocationKind { - /** - * A function parameter will be invoked one time or not invoked at all. - */ - AT_MOST_ONCE, - - /** - * A function parameter will be invoked exactly one time. - */ - EXACTLY_ONCE, - - /** - * A function parameter will be invoked one or more times. - */ - AT_LEAST_ONCE, -} - -/** - * Severity of the diagnostic reported by the compiler when a version requirement is not satisfied. - */ -public enum class KmVersionRequirementLevel { - /** - * Represents a diagnostic with 'WARNING' severity. - */ - WARNING, - - /** - * Represents a diagnostic with 'ERROR' severity. - */ - ERROR, - - /** - * Excludes the declaration from the resolution process completely when the version requirement is not satisfied. - */ - HIDDEN, -} - -/** - * The kind of the version that is required by a version requirement. - */ -public enum class KmVersionRequirementVersionKind { - /** - * Indicates that certain language version is required. - */ - LANGUAGE_VERSION, - - /** - * Indicates that certain compiler version is required. - */ - COMPILER_VERSION, - - /** - * Indicates that certain API version is required. - */ - API_VERSION, - - /** - * Represents a version requirement not successfully parsed from the metadata. - * - * The old metadata format (from Kotlin 1.3 and earlier) did not have enough information for correct parsing of version requirements in some cases, - * so a stub of this kind is inserted instead. - * - * [KmVersionRequirement] with this kind always has [KmVersionRequirementLevel.HIDDEN] level, `256.256.256` [KmVersionRequirement.version], - * and `null` [KmVersionRequirement.errorCode] and [KmVersionRequirement.message]. - * - * Version requirements of this kind are being ignored by writers (i.e., are not written back). - * - * See the following issues for details: [KT-60870](https://youtrack.jetbrains.com/issue/KT-60870), [KT-25120](https://youtrack.jetbrains.com/issue/KT-25120) - */ - UNKNOWN - ; -} diff --git a/libraries/kotlinx-metadata/src/kotlin/metadata/internal/FlagDelegatesImpl.kt b/libraries/kotlinx-metadata/src/kotlin/metadata/internal/FlagDelegatesImpl.kt index b6047020fe6..44821786e89 100644 --- a/libraries/kotlinx-metadata/src/kotlin/metadata/internal/FlagDelegatesImpl.kt +++ b/libraries/kotlinx-metadata/src/kotlin/metadata/internal/FlagDelegatesImpl.kt @@ -2,8 +2,6 @@ * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ -@file:Suppress("DEPRECATION_ERROR") // flags will become internal eventually - package kotlin.metadata.internal import kotlin.metadata.* @@ -73,3 +71,11 @@ internal fun valueParameterBooleanFlag(flag: Flag) = BooleanFlagDelegate(KmValue internal fun annotationsOn(flags: KMutableProperty1) = BooleanFlagDelegate(flags, Flag(ProtoFlags.HAS_ANNOTATIONS)) +// Used for kotlin-metadata-jvm tests: +public fun _flagAccess(kmClass: KmClass): Int = kmClass.flags + +public fun _flagAccess(kmFunc: KmFunction): Int = kmFunc.flags + +public fun _flagAccess(kmType: KmType): Int = kmType.flags + +public fun _flagAccess(kmConstr: KmConstructor): Int = kmConstr.flags diff --git a/libraries/kotlinx-metadata/src/kotlin/metadata/internal/Readers.kt b/libraries/kotlinx-metadata/src/kotlin/metadata/internal/Readers.kt index 58337ed29d0..878279e1bad 100644 --- a/libraries/kotlinx-metadata/src/kotlin/metadata/internal/Readers.kt +++ b/libraries/kotlinx-metadata/src/kotlin/metadata/internal/Readers.kt @@ -2,8 +2,6 @@ * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ -@file:Suppress("DEPRECATION_ERROR") // flags will become internal eventually - package kotlin.metadata.internal import kotlin.metadata.* diff --git a/libraries/kotlinx-metadata/src/kotlin/metadata/internal/Writers.kt b/libraries/kotlinx-metadata/src/kotlin/metadata/internal/Writers.kt index fc1d00341f0..f7dd1cd4ab5 100644 --- a/libraries/kotlinx-metadata/src/kotlin/metadata/internal/Writers.kt +++ b/libraries/kotlinx-metadata/src/kotlin/metadata/internal/Writers.kt @@ -2,7 +2,6 @@ * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ -@file:Suppress("DEPRECATION_ERROR") // flags will become internal eventually package kotlin.metadata.internal import kotlin.metadata.* diff --git a/libraries/kotlinx-metadata/src/kotlin/metadata/internal/common/KotlinCommonMetadata.kt b/libraries/kotlinx-metadata/src/kotlin/metadata/internal/common/KotlinCommonMetadata.kt index 5b21f23a706..18f721d1e3f 100644 --- a/libraries/kotlinx-metadata/src/kotlin/metadata/internal/common/KotlinCommonMetadata.kt +++ b/libraries/kotlinx-metadata/src/kotlin/metadata/internal/common/KotlinCommonMetadata.kt @@ -2,21 +2,16 @@ * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ -@file:Suppress("DEPRECATION_ERROR") // deprecated .accept implementation - package kotlin.metadata.internal.common import kotlin.metadata.* -import kotlin.metadata.VISITOR_API_MESSAGE import kotlin.metadata.internal.toKmPackage import kotlin.metadata.internal.toKmClass -import kotlin.metadata.internal.extensions.KmModuleFragmentExtension -import kotlin.metadata.internal.extensions.MetadataExtensions -import kotlin.metadata.internal.extensions.singleOfType import org.jetbrains.kotlin.metadata.ProtoBuf import org.jetbrains.kotlin.metadata.builtins.readBuiltinsPackageFragment import org.jetbrains.kotlin.metadata.deserialization.NameResolverImpl import java.io.ByteArrayInputStream +import kotlin.metadata.internal.extensions.* /** * Reads metadata that is not from annotation nor from `.kotlin_module` file. @@ -27,22 +22,11 @@ public class KotlinCommonMetadata private constructor(proto: ProtoBuf.PackageFra public val kmModuleFragment: KmModuleFragment = readImpl(proto) - @Deprecated( - "To avoid excessive copying, use .kmModuleFragment property instead. Note that it returns a view and not a copy.", - ReplaceWith("kmModuleFragment"), - DeprecationLevel.ERROR - ) - public fun toKmModuleFragment(): KmModuleFragment = - KmModuleFragment().apply { kmModuleFragment.accept(this) } - // private because there are no use-cases and it is not finished - private class Writer : KmModuleFragmentVisitor() { + private class Writer { // TODO } - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - public fun accept(v: KmModuleFragmentVisitor): Unit = kmModuleFragment.accept(v) - private fun readImpl(proto: ProtoBuf.PackageFragment): KmModuleFragment { val v = KmModuleFragment() val strings = NameResolverImpl(proto.strings, proto.qualifiedNames) @@ -73,7 +57,7 @@ public class KotlinCommonMetadata private constructor(proto: ProtoBuf.PackageFra * * Can be read with [KotlinCommonMetadata.read]. */ -public class KmModuleFragment : KmModuleFragmentVisitor() { +public class KmModuleFragment { /** * Top-level functions, type aliases and properties in the module fragment. @@ -87,72 +71,4 @@ public class KmModuleFragment : KmModuleFragmentVisitor() { internal val extensions: List = MetadataExtensions.INSTANCES.map(MetadataExtensions::createModuleFragmentExtensions) - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitPackage(): KmPackageVisitor? = - KmPackage().also { pkg = it } - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitExtensions(type: KmExtensionType): KmModuleFragmentExtensionVisitor? = - extensions.singleOfType(type) - - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - override fun visitClass(): KmClassVisitor? = - KmClass().addTo(classes) - - /** - * Populates the given visitor with data in this module fragment. - * - * @param visitor the visitor which will visit data in the module fragment. - */ - @Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) - public fun accept(visitor: KmModuleFragmentVisitor) { - pkg?.let { visitor.visitPackage()?.let(it::accept) } - classes.forEach { visitor.visitClass()?.let(it::accept) } - extensions.forEach { visitor.visitExtensions(it.type)?.let(it::accept) } - visitor.visitEnd() - } } - -/** - * A visitor to visit module fragments. The module fragment can have no more than one package, and any number of classes, - * and must have at least one declaration. - * - * When using this class, [visitEnd] must be called exactly once and after calls to all other visit* methods. - */ -@Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) -public abstract class KmModuleFragmentVisitor @JvmOverloads constructor(private val delegate: KmModuleFragmentVisitor? = null) { - - /** - * Visits a package within the module fragment. - */ - public open fun visitPackage(): KmPackageVisitor? = - delegate?.visitPackage() - - /** - * Visits a class within the module fragment. - */ - public open fun visitClass(): KmClassVisitor? = - delegate?.visitClass() - - /** - * Visits the extensions of the given type on the module fragment. - * - * @param type the type of extension visitor to be returned. - */ - public open fun visitExtensions(type: KmExtensionType): KmModuleFragmentExtensionVisitor? = - delegate?.visitExtensions(type) - - /** - * Visits the end of the module fragment. - */ - public open fun visitEnd() { - delegate?.visitEnd() - } -} - -/** - * A visitor to visit platform-specific extensions for a module fragment. - */ -@Deprecated(VISITOR_API_MESSAGE, level = DeprecationLevel.ERROR) -public interface KmModuleFragmentExtensionVisitor : KmExtensionVisitor diff --git a/libraries/kotlinx-metadata/src/kotlin/metadata/internal/extensions/ExtensionNodes.kt b/libraries/kotlinx-metadata/src/kotlin/metadata/internal/extensions/ExtensionNodes.kt index f3ae76243e9..22c5804daac 100644 --- a/libraries/kotlinx-metadata/src/kotlin/metadata/internal/extensions/ExtensionNodes.kt +++ b/libraries/kotlinx-metadata/src/kotlin/metadata/internal/extensions/ExtensionNodes.kt @@ -2,33 +2,94 @@ * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ -@file:Suppress("DEPRECATION_ERROR") // deprecated visitors API - package kotlin.metadata.internal.extensions import kotlin.metadata.* -import kotlin.metadata.internal.common.KmModuleFragmentExtensionVisitor +import kotlin.metadata.internal.common.KmModuleFragment +import kotlin.reflect.KClass -public interface KmExtension : KmExtensionVisitor { - public fun accept(visitor: V) +/** + * A type of the extension expected by the code that uses the extensions API. + * + * Each declaration that can have platform-specific extensions in the metadata has a method `getExtension`, e.g.: + * `fun KmFunction.getExtension(type: KmExtensionType): KmFunctionExtension`. + * + * These functions are used by -jvm and -klib counterparts to retrieve platform-specific metadata + * and should not be used in any other way. + */ +public class KmExtensionType(private val klass: KClass) { + override fun equals(other: Any?): Boolean = + other is KmExtensionType && klass == other.klass + + override fun hashCode(): Int = + klass.hashCode() + + override fun toString(): String = + klass.java.name } -public interface KmClassExtension : KmClassExtensionVisitor, KmExtension +/** + * Base interface for all extensions to hold the extension type. + */ +public interface KmExtension { -public interface KmPackageExtension : KmPackageExtensionVisitor, KmExtension + /** + * Type of this extension. + */ + public val type: KmExtensionType +} -public interface KmModuleFragmentExtension : KmModuleFragmentExtensionVisitor, KmExtension +public interface KmClassExtension : KmExtension -public interface KmFunctionExtension : KmFunctionExtensionVisitor, KmExtension +public fun KmClass.getExtension(type: KmExtensionType): KmClassExtension = extensions.singleOfType(type) -public interface KmPropertyExtension : KmPropertyExtensionVisitor, KmExtension +public interface KmPackageExtension : KmExtension -public interface KmConstructorExtension : KmConstructorExtensionVisitor, KmExtension +public fun KmPackage.getExtension(type: KmExtensionType): KmPackageExtension = extensions.singleOfType(type) -public interface KmTypeParameterExtension : KmTypeParameterExtensionVisitor, KmExtension +public interface KmModuleFragmentExtension : KmExtension -public interface KmTypeExtension : KmTypeExtensionVisitor, KmExtension +public fun KmModuleFragment.getExtension(type: KmExtensionType): KmModuleFragmentExtension = extensions.singleOfType(type) -public interface KmTypeAliasExtension : KmTypeAliasExtensionVisitor, KmExtension +public interface KmFunctionExtension : KmExtension -public interface KmValueParameterExtension : KmValueParameterExtensionVisitor, KmExtension +public fun KmFunction.getExtension(type: KmExtensionType): KmFunctionExtension = extensions.singleOfType(type) + +public interface KmPropertyExtension : KmExtension + +public fun KmProperty.getExtension(type: KmExtensionType): KmPropertyExtension = extensions.singleOfType(type) + +public interface KmConstructorExtension : KmExtension + +public fun KmConstructor.getExtension(type: KmExtensionType): KmConstructorExtension = extensions.singleOfType(type) + +public interface KmTypeParameterExtension : KmExtension + +public fun KmTypeParameter.getExtension(type: KmExtensionType): KmTypeParameterExtension = extensions.singleOfType(type) + +public interface KmTypeExtension : KmExtension + +public fun KmType.getExtension(type: KmExtensionType): KmTypeExtension = extensions.singleOfType(type) + +public interface KmTypeAliasExtension : KmExtension + +public fun KmTypeAlias.getExtension(type: KmExtensionType): KmTypeAliasExtension = extensions.singleOfType(type) + +public interface KmValueParameterExtension : KmExtension + +public fun KmValueParameter.getExtension(type: KmExtensionType): KmValueParameterExtension = extensions.singleOfType(type) + +private fun Collection.singleOfType(type: KmExtensionType): N { + var result: N? = null + for (node in this) { + if (node.type != type) continue + if (result != null) { + throw IllegalStateException("Multiple extensions handle the same extension type: $type") + } + result = node + } + if (result == null) { + throw IllegalStateException("No extensions handle the extension type: $type") + } + return result +} diff --git a/libraries/kotlinx-metadata/src/kotlin/metadata/internal/extensions/ExtensionUtils.kt b/libraries/kotlinx-metadata/src/kotlin/metadata/internal/extensions/ExtensionUtils.kt deleted file mode 100644 index 445fd7c264c..00000000000 --- a/libraries/kotlinx-metadata/src/kotlin/metadata/internal/extensions/ExtensionUtils.kt +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ -@file:Suppress("DEPRECATION_ERROR") // KmExtensionType will be moved to an internal package -package kotlin.metadata.internal.extensions - -import kotlin.metadata.KmExtensionType - -internal fun > Collection.singleOfType(type: KmExtensionType): N { - var result: N? = null - for (node in this) { - if (node.type != type) continue - if (result != null) { - throw IllegalStateException("Multiple extensions handle the same extension type: $type") - } - result = node - } - if (result == null) { - throw IllegalStateException("No extensions handle the extension type: $type") - } - return result -}