Promote deprecation on Flags API to ERROR

#KT-59440
This commit is contained in:
Leonid Startsev
2023-08-15 15:59:14 +02:00
committed by Space Team
parent 06c471d413
commit 6e4d033f89
16 changed files with 248 additions and 227 deletions
@@ -138,7 +138,7 @@ public final class kotlinx/metadata/ClassNameKt {
public abstract interface annotation class kotlinx/metadata/ExperimentalContextReceivers : java/lang/annotation/Annotation { public abstract interface annotation class kotlinx/metadata/ExperimentalContextReceivers : java/lang/annotation/Annotation {
} }
public abstract class kotlinx/metadata/Flag { public final class kotlinx/metadata/Flag {
public static final field Common Lkotlinx/metadata/Flag$Common; public static final field Common Lkotlinx/metadata/Flag$Common;
public static final field HAS_ANNOTATIONS Lkotlinx/metadata/Flag; public static final field HAS_ANNOTATIONS Lkotlinx/metadata/Flag;
public static final field IS_ABSTRACT Lkotlinx/metadata/Flag; public static final field IS_ABSTRACT Lkotlinx/metadata/Flag;
@@ -151,7 +151,8 @@ public abstract class kotlinx/metadata/Flag {
public static final field IS_PROTECTED Lkotlinx/metadata/Flag; public static final field IS_PROTECTED Lkotlinx/metadata/Flag;
public static final field IS_PUBLIC Lkotlinx/metadata/Flag; public static final field IS_PUBLIC Lkotlinx/metadata/Flag;
public static final field IS_SEALED Lkotlinx/metadata/Flag; public static final field IS_SEALED Lkotlinx/metadata/Flag;
public abstract fun invoke (I)Z public fun <init> (III)V
public final fun invoke (I)Z
} }
public final class kotlinx/metadata/Flag$Class { public final class kotlinx/metadata/Flag$Class {
@@ -3,7 +3,7 @@
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. * 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") @file:Suppress("DEPRECATION_ERROR") // flags will become internal eventually
@file:JvmName("JvmAttributes") @file:JvmName("JvmAttributes")
package kotlinx.metadata.jvm package kotlinx.metadata.jvm
@@ -45,7 +45,10 @@ public var KmClass.anonymousObjectOriginName: String?
/** /**
* JVM-specific flags of the class, consisting of [JvmFlag.Class] flags. * 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") @Deprecated(
"Flag API is deprecated. Please use corresponding member extensions on KmClass, such as KmClass.hasMethodBodiesInInterface",
level = DeprecationLevel.ERROR
)
public var KmClass.jvmFlags: Int public var KmClass.jvmFlags: Int
get() = jvm.jvmFlags get() = jvm.jvmFlags
set(value) { set(value) {
@@ -97,7 +100,10 @@ public var KmFunction.lambdaClassOriginName: String?
/** /**
* JVM-specific flags of the property, consisting of [JvmFlag.Property] flags. * 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") @Deprecated(
"Flag API is deprecated. Please use corresponding member extensions on KmProperty, such as KmProperty.isMovedFromInterfaceCompanion",
level = DeprecationLevel.ERROR
)
public var KmProperty.jvmFlags: Int public var KmProperty.jvmFlags: Int
get() = jvm.jvmFlags get() = jvm.jvmFlags
set(value) { set(value) {
@@ -3,12 +3,11 @@
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. * 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") @file:Suppress("DEPRECATION_ERROR")
package kotlinx.metadata.jvm package kotlinx.metadata.jvm
import kotlinx.metadata.Flag import kotlinx.metadata.Flag
import kotlinx.metadata.internal.FlagImpl
import org.jetbrains.kotlin.metadata.deserialization.Flags as F import org.jetbrains.kotlin.metadata.deserialization.Flags as F
import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmFlags as JF import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmFlags as JF
@@ -20,12 +19,12 @@ private const val prefix = "Flag API is deprecated. Please use"
* @see Flag * @see Flag
* @see Flags * @see Flags
*/ */
@Deprecated("$prefix corresponding extensions on Km nodes, such as KmClass.hasMethodBodiesInInterface") @Deprecated("$prefix corresponding extensions on Km nodes, such as KmClass.hasMethodBodiesInInterface", level = DeprecationLevel.ERROR)
public object JvmFlag { public object JvmFlag {
/** /**
* JVM-specific property flags in addition to common property flags declared in [Flag.Property]. * JVM-specific property flags in addition to common property flags declared in [Flag.Property].
*/ */
@Deprecated("$prefix corresponding extension on KmProperty: KmProperty.isMovedFromInterfaceCompanion") @Deprecated("$prefix corresponding extension on KmProperty: KmProperty.isMovedFromInterfaceCompanion", level = DeprecationLevel.ERROR)
public object Property { public object Property {
/** /**
* Applied to a property declared in an interface's companion object, signifies that its backing field is declared as a static * Applied to a property declared in an interface's companion object, signifies that its backing field is declared as a static
@@ -34,14 +33,14 @@ public object JvmFlag {
* Has no effect if the property is not declared in a companion object of some interface. * Has no effect if the property is not declared in a companion object of some interface.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmProperty.isMovedFromInterfaceCompanion") @Deprecated("$prefix KmProperty.isMovedFromInterfaceCompanion", level = DeprecationLevel.ERROR)
public val IS_MOVED_FROM_INTERFACE_COMPANION: Flag = booleanFlag(JF.IS_MOVED_FROM_INTERFACE_COMPANION) 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]. * JVM-specific class flags in addition to common class flags declared in [Flag.Class].
*/ */
@Deprecated("$prefix corresponding extensions on KmClass") @Deprecated("$prefix corresponding extensions on KmClass", level = DeprecationLevel.ERROR)
public object Class { public object Class {
/** /**
* Applied to an interface compiled with -Xjvm-default=all or all-compatibility. * Applied to an interface compiled with -Xjvm-default=all or all-compatibility.
@@ -51,7 +50,7 @@ public object JvmFlag {
* class. * class.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmClass.hasMethodBodiesInInterface") @Deprecated("$prefix KmClass.hasMethodBodiesInInterface", level = DeprecationLevel.ERROR)
public val HAS_METHOD_BODIES_IN_INTERFACE: Flag = booleanFlag(JF.IS_COMPILED_IN_JVM_DEFAULT_MODE) public val HAS_METHOD_BODIES_IN_INTERFACE: Flag = booleanFlag(JF.IS_COMPILED_IN_JVM_DEFAULT_MODE)
/** /**
@@ -62,10 +61,10 @@ public object JvmFlag {
* clients compiled without all-compatibility. * clients compiled without all-compatibility.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmClass.isCompiledInCompatibilityMode") @Deprecated("$prefix KmClass.isCompiledInCompatibilityMode", level = DeprecationLevel.ERROR)
public val IS_COMPILED_IN_COMPATIBILITY_MODE: Flag = booleanFlag(JF.IS_COMPILED_IN_COMPATIBILITY_MODE) public val IS_COMPILED_IN_COMPATIBILITY_MODE: Flag = booleanFlag(JF.IS_COMPILED_IN_COMPATIBILITY_MODE)
} }
internal fun booleanFlag(f: F.BooleanFlagField): Flag = internal fun booleanFlag(f: F.BooleanFlagField): Flag =
FlagImpl(f.offset, f.bitWidth, 1) Flag(f.offset, f.bitWidth, 1)
} }
@@ -10,7 +10,7 @@ import org.junit.Test
import kotlin.reflect.KMutableProperty0 import kotlin.reflect.KMutableProperty0
import kotlin.test.* import kotlin.test.*
@Suppress("DEPRECATION") @Suppress("DEPRECATION", "DEPRECATION_ERROR") // flags will become internal eventually
class FlagDelegatesTest { class FlagDelegatesTest {
private class Private private class Private
@@ -30,7 +30,7 @@ class MetadataSmokeTest {
val classMetadata = L::class.java.readMetadataAsKmClass() val classMetadata = L::class.java.readMetadataAsKmClass()
val inlineFunctions = classMetadata.functions val inlineFunctions = classMetadata.functions
.filter { Flag.Function.IS_INLINE(it.flags) } .filter { it.isInline }
.mapNotNull { it.signature?.toString() } .mapNotNull { it.signature?.toString() }
assertEquals( assertEquals(
@@ -146,6 +146,7 @@ class MetadataSmokeTest {
} }
@Test @Test
@Suppress("DEPRECATION_ERROR") // flags will become internal eventually
fun unstableParameterNames() { fun unstableParameterNames() {
@Suppress("unused", "UNUSED_PARAMETER") @Suppress("unused", "UNUSED_PARAMETER")
class Test(a: String, b: Int, c: Boolean) { class Test(a: String, b: Int, c: Boolean) {
@@ -8,7 +8,7 @@ package kotlinx.metadata
/** /**
* Represents an annotation, written to the Kotlin metadata. Note that not all annotations are written to metadata on all platforms. * Represents an annotation, written to the Kotlin metadata. Note that not all annotations are written to metadata on all platforms.
* For example, on JVM most of the annotations are written directly on the corresponding declarations in the class file, * For example, on JVM most of the annotations are written directly on the corresponding declarations in the class file,
* and entries in the metadata only have a flag ([Flag.HAS_ANNOTATIONS]) to signal if they do have annotations in the bytecode. * and entries in the metadata only have an attribute (such as [KmClass.hasAnnotations]) to signal if they do have annotations in the bytecode.
* On JVM, only annotations on type parameters and types are serialized to the Kotlin metadata * On JVM, only annotations on type parameters and types are serialized to the Kotlin metadata
* (see `KmType.annotations` and `KmTypeParameter.annotations` JVM extensions) * (see `KmType.annotations` and `KmTypeParameter.annotations` JVM extensions)
* *
@@ -3,7 +3,7 @@
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. * 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") @file:Suppress("DEPRECATION_ERROR") // flags will become internal eventually
@file:JvmName("Attributes") @file:JvmName("Attributes")
package kotlinx.metadata package kotlinx.metadata
@@ -127,23 +127,23 @@ public var KmClass.kind: ClassKind by EnumFlagDelegate(
/** /**
* Indicates that the corresponding class is `inner`. * Indicates that the corresponding class is `inner`.
*/ */
public var KmClass.isInner: Boolean by classBooleanFlag(Flag(ProtoFlags.IS_INNER)) public var KmClass.isInner: Boolean by classBooleanFlag(FlagImpl(ProtoFlags.IS_INNER))
/** /**
* Indicates that the corresponding `class` or `object` is `data`. * Indicates that the corresponding `class` or `object` is `data`.
* Always false for other kinds. * Always false for other kinds.
*/ */
public var KmClass.isData: Boolean by classBooleanFlag(Flag(ProtoFlags.IS_DATA)) public var KmClass.isData: Boolean by classBooleanFlag(FlagImpl(ProtoFlags.IS_DATA))
/** /**
* Indicates that the corresponding class is `external`. * Indicates that the corresponding class is `external`.
*/ */
public var KmClass.isExternal: Boolean by classBooleanFlag(Flag(ProtoFlags.IS_EXTERNAL_CLASS)) public var KmClass.isExternal: Boolean by classBooleanFlag(FlagImpl(ProtoFlags.IS_EXTERNAL_CLASS))
/** /**
* Indicates that the corresponding class is `expect`. * Indicates that the corresponding class is `expect`.
*/ */
public var KmClass.isExpect: Boolean by classBooleanFlag(Flag(ProtoFlags.IS_EXPECT_CLASS)) public var KmClass.isExpect: Boolean by classBooleanFlag(FlagImpl(ProtoFlags.IS_EXPECT_CLASS))
/** /**
* Indicates that the corresponding class is either a pre-Kotlin-1.5 `inline` class, or a 1.5+ `value` class. * Indicates that the corresponding class is either a pre-Kotlin-1.5 `inline` class, or a 1.5+ `value` class.
@@ -151,14 +151,14 @@ public var KmClass.isExpect: Boolean by classBooleanFlag(Flag(ProtoFlags.IS_EXPE
* Note that it does not imply that the class has [JvmInline] annotation and will be inlined. * Note that it does not imply that the class has [JvmInline] annotation and will be inlined.
* Currently, it is impossible to declare a value class without this annotation, but this can be changed in the future. * Currently, it is impossible to declare a value class without this annotation, but this can be changed in the future.
*/ */
public var KmClass.isValue: Boolean by classBooleanFlag(Flag(ProtoFlags.IS_VALUE_CLASS)) public var KmClass.isValue: Boolean by classBooleanFlag(FlagImpl(ProtoFlags.IS_VALUE_CLASS))
/** /**
* Indicates that the corresponding class is a functional interface, i.e., marked with the keyword `fun`. * Indicates that the corresponding class is a functional interface, i.e., marked with the keyword `fun`.
* *
* Always `false` if [KmClass.kind] is not an interface. * Always `false` if [KmClass.kind] is not an interface.
*/ */
public var KmClass.isFunInterface: Boolean by classBooleanFlag(Flag(ProtoFlags.IS_FUN_INTERFACE)) public var KmClass.isFunInterface: Boolean by classBooleanFlag(FlagImpl(ProtoFlags.IS_FUN_INTERFACE))
/** /**
* Indicates that the corresponding enum class has synthetic ".entries" property in bytecode. * Indicates that the corresponding enum class has synthetic ".entries" property in bytecode.
@@ -166,7 +166,7 @@ public var KmClass.isFunInterface: Boolean by classBooleanFlag(Flag(ProtoFlags.I
* Always `false` if [KmClass.kind] is not an enum. * Always `false` if [KmClass.kind] is not an enum.
* Enum classes always have enum entries property starting from Kotlin 1.9.0. * Enum classes always have enum entries property starting from Kotlin 1.9.0.
*/ */
public var KmClass.hasEnumEntries: Boolean by classBooleanFlag(Flag(ProtoFlags.HAS_ENUM_ENTRIES)) public var KmClass.hasEnumEntries: Boolean by classBooleanFlag(FlagImpl(ProtoFlags.HAS_ENUM_ENTRIES))
// --- CONSTRUCTOR --- // --- CONSTRUCTOR ---
@@ -181,7 +181,7 @@ public var KmConstructor.visibility: Visibility by visibilityDelegate(KmConstruc
/** /**
* Indicates that the corresponding constructor is secondary, i.e., declared not in the class header, but in the class body. * Indicates that the corresponding constructor is secondary, i.e., declared not in the class header, but in the class body.
*/ */
public var KmConstructor.isSecondary: Boolean by constructorBooleanFlag(Flag(ProtoFlags.IS_SECONDARY)) public var KmConstructor.isSecondary: Boolean by constructorBooleanFlag(FlagImpl(ProtoFlags.IS_SECONDARY))
/** /**
* Indicates that the corresponding constructor has non-stable parameter names, i.e., cannot be called with named arguments. * Indicates that the corresponding constructor has non-stable parameter names, i.e., cannot be called with named arguments.
@@ -189,7 +189,7 @@ public var KmConstructor.isSecondary: Boolean by constructorBooleanFlag(Flag(Pro
* Currently, this attribute is Kotlin/Native-specific and is never set by Kotlin/JVM compiler. * Currently, this attribute is Kotlin/Native-specific and is never set by Kotlin/JVM compiler.
* This may be changed in the future. * This may be changed in the future.
*/ */
public var KmConstructor.hasNonStableParameterNames: Boolean by constructorBooleanFlag(Flag(ProtoFlags.IS_CONSTRUCTOR_WITH_NON_STABLE_PARAMETER_NAMES)) public var KmConstructor.hasNonStableParameterNames: Boolean by constructorBooleanFlag(FlagImpl(ProtoFlags.IS_CONSTRUCTOR_WITH_NON_STABLE_PARAMETER_NAMES))
// --- FUNCTION --- // --- FUNCTION ---
@@ -221,37 +221,37 @@ public var KmFunction.modality: Modality by modalityDelegate(KmFunction::flags)
/** /**
* Indicates that the corresponding function is `operator`. * Indicates that the corresponding function is `operator`.
*/ */
public var KmFunction.isOperator: Boolean by functionBooleanFlag(Flag(ProtoFlags.IS_OPERATOR)) public var KmFunction.isOperator: Boolean by functionBooleanFlag(FlagImpl(ProtoFlags.IS_OPERATOR))
/** /**
* Indicates that the corresponding function is `infix`. * Indicates that the corresponding function is `infix`.
*/ */
public var KmFunction.isInfix: Boolean by functionBooleanFlag(Flag(ProtoFlags.IS_INFIX)) public var KmFunction.isInfix: Boolean by functionBooleanFlag(FlagImpl(ProtoFlags.IS_INFIX))
/** /**
* Indicates that the corresponding function is `inline`. * Indicates that the corresponding function is `inline`.
*/ */
public var KmFunction.isInline: Boolean by functionBooleanFlag(Flag(ProtoFlags.IS_INLINE)) public var KmFunction.isInline: Boolean by functionBooleanFlag(FlagImpl(ProtoFlags.IS_INLINE))
/** /**
* Indicates that the corresponding function is `tailrec`. * Indicates that the corresponding function is `tailrec`.
*/ */
public var KmFunction.isTailrec: Boolean by functionBooleanFlag(Flag(ProtoFlags.IS_TAILREC)) public var KmFunction.isTailrec: Boolean by functionBooleanFlag(FlagImpl(ProtoFlags.IS_TAILREC))
/** /**
* Indicates that the corresponding function is `external`. * Indicates that the corresponding function is `external`.
*/ */
public var KmFunction.isExternal: Boolean by functionBooleanFlag(Flag(ProtoFlags.IS_EXTERNAL_FUNCTION)) public var KmFunction.isExternal: Boolean by functionBooleanFlag(FlagImpl(ProtoFlags.IS_EXTERNAL_FUNCTION))
/** /**
* Indicates that the corresponding function is `suspend`. * Indicates that the corresponding function is `suspend`.
*/ */
public var KmFunction.isSuspend: Boolean by functionBooleanFlag(Flag(ProtoFlags.IS_SUSPEND)) public var KmFunction.isSuspend: Boolean by functionBooleanFlag(FlagImpl(ProtoFlags.IS_SUSPEND))
/** /**
* Indicates that the corresponding function is `expect`. * Indicates that the corresponding function is `expect`.
*/ */
public var KmFunction.isExpect: Boolean by functionBooleanFlag(Flag(ProtoFlags.IS_EXPECT_FUNCTION)) public var KmFunction.isExpect: Boolean by functionBooleanFlag(FlagImpl(ProtoFlags.IS_EXPECT_FUNCTION))
/** /**
* Indicates that the corresponding function has non-stable parameter names, i.e., cannot be called with named arguments. * Indicates that the corresponding function has non-stable parameter names, i.e., cannot be called with named arguments.
@@ -259,7 +259,7 @@ public var KmFunction.isExpect: Boolean by functionBooleanFlag(Flag(ProtoFlags.I
* Currently, this attribute is Kotlin/Native-specific and is never set by Kotlin/JVM compiler. * Currently, this attribute is Kotlin/Native-specific and is never set by Kotlin/JVM compiler.
* This may be changed in the future. * This may be changed in the future.
*/ */
public var KmFunction.hasNonStableParameterNames: Boolean by functionBooleanFlag(Flag(ProtoFlags.IS_FUNCTION_WITH_NON_STABLE_PARAMETER_NAMES)) public var KmFunction.hasNonStableParameterNames: Boolean by functionBooleanFlag(FlagImpl(ProtoFlags.IS_FUNCTION_WITH_NON_STABLE_PARAMETER_NAMES))
// --- PROPERTY --- // --- PROPERTY ---
@@ -293,29 +293,29 @@ public var KmProperty.kind: MemberKind by memberKindDelegate(KmProperty::flags)
* *
* Note that setting [KmProperty.isVar] to true does not automatically create [KmProperty.setter] and vice versa. This has to be done explicitly. * Note that setting [KmProperty.isVar] to true does not automatically create [KmProperty.setter] and vice versa. This has to be done explicitly.
*/ */
public var KmProperty.isVar: Boolean by propertyBooleanFlag(Flag(ProtoFlags.IS_VAR)) public var KmProperty.isVar: Boolean by propertyBooleanFlag(FlagImpl(ProtoFlags.IS_VAR))
/** /**
* Indicates that the corresponding property has a getter. * Indicates that the corresponding property has a getter.
*/ */
@Deprecated("Kotlin properties always have getters", ReplaceWith("true"), DeprecationLevel.WARNING) @Deprecated("Kotlin properties always have getters", ReplaceWith("true"), DeprecationLevel.WARNING)
public var KmProperty.hasGetter: Boolean by propertyBooleanFlag(Flag(ProtoFlags.HAS_GETTER)) public var KmProperty.hasGetter: Boolean by propertyBooleanFlag(FlagImpl(ProtoFlags.HAS_GETTER))
/** /**
* Indicates that the corresponding property has a setter. * Indicates that the corresponding property has a setter.
*/ */
@Deprecated("Check .setter for nullability instead", ReplaceWith("this.setter != null"), DeprecationLevel.WARNING) @Deprecated("Check .setter for nullability instead", ReplaceWith("this.setter != null"), DeprecationLevel.WARNING)
public var KmProperty.hasSetter: Boolean by propertyBooleanFlag(Flag(ProtoFlags.HAS_SETTER)) public var KmProperty.hasSetter: Boolean by propertyBooleanFlag(FlagImpl(ProtoFlags.HAS_SETTER))
/** /**
* Indicates that the corresponding property is `const`. * Indicates that the corresponding property is `const`.
*/ */
public var KmProperty.isConst: Boolean by propertyBooleanFlag(Flag(ProtoFlags.IS_CONST)) public var KmProperty.isConst: Boolean by propertyBooleanFlag(FlagImpl(ProtoFlags.IS_CONST))
/** /**
* Indicates that the corresponding property is `lateinit`. * Indicates that the corresponding property is `lateinit`.
*/ */
public var KmProperty.isLateinit: Boolean by propertyBooleanFlag(Flag(ProtoFlags.IS_LATEINIT)) public var KmProperty.isLateinit: Boolean by propertyBooleanFlag(FlagImpl(ProtoFlags.IS_LATEINIT))
/** /**
* Indicates that the corresponding property has a constant value. On JVM, this flag allows an optimization similarly to * Indicates that the corresponding property has a constant value. On JVM, this flag allows an optimization similarly to
@@ -338,12 +338,12 @@ public var KmProperty.isLateinit: Boolean by propertyBooleanFlag(Flag(ProtoFlags
* } * }
* ``` * ```
*/ */
public var KmProperty.hasConstant: Boolean by propertyBooleanFlag(Flag(ProtoFlags.HAS_CONSTANT)) public var KmProperty.hasConstant: Boolean by propertyBooleanFlag(FlagImpl(ProtoFlags.HAS_CONSTANT))
/** /**
* Indicates that the corresponding property is `external`. * Indicates that the corresponding property is `external`.
*/ */
public var KmProperty.isExternal: Boolean by propertyBooleanFlag(Flag(ProtoFlags.IS_EXTERNAL_PROPERTY)) public var KmProperty.isExternal: Boolean by propertyBooleanFlag(FlagImpl(ProtoFlags.IS_EXTERNAL_PROPERTY))
/** /**
* Indicates that the corresponding property is a delegated property. * Indicates that the corresponding property is a delegated property.
@@ -351,12 +351,12 @@ public var KmProperty.isExternal: Boolean by propertyBooleanFlag(Flag(ProtoFlags
* Not to be confused with interface delegation. * Not to be confused with interface delegation.
* If a property was produced by interface delegation, it would have the corresponding [KmProperty.kind]. * If a property was produced by interface delegation, it would have the corresponding [KmProperty.kind].
*/ */
public var KmProperty.isDelegated: Boolean by propertyBooleanFlag(Flag(ProtoFlags.IS_DELEGATED)) public var KmProperty.isDelegated: Boolean by propertyBooleanFlag(FlagImpl(ProtoFlags.IS_DELEGATED))
/** /**
* Indicates that the corresponding property is `expect`. * Indicates that the corresponding property is `expect`.
*/ */
public var KmProperty.isExpect: Boolean by propertyBooleanFlag(Flag(ProtoFlags.IS_EXPECT_PROPERTY)) public var KmProperty.isExpect: Boolean by propertyBooleanFlag(FlagImpl(ProtoFlags.IS_EXPECT_PROPERTY))
// --- PROPERTY ACCESSOR --- // --- PROPERTY ACCESSOR ---
@@ -382,17 +382,17 @@ public var KmPropertyAccessorAttributes.modality: Modality by modalityDelegate(K
* Indicates that the corresponding property accessor is not default, i.e. it has a body and/or annotations in the source code, * Indicates that the corresponding property accessor is not default, i.e. it has a body and/or annotations in the source code,
* or the property is delegated. * or the property is delegated.
*/ */
public var KmPropertyAccessorAttributes.isNotDefault: Boolean by propertyAccessorBooleanFlag(Flag(ProtoFlags.IS_NOT_DEFAULT)) public var KmPropertyAccessorAttributes.isNotDefault: Boolean by propertyAccessorBooleanFlag(FlagImpl(ProtoFlags.IS_NOT_DEFAULT))
/** /**
* Indicates that the corresponding property accessor is `external`. * Indicates that the corresponding property accessor is `external`.
*/ */
public var KmPropertyAccessorAttributes.isExternal: Boolean by propertyAccessorBooleanFlag(Flag(ProtoFlags.IS_EXTERNAL_ACCESSOR)) public var KmPropertyAccessorAttributes.isExternal: Boolean by propertyAccessorBooleanFlag(FlagImpl(ProtoFlags.IS_EXTERNAL_ACCESSOR))
/** /**
* Indicates that the corresponding property accessor is `inline`. * Indicates that the corresponding property accessor is `inline`.
*/ */
public var KmPropertyAccessorAttributes.isInline: Boolean by propertyAccessorBooleanFlag(Flag(ProtoFlags.IS_INLINE_ACCESSOR)) public var KmPropertyAccessorAttributes.isInline: Boolean by propertyAccessorBooleanFlag(FlagImpl(ProtoFlags.IS_INLINE_ACCESSOR))
// --- TYPE & TYPE_PARAM // --- TYPE & TYPE_PARAM
@@ -443,17 +443,17 @@ public var KmTypeAlias.visibility: Visibility by visibilityDelegate(KmTypeAlias:
* parameter in the derived method does _not_ declare the default value, but the parameter is * parameter in the derived method does _not_ declare the default value, but the parameter is
* still optional at the call site because the default value from the base method is used. * still optional at the call site because the default value from the base method is used.
*/ */
public var KmValueParameter.declaresDefaultValue: Boolean by valueParameterBooleanFlag(Flag(ProtoFlags.DECLARES_DEFAULT_VALUE)) public var KmValueParameter.declaresDefaultValue: Boolean by valueParameterBooleanFlag(FlagImpl(ProtoFlags.DECLARES_DEFAULT_VALUE))
/** /**
* Indicates that the corresponding value parameter is `crossinline`. * Indicates that the corresponding value parameter is `crossinline`.
*/ */
public var KmValueParameter.isCrossinline: Boolean by valueParameterBooleanFlag(Flag(ProtoFlags.IS_CROSSINLINE)) public var KmValueParameter.isCrossinline: Boolean by valueParameterBooleanFlag(FlagImpl(ProtoFlags.IS_CROSSINLINE))
/** /**
* Indicates that the corresponding value parameter is `noinline`. * Indicates that the corresponding value parameter is `noinline`.
*/ */
public var KmValueParameter.isNoinline: Boolean by valueParameterBooleanFlag(Flag(ProtoFlags.IS_NOINLINE)) public var KmValueParameter.isNoinline: Boolean by valueParameterBooleanFlag(FlagImpl(ProtoFlags.IS_NOINLINE))
// --- EFFECT EXPRESSION --- // --- EFFECT EXPRESSION ---
@@ -464,7 +464,7 @@ public var KmValueParameter.isNoinline: Boolean by valueParameterBooleanFlag(Fla
* may change in a subsequent release. * may change in a subsequent release.
*/ */
@ExperimentalContracts @ExperimentalContracts
public var KmEffectExpression.isNegated: Boolean by BooleanFlagDelegate(KmEffectExpression::flags, Flag(ProtoFlags.IS_NEGATED)) public var KmEffectExpression.isNegated: Boolean by BooleanFlagDelegate(KmEffectExpression::flags, FlagImpl(ProtoFlags.IS_NEGATED))
/** /**
* Indicates that the corresponding effect expression checks whether a value of some variable is `null`. * Indicates that the corresponding effect expression checks whether a value of some variable is `null`.
@@ -473,4 +473,4 @@ public var KmEffectExpression.isNegated: Boolean by BooleanFlagDelegate(KmEffect
* may change in a subsequent release. * may change in a subsequent release.
*/ */
@ExperimentalContracts @ExperimentalContracts
public var KmEffectExpression.isNullCheckPredicate: Boolean by BooleanFlagDelegate(KmEffectExpression::flags, Flag(ProtoFlags.IS_NULL_CHECK_PREDICATE)) public var KmEffectExpression.isNullCheckPredicate: Boolean by BooleanFlagDelegate(KmEffectExpression::flags, FlagImpl(ProtoFlags.IS_NULL_CHECK_PREDICATE))
@@ -5,7 +5,7 @@
package kotlinx.metadata package kotlinx.metadata
import kotlinx.metadata.internal.FlagImpl import kotlinx.metadata.internal.IgnoreInApiDump
import org.jetbrains.kotlin.metadata.ProtoBuf.* import org.jetbrains.kotlin.metadata.ProtoBuf.*
import org.jetbrains.kotlin.metadata.ProtoBuf.Class.Kind as ClassKind import org.jetbrains.kotlin.metadata.ProtoBuf.Class.Kind as ClassKind
import org.jetbrains.kotlin.metadata.deserialization.Flags as F import org.jetbrains.kotlin.metadata.deserialization.Flags as F
@@ -43,17 +43,27 @@ private const val prefix = "Flag API is deprecated. Please use"
* @see Flags * @see Flags
* @see flagsOf * @see flagsOf
*/ */
@Deprecated("$prefix corresponding extensions on Km nodes, such as KmClass.visibility") @Deprecated("$prefix corresponding extensions on Km nodes, such as KmClass.visibility", level = DeprecationLevel.ERROR)
@Suppress("DEPRECATION") @Suppress("DEPRECATION_ERROR")
public abstract class Flag internal constructor() { 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. * Checks whether the flag is present in the given bitmask.
*/ */
public abstract operator fun invoke(flags: Int): Boolean public operator fun invoke(flags: Int): Boolean = (flags ushr offset) and ((1 shl bitWidth) - 1) == value
/** @suppress deprecated */ /** @suppress deprecated */
@Deprecated("$prefix corresponding extensions on Km nodes, such as KmClass.visibility") @Deprecated("$prefix corresponding extensions on Km nodes, such as KmClass.visibility", level = DeprecationLevel.ERROR)
public companion object Common { public companion object Common {
/** /**
* Signifies that the corresponding declaration has at least one annotation. * Signifies that the corresponding declaration has at least one annotation.
@@ -63,82 +73,82 @@ public abstract class Flag internal constructor() {
* reading annotations from the class file (which can be slow) in case when a declaration has no annotations. * reading annotations from the class file (which can be slow) in case when a declaration has no annotations.
*/ */
@JvmField @JvmField
@Deprecated("$prefix corresponding extension on a node, e.g. KmClass.hasAnnotations") @Deprecated("$prefix corresponding extension on a node, e.g. KmClass.hasAnnotations", level = DeprecationLevel.ERROR)
public val HAS_ANNOTATIONS: Flag = FlagImpl(F.HAS_ANNOTATIONS) public val HAS_ANNOTATIONS: Flag = Flag(F.HAS_ANNOTATIONS)
/** /**
* A visibility flag, signifying that the corresponding declaration is `internal`. * A visibility flag, signifying that the corresponding declaration is `internal`.
*/ */
@JvmField @JvmField
@Deprecated("$prefix visibility extension on a node, e.g. KmClass.visibility") @Deprecated("$prefix visibility extension on a node, e.g. KmClass.visibility", level = DeprecationLevel.ERROR)
public val IS_INTERNAL: Flag = FlagImpl(F.VISIBILITY, ProtoVisibility.INTERNAL_VALUE) public val IS_INTERNAL: Flag = Flag(F.VISIBILITY, ProtoVisibility.INTERNAL_VALUE)
/** /**
* A visibility flag, signifying that the corresponding declaration is `private`. * A visibility flag, signifying that the corresponding declaration is `private`.
*/ */
@JvmField @JvmField
@Deprecated("$prefix visibility extension on a node, e.g. KmClass.visibility") @Deprecated("$prefix visibility extension on a node, e.g. KmClass.visibility", level = DeprecationLevel.ERROR)
public val IS_PRIVATE: Flag = FlagImpl(F.VISIBILITY, ProtoVisibility.PRIVATE_VALUE) public val IS_PRIVATE: Flag = Flag(F.VISIBILITY, ProtoVisibility.PRIVATE_VALUE)
/** /**
* A visibility flag, signifying that the corresponding declaration is `protected`. * A visibility flag, signifying that the corresponding declaration is `protected`.
*/ */
@JvmField @JvmField
@Deprecated("$prefix visibility extension on a node, e.g. KmClass.visibility") @Deprecated("$prefix visibility extension on a node, e.g. KmClass.visibility", level = DeprecationLevel.ERROR)
public val IS_PROTECTED: Flag = FlagImpl(F.VISIBILITY, ProtoVisibility.PROTECTED_VALUE) public val IS_PROTECTED: Flag = Flag(F.VISIBILITY, ProtoVisibility.PROTECTED_VALUE)
/** /**
* A visibility flag, signifying that the corresponding declaration is `public`. * A visibility flag, signifying that the corresponding declaration is `public`.
*/ */
@JvmField @JvmField
@Deprecated("$prefix visibility extension on a node, e.g. KmClass.visibility") @Deprecated("$prefix visibility extension on a node, e.g. KmClass.visibility", level = DeprecationLevel.ERROR)
public val IS_PUBLIC: Flag = FlagImpl(F.VISIBILITY, ProtoVisibility.PUBLIC_VALUE) 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 * 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. * private members in Kotlin which are callable only on the same instance of the declaring class.
*/ */
@JvmField @JvmField
@Deprecated("$prefix visibility extension on a node, e.g. KmClass.visibility") @Deprecated("$prefix visibility extension on a node, e.g. KmClass.visibility", level = DeprecationLevel.ERROR)
public val IS_PRIVATE_TO_THIS: Flag = FlagImpl(F.VISIBILITY, ProtoVisibility.PRIVATE_TO_THIS_VALUE) 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 * A visibility flag, signifying that the corresponding declaration is local, i.e. declared inside a code block
* and not visible from the outside. * and not visible from the outside.
*/ */
@JvmField @JvmField
@Deprecated("$prefix visibility extension on a node, e.g. KmClass.visibility") @Deprecated("$prefix visibility extension on a node, e.g. KmClass.visibility", level = DeprecationLevel.ERROR)
public val IS_LOCAL: Flag = FlagImpl(F.VISIBILITY, ProtoVisibility.LOCAL_VALUE) public val IS_LOCAL: Flag = Flag(F.VISIBILITY, ProtoVisibility.LOCAL_VALUE)
/** /**
* A modality flag, signifying that the corresponding declaration is `final`. * A modality flag, signifying that the corresponding declaration is `final`.
*/ */
@JvmField @JvmField
@Deprecated("$prefix modality extension on a node, e.g. KmClass.modality or KmFunction.modality") @Deprecated("$prefix modality extension on a node, e.g. KmClass.modality or KmFunction.modality", level = DeprecationLevel.ERROR)
public val IS_FINAL: Flag = FlagImpl(F.MODALITY, ProtoModality.FINAL_VALUE) public val IS_FINAL: Flag = Flag(F.MODALITY, ProtoModality.FINAL_VALUE)
/** /**
* A modality flag, signifying that the corresponding declaration is `open`. * A modality flag, signifying that the corresponding declaration is `open`.
*/ */
@JvmField @JvmField
@Deprecated("$prefix modality extension on a node, e.g. KmClass.modality or KmFunction.modality") @Deprecated("$prefix modality extension on a node, e.g. KmClass.modality or KmFunction.modality", level = DeprecationLevel.ERROR)
public val IS_OPEN: Flag = FlagImpl(F.MODALITY, ProtoModality.OPEN_VALUE) public val IS_OPEN: Flag = Flag(F.MODALITY, ProtoModality.OPEN_VALUE)
/** /**
* A modality flag, signifying that the corresponding declaration is `abstract`. * A modality flag, signifying that the corresponding declaration is `abstract`.
*/ */
@JvmField @JvmField
@Deprecated("$prefix modality extension on a node, e.g. KmClass.modality or KmFunction.modality") @Deprecated("$prefix modality extension on a node, e.g. KmClass.modality or KmFunction.modality", level = DeprecationLevel.ERROR)
public val IS_ABSTRACT: Flag = FlagImpl(F.MODALITY, ProtoModality.ABSTRACT_VALUE) public val IS_ABSTRACT: Flag = Flag(F.MODALITY, ProtoModality.ABSTRACT_VALUE)
/** /**
* A modality flag, signifying that the corresponding declaration is `sealed`. * A modality flag, signifying that the corresponding declaration is `sealed`.
*/ */
@JvmField @JvmField
@Deprecated("$prefix modality extension on a node, e.g. KmClass.modality") @Deprecated("$prefix modality extension on a node, e.g. KmClass.modality", level = DeprecationLevel.ERROR)
public val IS_SEALED: Flag = FlagImpl(F.MODALITY, ProtoModality.SEALED_VALUE) public val IS_SEALED: Flag = Flag(F.MODALITY, ProtoModality.SEALED_VALUE)
} }
/** /**
@@ -148,85 +158,85 @@ public abstract class Flag internal constructor() {
* * class kind flags: [IS_CLASS], [IS_INTERFACE], [IS_ENUM_CLASS], [IS_ENUM_ENTRY], [IS_ANNOTATION_CLASS], [IS_OBJECT], * * class kind flags: [IS_CLASS], [IS_INTERFACE], [IS_ENUM_CLASS], [IS_ENUM_ENTRY], [IS_ANNOTATION_CLASS], [IS_OBJECT],
* [IS_COMPANION_OBJECT] * [IS_COMPANION_OBJECT]
*/ */
@Deprecated("$prefix corresponding extension on a KmClass") @Deprecated("$prefix corresponding extension on a KmClass", level = DeprecationLevel.ERROR)
public object Class { public object Class {
/** /**
* A class kind flag, signifying that the corresponding class is a usual `class`. * A class kind flag, signifying that the corresponding class is a usual `class`.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmClass.kind") @Deprecated("$prefix KmClass.kind", level = DeprecationLevel.ERROR)
public val IS_CLASS: Flag = FlagImpl(F.CLASS_KIND, ClassKind.CLASS_VALUE) public val IS_CLASS: Flag = Flag(F.CLASS_KIND, ClassKind.CLASS_VALUE)
/** /**
* A class kind flag, signifying that the corresponding class is an `interface`. * A class kind flag, signifying that the corresponding class is an `interface`.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmClass.kind") @Deprecated("$prefix KmClass.kind", level = DeprecationLevel.ERROR)
public val IS_INTERFACE: Flag = FlagImpl(F.CLASS_KIND, ClassKind.INTERFACE_VALUE) 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`. * A class kind flag, signifying that the corresponding class is an `enum class`.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmClass.kind") @Deprecated("$prefix KmClass.kind", level = DeprecationLevel.ERROR)
public val IS_ENUM_CLASS: Flag = FlagImpl(F.CLASS_KIND, ClassKind.ENUM_CLASS_VALUE) 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. * A class kind flag, signifying that the corresponding class is an enum entry.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmClass.kind") @Deprecated("$prefix KmClass.kind", level = DeprecationLevel.ERROR)
public val IS_ENUM_ENTRY: Flag = FlagImpl(F.CLASS_KIND, ClassKind.ENUM_ENTRY_VALUE) 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`. * A class kind flag, signifying that the corresponding class is an `annotation class`.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmClass.kind") @Deprecated("$prefix KmClass.kind", level = DeprecationLevel.ERROR)
public val IS_ANNOTATION_CLASS: Flag = FlagImpl(F.CLASS_KIND, ClassKind.ANNOTATION_CLASS_VALUE) 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`. * A class kind flag, signifying that the corresponding class is a non-companion `object`.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmClass.kind") @Deprecated("$prefix KmClass.kind", level = DeprecationLevel.ERROR)
public val IS_OBJECT: Flag = FlagImpl(F.CLASS_KIND, ClassKind.OBJECT_VALUE) 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`. * A class kind flag, signifying that the corresponding class is a `companion object`.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmClass.kind") @Deprecated("$prefix KmClass.kind", level = DeprecationLevel.ERROR)
public val IS_COMPANION_OBJECT: Flag = FlagImpl(F.CLASS_KIND, ClassKind.COMPANION_OBJECT_VALUE) public val IS_COMPANION_OBJECT: Flag = Flag(F.CLASS_KIND, ClassKind.COMPANION_OBJECT_VALUE)
/** /**
* Signifies that the corresponding class is `inner`. * Signifies that the corresponding class is `inner`.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmClass.isInner") @Deprecated("$prefix KmClass.isInner", level = DeprecationLevel.ERROR)
public val IS_INNER: Flag = FlagImpl(F.IS_INNER) public val IS_INNER: Flag = Flag(F.IS_INNER)
/** /**
* Signifies that the corresponding class is `data`. * Signifies that the corresponding class is `data`.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmClass.isData") @Deprecated("$prefix KmClass.isData", level = DeprecationLevel.ERROR)
public val IS_DATA: Flag = FlagImpl(F.IS_DATA) public val IS_DATA: Flag = Flag(F.IS_DATA)
/** /**
* Signifies that the corresponding class is `external`. * Signifies that the corresponding class is `external`.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmClass.isExternal") @Deprecated("$prefix KmClass.isExternal", level = DeprecationLevel.ERROR)
public val IS_EXTERNAL: Flag = FlagImpl(F.IS_EXTERNAL_CLASS) public val IS_EXTERNAL: Flag = Flag(F.IS_EXTERNAL_CLASS)
/** /**
* Signifies that the corresponding class is `expect`. * Signifies that the corresponding class is `expect`.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmClass.isExpect") @Deprecated("$prefix KmClass.isExpect", level = DeprecationLevel.ERROR)
public val IS_EXPECT: Flag = FlagImpl(F.IS_EXPECT_CLASS) public val IS_EXPECT: Flag = Flag(F.IS_EXPECT_CLASS)
@JvmField @JvmField
@Deprecated( @Deprecated(
@@ -234,29 +244,29 @@ public abstract class Flag internal constructor() {
level = DeprecationLevel.ERROR level = DeprecationLevel.ERROR
) )
@Suppress("unused") @Suppress("unused")
public val IS_INLINE: Flag = FlagImpl(F.IS_VALUE_CLASS) 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. * Signifies that the corresponding class is either a pre-Kotlin-1.5 `inline` class, or a 1.5+ `value` class.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmClass.isValue") @Deprecated("$prefix KmClass.isValue", level = DeprecationLevel.ERROR)
public val IS_VALUE: Flag = FlagImpl(F.IS_VALUE_CLASS) 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`. * Signifies that the corresponding class is a functional interface, i.e. marked with the keyword `fun`.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmClass.isFun") @Deprecated("$prefix KmClass.isFun", level = DeprecationLevel.ERROR)
public val IS_FUN: Flag = FlagImpl(F.IS_FUN_INTERFACE) public val IS_FUN: Flag = Flag(F.IS_FUN_INTERFACE)
/** /**
* Signifies that the corresponding enum class has ".entries" property in bytecode. * Signifies that the corresponding enum class has ".entries" property in bytecode.
* Always `false` for not enum classes. * Always `false` for not enum classes.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmClass.hasEnumEntries") @Deprecated("$prefix KmClass.hasEnumEntries", level = DeprecationLevel.ERROR)
public val HAS_ENUM_ENTRIES: Flag = FlagImpl(F.HAS_ENUM_ENTRIES) public val HAS_ENUM_ENTRIES: Flag = Flag(F.HAS_ENUM_ENTRIES)
} }
/** /**
@@ -266,21 +276,21 @@ public abstract class Flag internal constructor() {
@JvmField @JvmField
@Deprecated("Use IS_SECONDARY which holds inverted value instead.", level = DeprecationLevel.ERROR) @Deprecated("Use IS_SECONDARY which holds inverted value instead.", level = DeprecationLevel.ERROR)
@Suppress("unused") @Suppress("unused")
public val IS_PRIMARY: Flag = FlagImpl(F.IS_SECONDARY, 0) 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. * Signifies that the corresponding constructor is secondary, i.e. declared not in the class header, but in the class body.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmConstructor.isSecondary") @Deprecated("$prefix KmConstructor.isSecondary", level = DeprecationLevel.ERROR)
public val IS_SECONDARY: Flag = FlagImpl(F.IS_SECONDARY) 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. * Signifies that the corresponding constructor has non-stable parameter names, i.e. cannot be called with named arguments.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmConstructor.hasNonStableParameterNames") @Deprecated("$prefix KmConstructor.hasNonStableParameterNames", level = DeprecationLevel.ERROR)
public val HAS_NON_STABLE_PARAMETER_NAMES: Flag = FlagImpl(F.IS_CONSTRUCTOR_WITH_NON_STABLE_PARAMETER_NAMES) public val HAS_NON_STABLE_PARAMETER_NAMES: Flag = Flag(F.IS_CONSTRUCTOR_WITH_NON_STABLE_PARAMETER_NAMES)
} }
/** /**
@@ -294,88 +304,88 @@ public abstract class Flag internal constructor() {
* A member kind flag, signifying that the corresponding function is explicitly declared in the containing class. * A member kind flag, signifying that the corresponding function is explicitly declared in the containing class.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmFunction.kind") @Deprecated("$prefix KmFunction.kind", level = DeprecationLevel.ERROR)
public val IS_DECLARATION: Flag = FlagImpl(F.MEMBER_KIND, ProtoMemberKind.DECLARATION_VALUE) 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 * 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. * signature exists in a supertype. This flag is not written by the Kotlin compiler and its effects are unspecified.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmFunction.kind") @Deprecated("$prefix KmFunction.kind", level = DeprecationLevel.ERROR)
public val IS_FAKE_OVERRIDE: Flag = FlagImpl(F.MEMBER_KIND, ProtoMemberKind.FAKE_OVERRIDE_VALUE) 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 * A member kind flag, signifying that the corresponding function exists in the containing class because it has been produced
* by interface delegation (delegation "by"). * by interface delegation (delegation "by").
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmFunction.kind") @Deprecated("$prefix KmFunction.kind", level = DeprecationLevel.ERROR)
public val IS_DELEGATION: Flag = FlagImpl(F.MEMBER_KIND, ProtoMemberKind.DELEGATION_VALUE) 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 * 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. * by the compiler and has no declaration in the source code.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmFunction.kind") @Deprecated("$prefix KmFunction.kind", level = DeprecationLevel.ERROR)
public val IS_SYNTHESIZED: Flag = FlagImpl(F.MEMBER_KIND, ProtoMemberKind.SYNTHESIZED_VALUE) public val IS_SYNTHESIZED: Flag = Flag(F.MEMBER_KIND, ProtoMemberKind.SYNTHESIZED_VALUE)
/** /**
* Signifies that the corresponding function is `operator`. * Signifies that the corresponding function is `operator`.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmFunction.isOperator") @Deprecated("$prefix KmFunction.isOperator", level = DeprecationLevel.ERROR)
public val IS_OPERATOR: Flag = FlagImpl(F.IS_OPERATOR) public val IS_OPERATOR: Flag = Flag(F.IS_OPERATOR)
/** /**
* Signifies that the corresponding function is `infix`. * Signifies that the corresponding function is `infix`.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmFunction.isInfix") @Deprecated("$prefix KmFunction.isInfix", level = DeprecationLevel.ERROR)
public val IS_INFIX: Flag = FlagImpl(F.IS_INFIX) public val IS_INFIX: Flag = Flag(F.IS_INFIX)
/** /**
* Signifies that the corresponding function is `inline`. * Signifies that the corresponding function is `inline`.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmFunction.isInline") @Deprecated("$prefix KmFunction.isInline", level = DeprecationLevel.ERROR)
public val IS_INLINE: Flag = FlagImpl(F.IS_INLINE) public val IS_INLINE: Flag = Flag(F.IS_INLINE)
/** /**
* Signifies that the corresponding function is `tailrec`. * Signifies that the corresponding function is `tailrec`.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmFunction.isTailrec") @Deprecated("$prefix KmFunction.isTailrec", level = DeprecationLevel.ERROR)
public val IS_TAILREC: Flag = FlagImpl(F.IS_TAILREC) public val IS_TAILREC: Flag = Flag(F.IS_TAILREC)
/** /**
* Signifies that the corresponding function is `external`. * Signifies that the corresponding function is `external`.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmFunction.isExternalFunction") @Deprecated("$prefix KmFunction.isExternalFunction", level = DeprecationLevel.ERROR)
public val IS_EXTERNAL: Flag = FlagImpl(F.IS_EXTERNAL_FUNCTION) public val IS_EXTERNAL: Flag = Flag(F.IS_EXTERNAL_FUNCTION)
/** /**
* Signifies that the corresponding function is `suspend`. * Signifies that the corresponding function is `suspend`.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmFunction.isSuspend") @Deprecated("$prefix KmFunction.isSuspend", level = DeprecationLevel.ERROR)
public val IS_SUSPEND: Flag = FlagImpl(F.IS_SUSPEND) public val IS_SUSPEND: Flag = Flag(F.IS_SUSPEND)
/** /**
* Signifies that the corresponding function is `expect`. * Signifies that the corresponding function is `expect`.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmFunction.isExpectFunction") @Deprecated("$prefix KmFunction.isExpectFunction", level = DeprecationLevel.ERROR)
public val IS_EXPECT: Flag = FlagImpl(F.IS_EXPECT_FUNCTION) 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. * Signifies that the corresponding function has non-stable parameter names, i.e. cannot be called with named arguments.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmFunction.isFunctionWithNonStableParameterNames") @Deprecated("$prefix KmFunction.isFunctionWithNonStableParameterNames", level = DeprecationLevel.ERROR)
public val HAS_NON_STABLE_PARAMETER_NAMES: Flag = FlagImpl(F.IS_FUNCTION_WITH_NON_STABLE_PARAMETER_NAMES) public val HAS_NON_STABLE_PARAMETER_NAMES: Flag = Flag(F.IS_FUNCTION_WITH_NON_STABLE_PARAMETER_NAMES)
} }
/** /**
@@ -389,67 +399,67 @@ public abstract class Flag internal constructor() {
* A member kind flag, signifying that the corresponding property is explicitly declared in the containing class. * A member kind flag, signifying that the corresponding property is explicitly declared in the containing class.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmProperty.kind") @Deprecated("$prefix KmProperty.kind", level = DeprecationLevel.ERROR)
public val IS_DECLARATION: Flag = FlagImpl(F.MEMBER_KIND, ProtoMemberKind.DECLARATION_VALUE) 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 * 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. * signature exists in a supertype. This flag is not written by the Kotlin compiler and its effects are unspecified.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmProperty.kind") @Deprecated("$prefix KmProperty.kind", level = DeprecationLevel.ERROR)
public val IS_FAKE_OVERRIDE: Flag = FlagImpl(F.MEMBER_KIND, ProtoMemberKind.FAKE_OVERRIDE_VALUE) 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 * A member kind flag, signifying that the corresponding property exists in the containing class because it has been produced
* by interface delegation (delegation "by"). * by interface delegation (delegation "by").
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmProperty.kind") @Deprecated("$prefix KmProperty.kind", level = DeprecationLevel.ERROR)
public val IS_DELEGATION: Flag = FlagImpl(F.MEMBER_KIND, ProtoMemberKind.DELEGATION_VALUE) 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 * 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. * by the compiler and has no declaration in the source code.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmProperty.kind") @Deprecated("$prefix KmProperty.kind", level = DeprecationLevel.ERROR)
public val IS_SYNTHESIZED: Flag = FlagImpl(F.MEMBER_KIND, ProtoMemberKind.SYNTHESIZED_VALUE) public val IS_SYNTHESIZED: Flag = Flag(F.MEMBER_KIND, ProtoMemberKind.SYNTHESIZED_VALUE)
/** /**
* Signifies that the corresponding property is `var`. * Signifies that the corresponding property is `var`.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmProperty.isVar") @Deprecated("$prefix KmProperty.isVar", level = DeprecationLevel.ERROR)
public val IS_VAR: Flag = FlagImpl(F.IS_VAR) public val IS_VAR: Flag = Flag(F.IS_VAR)
/** /**
* Signifies that the corresponding property has a getter. * Signifies that the corresponding property has a getter.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmProperty.hasGetter") @Deprecated("$prefix KmProperty.hasGetter", level = DeprecationLevel.ERROR)
public val HAS_GETTER: Flag = FlagImpl(F.HAS_GETTER) public val HAS_GETTER: Flag = Flag(F.HAS_GETTER)
/** /**
* Signifies that the corresponding property has a setter. * Signifies that the corresponding property has a setter.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmProperty.hasSetter") @Deprecated("$prefix KmProperty.hasSetter", level = DeprecationLevel.ERROR)
public val HAS_SETTER: Flag = FlagImpl(F.HAS_SETTER) public val HAS_SETTER: Flag = Flag(F.HAS_SETTER)
/** /**
* Signifies that the corresponding property is `const`. * Signifies that the corresponding property is `const`.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmProperty.isConst") @Deprecated("$prefix KmProperty.isConst", level = DeprecationLevel.ERROR)
public val IS_CONST: Flag = FlagImpl(F.IS_CONST) public val IS_CONST: Flag = Flag(F.IS_CONST)
/** /**
* Signifies that the corresponding property is `lateinit`. * Signifies that the corresponding property is `lateinit`.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmProperty.isLateinit") @Deprecated("$prefix KmProperty.isLateinit", level = DeprecationLevel.ERROR)
public val IS_LATEINIT: Flag = FlagImpl(F.IS_LATEINIT) 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 * Signifies that the corresponding property has a constant value. On JVM, this flag allows an optimization similarly to
@@ -457,29 +467,29 @@ public abstract class Flag internal constructor() {
* reading the value from the bytecode in case there isn't one. * reading the value from the bytecode in case there isn't one.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmProperty.hasConstant") @Deprecated("$prefix KmProperty.hasConstant", level = DeprecationLevel.ERROR)
public val HAS_CONSTANT: Flag = FlagImpl(F.HAS_CONSTANT) public val HAS_CONSTANT: Flag = Flag(F.HAS_CONSTANT)
/** /**
* Signifies that the corresponding property is `external`. * Signifies that the corresponding property is `external`.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmProperty.isExternal") @Deprecated("$prefix KmProperty.isExternal", level = DeprecationLevel.ERROR)
public val IS_EXTERNAL: Flag = FlagImpl(F.IS_EXTERNAL_PROPERTY) public val IS_EXTERNAL: Flag = Flag(F.IS_EXTERNAL_PROPERTY)
/** /**
* Signifies that the corresponding property is a delegated property. * Signifies that the corresponding property is a delegated property.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmProperty.isDelegated") @Deprecated("$prefix KmProperty.isDelegated", level = DeprecationLevel.ERROR)
public val IS_DELEGATED: Flag = FlagImpl(F.IS_DELEGATED) public val IS_DELEGATED: Flag = Flag(F.IS_DELEGATED)
/** /**
* Signifies that the corresponding property is `expect`. * Signifies that the corresponding property is `expect`.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmProperty.isExpect") @Deprecated("$prefix KmProperty.isExpect", level = DeprecationLevel.ERROR)
public val IS_EXPECT: Flag = FlagImpl(F.IS_EXPECT_PROPERTY) public val IS_EXPECT: Flag = Flag(F.IS_EXPECT_PROPERTY)
} }
@@ -491,22 +501,22 @@ public abstract class Flag internal constructor() {
* Signifies that the corresponding property accessor is not default, i.e. it has a body and/or annotations in the source code. * Signifies that the corresponding property accessor is not default, i.e. it has a body and/or annotations in the source code.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmPropertyAccessorAttributes.isNotDefault") @Deprecated("$prefix KmPropertyAccessorAttributes.isNotDefault", level = DeprecationLevel.ERROR)
public val IS_NOT_DEFAULT: Flag = FlagImpl(F.IS_NOT_DEFAULT) public val IS_NOT_DEFAULT: Flag = Flag(F.IS_NOT_DEFAULT)
/** /**
* Signifies that the corresponding property accessor is `external`. * Signifies that the corresponding property accessor is `external`.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmPropertyAccessorAttributes.isExternal") @Deprecated("$prefix KmPropertyAccessorAttributes.isExternal", level = DeprecationLevel.ERROR)
public val IS_EXTERNAL: Flag = FlagImpl(F.IS_EXTERNAL_ACCESSOR) public val IS_EXTERNAL: Flag = Flag(F.IS_EXTERNAL_ACCESSOR)
/** /**
* Signifies that the corresponding property accessor is `inline`. * Signifies that the corresponding property accessor is `inline`.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmPropertyAccessorAttributes.isInline") @Deprecated("$prefix KmPropertyAccessorAttributes.isInline", level = DeprecationLevel.ERROR)
public val IS_INLINE: Flag = FlagImpl(F.IS_INLINE_ACCESSOR) public val IS_INLINE: Flag = Flag(F.IS_INLINE_ACCESSOR)
} }
/** /**
@@ -517,23 +527,23 @@ public abstract class Flag internal constructor() {
* Signifies that the corresponding type is marked as nullable, i.e. has a question mark at the end of its notation. * Signifies that the corresponding type is marked as nullable, i.e. has a question mark at the end of its notation.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmType.isNullable") @Deprecated("$prefix KmType.isNullable", level = DeprecationLevel.ERROR)
public val IS_NULLABLE: Flag = FlagImpl(0, 1, 1) public val IS_NULLABLE: Flag = Flag(0, 1, 1)
/** /**
* Signifies that the corresponding type is `suspend`. * Signifies that the corresponding type is `suspend`.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmType.isSuspend") @Deprecated("$prefix KmType.isSuspend", level = DeprecationLevel.ERROR)
public val IS_SUSPEND: Flag = FlagImpl(F.SUSPEND_TYPE.offset + 1, F.SUSPEND_TYPE.bitWidth, 1) public val IS_SUSPEND: Flag = Flag(F.SUSPEND_TYPE.offset + 1, F.SUSPEND_TYPE.bitWidth, 1)
/** /**
* Signifies that the corresponding type is * Signifies that the corresponding type is
* [definitely non-null](https://kotlinlang.org/docs/whatsnew17.html#stable-definitely-non-nullable-types). * [definitely non-null](https://kotlinlang.org/docs/whatsnew17.html#stable-definitely-non-nullable-types).
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmType.isDefinitelyNonNull") @Deprecated("$prefix KmType.isDefinitelyNonNull", level = DeprecationLevel.ERROR)
public val IS_DEFINITELY_NON_NULL: Flag = FlagImpl(F.DEFINITELY_NOT_NULL_TYPE.offset + 1, F.DEFINITELY_NOT_NULL_TYPE.bitWidth, 1) public val IS_DEFINITELY_NON_NULL: Flag = Flag(F.DEFINITELY_NOT_NULL_TYPE.offset + 1, F.DEFINITELY_NOT_NULL_TYPE.bitWidth, 1)
} }
/** /**
@@ -544,8 +554,8 @@ public abstract class Flag internal constructor() {
* Signifies that the corresponding type parameter is `reified`. * Signifies that the corresponding type parameter is `reified`.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmTypeParameter.isReified") @Deprecated("$prefix KmTypeParameter.isReified", level = DeprecationLevel.ERROR)
public val IS_REIFIED: Flag = FlagImpl(0, 1, 1) public val IS_REIFIED: Flag = Flag(0, 1, 1)
} }
/** /**
@@ -559,22 +569,22 @@ public abstract class Flag internal constructor() {
* still optional at the call site because the default value from the base method is used. * still optional at the call site because the default value from the base method is used.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmValueParameter.declaresDefaultValue") @Deprecated("$prefix KmValueParameter.declaresDefaultValue", level = DeprecationLevel.ERROR)
public val DECLARES_DEFAULT_VALUE: Flag = FlagImpl(F.DECLARES_DEFAULT_VALUE) public val DECLARES_DEFAULT_VALUE: Flag = Flag(F.DECLARES_DEFAULT_VALUE)
/** /**
* Signifies that the corresponding value parameter is `crossinline`. * Signifies that the corresponding value parameter is `crossinline`.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmValueParameter.isCrossinline") @Deprecated("$prefix KmValueParameter.isCrossinline", level = DeprecationLevel.ERROR)
public val IS_CROSSINLINE: Flag = FlagImpl(F.IS_CROSSINLINE) public val IS_CROSSINLINE: Flag = Flag(F.IS_CROSSINLINE)
/** /**
* Signifies that the corresponding value parameter is `noinline`. * Signifies that the corresponding value parameter is `noinline`.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmValueParameter.isNoinline") @Deprecated("$prefix KmValueParameter.isNoinline", level = DeprecationLevel.ERROR)
public val IS_NOINLINE: Flag = FlagImpl(F.IS_NOINLINE) public val IS_NOINLINE: Flag = Flag(F.IS_NOINLINE)
} }
/** /**
@@ -588,14 +598,14 @@ public abstract class Flag internal constructor() {
* Signifies that the corresponding effect expression should be negated to compute the proposition or the conclusion of an effect. * Signifies that the corresponding effect expression should be negated to compute the proposition or the conclusion of an effect.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmEffectExpression.isNegated") @Deprecated("$prefix KmEffectExpression.isNegated", level = DeprecationLevel.ERROR)
public val IS_NEGATED: Flag = FlagImpl(F.IS_NEGATED) public val IS_NEGATED: Flag = Flag(F.IS_NEGATED)
/** /**
* Signifies that the corresponding effect expression checks whether a value of some variable is `null`. * Signifies that the corresponding effect expression checks whether a value of some variable is `null`.
*/ */
@JvmField @JvmField
@Deprecated("$prefix KmEffectExpression.isNullCheckPredicate") @Deprecated("$prefix KmEffectExpression.isNullCheckPredicate", level = DeprecationLevel.ERROR)
public val IS_NULL_CHECK_PREDICATE: Flag = FlagImpl(F.IS_NULL_CHECK_PREDICATE) public val IS_NULL_CHECK_PREDICATE: Flag = Flag(F.IS_NULL_CHECK_PREDICATE)
} }
} }
@@ -16,7 +16,8 @@ import kotlinx.metadata.internal.FlagImpl
*/ */
@Deprecated( @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", "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") ReplaceWith("Int"),
DeprecationLevel.ERROR
) )
public typealias Flags = Int public typealias Flags = Int
@@ -27,9 +28,10 @@ public typealias Flags = Int
* hold the value of the latest flag. For example, `flagsOf(Flag.IS_PRIVATE, Flag.IS_PUBLIC, Flag.IS_INTERNAL)` is the same as * 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)`. * `flagsOf(Flag.IS_INTERNAL)`.
*/ */
@Suppress("DEPRECATION") @Suppress("DEPRECATION_ERROR")
@Deprecated( @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", "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 = public fun flagsOf(vararg flags: Flag): Int =
flags.fold(0) { acc, flag -> (flag as FlagImpl) + acc } flags.fold(0) { acc, flag -> flag + acc }
@@ -5,7 +5,7 @@
package kotlinx.metadata package kotlinx.metadata
import kotlinx.metadata.internal.Flag import kotlinx.metadata.internal.FlagImpl
import org.jetbrains.kotlin.metadata.deserialization.Flags as ProtoFlags import org.jetbrains.kotlin.metadata.deserialization.Flags as ProtoFlags
import org.jetbrains.kotlin.metadata.ProtoBuf.Class.Kind as ProtoClassKind import org.jetbrains.kotlin.metadata.ProtoBuf.Class.Kind as ProtoClassKind
import org.jetbrains.kotlin.metadata.ProtoBuf.Visibility as ProtoVisibility import org.jetbrains.kotlin.metadata.ProtoBuf.Visibility as ProtoVisibility
@@ -71,7 +71,7 @@ public enum class Visibility(kind: Int) {
LOCAL(ProtoVisibility.LOCAL_VALUE) LOCAL(ProtoVisibility.LOCAL_VALUE)
; ;
internal val flag = Flag(ProtoFlags.VISIBILITY, kind) internal val flag = FlagImpl(ProtoFlags.VISIBILITY, kind)
} }
/** /**
@@ -104,7 +104,7 @@ public enum class Modality(kind: Int) {
SEALED(ProtoModality.SEALED_VALUE) SEALED(ProtoModality.SEALED_VALUE)
; ;
internal val flag = Flag(ProtoFlags.MODALITY, kind) internal val flag = FlagImpl(ProtoFlags.MODALITY, kind)
} }
/** /**
@@ -147,7 +147,7 @@ public enum class ClassKind(kind: Int) {
COMPANION_OBJECT(ProtoClassKind.COMPANION_OBJECT_VALUE) COMPANION_OBJECT(ProtoClassKind.COMPANION_OBJECT_VALUE)
; ;
internal val flag = Flag(ProtoFlags.CLASS_KIND, kind) internal val flag = FlagImpl(ProtoFlags.CLASS_KIND, kind)
} }
/** /**
@@ -187,5 +187,5 @@ public enum class MemberKind(kind: Int) {
SYNTHESIZED(ProtoMemberKind.SYNTHESIZED_VALUE) SYNTHESIZED(ProtoMemberKind.SYNTHESIZED_VALUE)
; ;
internal val flag = Flag(ProtoFlags.MEMBER_KIND, kind) internal val flag = FlagImpl(ProtoFlags.MEMBER_KIND, kind)
} }
@@ -7,9 +7,8 @@
package kotlinx.metadata package kotlinx.metadata
import kotlinx.metadata.internal.Flag import kotlinx.metadata.internal.FlagImpl
import kotlinx.metadata.internal.extensions.* import kotlinx.metadata.internal.extensions.*
import kotlinx.metadata.internal.getDefaultPropertyAccessorFlags
import kotlinx.metadata.internal.propertyBooleanFlag import kotlinx.metadata.internal.propertyBooleanFlag
import org.jetbrains.kotlin.metadata.deserialization.Flags import org.jetbrains.kotlin.metadata.deserialization.Flags
import kotlin.contracts.ExperimentalContracts import kotlin.contracts.ExperimentalContracts
@@ -46,7 +45,7 @@ public class KmClass : KmClassVisitor(), KmDeclarationContainer {
/** /**
* Class flags, consisting of [Flag.HAS_ANNOTATIONS], visibility flag, modality flag and [Flag.Class] flags. * Class flags, consisting of [Flag.HAS_ANNOTATIONS], visibility flag, modality flag and [Flag.Class] flags.
*/ */
@Deprecated("$flagAccessPrefix KmClass, such as KmClass.visibility") @Deprecated("$flagAccessPrefix KmClass, such as KmClass.visibility", level = DeprecationLevel.ERROR)
public var flags: Int = 0 public var flags: Int = 0
/** /**
@@ -317,8 +316,8 @@ public class KmLambda : KmLambdaVisitor() {
* such as [KmConstructor.visibility] or [KmConstructor.isSecondary]. * such as [KmConstructor.visibility] or [KmConstructor.isSecondary].
*/ */
@Suppress("DEPRECATION", "DEPRECATION_ERROR") @Suppress("DEPRECATION", "DEPRECATION_ERROR")
public class KmConstructor @Deprecated(flagsCtorDeprecated) constructor( public class KmConstructor @Deprecated(flagsCtorDeprecated, level = DeprecationLevel.ERROR) constructor(
@Deprecated("$flagAccessPrefix KmConstructor, such as KmConstructor.visibility") public var flags: Int, @Deprecated("$flagAccessPrefix KmConstructor, such as KmConstructor.visibility", level = DeprecationLevel.ERROR) public var flags: Int,
) : ) :
KmConstructorVisitor() { KmConstructorVisitor() {
public constructor() : this(0) public constructor() : this(0)
@@ -371,8 +370,8 @@ public class KmConstructor @Deprecated(flagsCtorDeprecated) constructor(
* @property name the name of the function * @property name the name of the function
*/ */
@Suppress("DEPRECATION", "DEPRECATION_ERROR") @Suppress("DEPRECATION", "DEPRECATION_ERROR")
public class KmFunction @Deprecated(flagsCtorDeprecated) constructor( public class KmFunction @Deprecated(flagsCtorDeprecated, level = DeprecationLevel.ERROR) constructor(
@Deprecated("$flagAccessPrefix KmFunction, such as KmFunction.visibility") public var flags: Int, @Deprecated("$flagAccessPrefix KmFunction, such as KmFunction.visibility", level = DeprecationLevel.ERROR) public var flags: Int,
public var name: String, public var name: String,
) : KmFunctionVisitor() { ) : KmFunctionVisitor() {
@@ -493,8 +492,8 @@ public class KmPropertyAccessorAttributes internal constructor(internal var flag
* @property name the name of the property * @property name the name of the property
*/ */
@Suppress("DEPRECATION", "DEPRECATION_ERROR") @Suppress("DEPRECATION", "DEPRECATION_ERROR")
public class KmProperty @Deprecated(flagsCtorDeprecated) constructor( public class KmProperty @Deprecated(flagsCtorDeprecated, level = DeprecationLevel.ERROR) constructor(
@Deprecated("$flagAccessPrefix KmProperty, such as KmProperty.visibility") public var flags: Int, @Deprecated("$flagAccessPrefix KmProperty, such as KmProperty.visibility", level = DeprecationLevel.ERROR) public var flags: Int,
public var name: String, public var name: String,
getterFlags: Int, getterFlags: Int,
setterFlags: Int, setterFlags: Int,
@@ -503,8 +502,8 @@ public class KmProperty @Deprecated(flagsCtorDeprecated) constructor(
public constructor(name: String) : this(0, name, 0, 0) public constructor(name: String) : this(0, name, 0, 0)
// needed for reading/writing flags back to protobuf as a whole pack // needed for reading/writing flags back to protobuf as a whole pack
private var _hasSetter: Boolean by propertyBooleanFlag(Flag(Flags.HAS_SETTER)) private var _hasSetter: Boolean by propertyBooleanFlag(FlagImpl(Flags.HAS_SETTER))
private var _hasGetter: Boolean by propertyBooleanFlag(Flag(Flags.HAS_GETTER)) private var _hasGetter: Boolean by propertyBooleanFlag(FlagImpl(Flags.HAS_GETTER))
/** /**
* Attributes of the getter of this property. * Attributes of the getter of this property.
@@ -534,7 +533,7 @@ public class KmProperty @Deprecated(flagsCtorDeprecated) constructor(
* Property accessor flags, consisting of [Flag.HAS_ANNOTATIONS], visibility flag, modality flag * Property accessor flags, consisting of [Flag.HAS_ANNOTATIONS], visibility flag, modality flag
* and [Flag.PropertyAccessor] flags. * and [Flag.PropertyAccessor] flags.
*/ */
@Deprecated("$flagAccessPrefix KmProperty.getter, such as KmProperty.getter.isNotDefault") @Deprecated("$flagAccessPrefix KmProperty.getter, such as KmProperty.getter.isNotDefault", level = DeprecationLevel.ERROR)
public var getterFlags: Int public var getterFlags: Int
get() = getter.flags get() = getter.flags
set(value) { set(value) {
@@ -555,7 +554,7 @@ public class KmProperty @Deprecated(flagsCtorDeprecated) constructor(
* Setting this property when setter is absent changes the value, but does not create new [setter]. * 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. * This behavior is for compatibility only and will be removed in future versions.
*/ */
@Deprecated("$flagAccessPrefix KmProperty.setter, such as KmProperty.setter.isNotDefault") @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 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 get() = setter?.flags ?: field
set(value) { set(value) {
@@ -662,8 +661,8 @@ public class KmProperty @Deprecated(flagsCtorDeprecated) constructor(
* @property name the name of the type alias * @property name the name of the type alias
*/ */
@Suppress("DEPRECATION", "DEPRECATION_ERROR") @Suppress("DEPRECATION", "DEPRECATION_ERROR")
public class KmTypeAlias @Deprecated(flagsCtorDeprecated) constructor( public class KmTypeAlias @Deprecated(flagsCtorDeprecated, level = DeprecationLevel.ERROR) constructor(
@Deprecated("$flagAccessPrefix KmTypeAlias, such as KmTypeAlias.visibility") public var flags: Int, @Deprecated("$flagAccessPrefix KmTypeAlias, such as KmTypeAlias.visibility", level = DeprecationLevel.ERROR) public var flags: Int,
public var name: String, public var name: String,
) : KmTypeAliasVisitor() { ) : KmTypeAliasVisitor() {
@@ -749,8 +748,11 @@ public class KmTypeAlias @Deprecated(flagsCtorDeprecated) constructor(
* @property name the name of the value parameter * @property name the name of the value parameter
*/ */
@Suppress("DEPRECATION", "DEPRECATION_ERROR") @Suppress("DEPRECATION", "DEPRECATION_ERROR")
public class KmValueParameter @Deprecated(flagsCtorDeprecated) constructor( public class KmValueParameter @Deprecated(flagsCtorDeprecated, level = DeprecationLevel.ERROR) constructor(
@Deprecated("$flagAccessPrefix KmValueParameter, such as KmValueParameter.declaresDefaultValue") public var flags: Int, @Deprecated(
"$flagAccessPrefix KmValueParameter, such as KmValueParameter.declaresDefaultValue",
level = DeprecationLevel.ERROR
) public var flags: Int,
public var name: String, public var name: String,
) : KmValueParameterVisitor() { ) : KmValueParameterVisitor() {
@@ -808,8 +810,11 @@ public class KmValueParameter @Deprecated(flagsCtorDeprecated) constructor(
* @property variance the declaration-site variance of the type parameter * @property variance the declaration-site variance of the type parameter
*/ */
@Suppress("DEPRECATION", "DEPRECATION_ERROR") @Suppress("DEPRECATION", "DEPRECATION_ERROR")
public class KmTypeParameter @Deprecated(flagsCtorDeprecated) constructor( public class KmTypeParameter @Deprecated(flagsCtorDeprecated, level = DeprecationLevel.ERROR) constructor(
@Deprecated("$flagAccessPrefix KmTypeParameter, such as KmTypeParameter.isReified") public var flags: Int, @Deprecated(
"$flagAccessPrefix KmTypeParameter, such as KmTypeParameter.isReified",
level = DeprecationLevel.ERROR
) public var flags: Int,
public var name: String, public var name: String,
public var id: Int, public var id: Int,
public var variance: KmVariance, public var variance: KmVariance,
@@ -853,8 +858,8 @@ public class KmTypeParameter @Deprecated(flagsCtorDeprecated) constructor(
* such as [KmType.isNullable]. * such as [KmType.isNullable].
*/ */
@Suppress("DEPRECATION", "DEPRECATION_ERROR") @Suppress("DEPRECATION", "DEPRECATION_ERROR")
public class KmType @Deprecated(flagsCtorDeprecated) constructor( public class KmType @Deprecated(flagsCtorDeprecated, level = DeprecationLevel.ERROR) constructor(
@Deprecated("$flagAccessPrefix KmType, such as KmType.isNullable") public var flags: Int @Deprecated("$flagAccessPrefix KmType, such as KmType.isNullable", level = DeprecationLevel.ERROR) public var flags: Int,
) : KmTypeVisitor() { ) : KmTypeVisitor() {
public constructor() : this(0) public constructor() : this(0)
@@ -1124,7 +1129,7 @@ public class KmEffectExpression : KmEffectExpressionVisitor() {
/** /**
* Effect expression flags, consisting of [Flag.EffectExpression] flags. * Effect expression flags, consisting of [Flag.EffectExpression] flags.
*/ */
@Deprecated("$flagAccessPrefix KmEffectExpression, such as KmEffectExpression.isNegated") @Deprecated("$flagAccessPrefix KmEffectExpression, such as KmEffectExpression.isNegated", level = DeprecationLevel.ERROR)
public var flags: Int = flagsOf() public var flags: Int = flagsOf()
/** /**
@@ -2,7 +2,7 @@
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. * 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. * 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") @file:Suppress("DEPRECATION_ERROR") // flags will become internal eventually
package kotlinx.metadata.internal package kotlinx.metadata.internal
@@ -7,7 +7,7 @@ package kotlinx.metadata.internal
import org.jetbrains.kotlin.metadata.deserialization.Flags as F import org.jetbrains.kotlin.metadata.deserialization.Flags as F
public class FlagImpl(internal val offset: Int, internal val bitWidth: Int, internal val value: Int) : @Suppress("DEPRECATION") kotlinx.metadata.Flag() { public class FlagImpl(internal val offset: Int, internal val bitWidth: Int, internal val value: Int) {
@IgnoreInApiDump @IgnoreInApiDump
internal constructor(field: F.FlagField<*>, value: Int) : this(field.offset, field.bitWidth, value) internal constructor(field: F.FlagField<*>, value: Int) : this(field.offset, field.bitWidth, value)
@@ -17,8 +17,5 @@ public class FlagImpl(internal val offset: Int, internal val bitWidth: Int, inte
internal operator fun plus(flags: Int): Int = internal operator fun plus(flags: Int): Int =
(flags and (((1 shl bitWidth) - 1) shl offset).inv()) + (value shl offset) (flags and (((1 shl bitWidth) - 1) shl offset).inv()) + (value shl offset)
override operator fun invoke(flags: Int): Boolean = (flags ushr offset) and ((1 shl bitWidth) - 1) == value public operator fun invoke(flags: Int): Boolean = (flags ushr offset) and ((1 shl bitWidth) - 1) == value
} }
internal fun Flag(field: F.FlagField<*>, value: Int): FlagImpl = FlagImpl(field, value)
internal fun Flag(field: F.BooleanFlagField): FlagImpl = FlagImpl(field)
@@ -2,7 +2,7 @@
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. * 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. * 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") // flags @file:Suppress("DEPRECATION_ERROR") // flags will become internal eventually
package kotlinx.metadata.internal package kotlinx.metadata.internal
@@ -2,7 +2,7 @@
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2022 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. * 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") // flags @file:Suppress("DEPRECATION_ERROR") // flags will become internal eventually
package kotlinx.metadata.internal package kotlinx.metadata.internal
import kotlinx.metadata.* import kotlinx.metadata.*