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 class kotlinx/metadata/Flag {
public final class kotlinx/metadata/Flag {
public static final field Common Lkotlinx/metadata/Flag$Common;
public static final field HAS_ANNOTATIONS 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_PUBLIC 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 {
@@ -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.
*/
@file:Suppress("DEPRECATION")
@file:Suppress("DEPRECATION_ERROR") // flags will become internal eventually
@file:JvmName("JvmAttributes")
package kotlinx.metadata.jvm
@@ -45,7 +45,10 @@ public var KmClass.anonymousObjectOriginName: String?
/**
* 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
get() = jvm.jvmFlags
set(value) {
@@ -97,7 +100,10 @@ public var KmFunction.lambdaClassOriginName: String?
/**
* 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
get() = jvm.jvmFlags
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.
*/
@file:Suppress("DEPRECATION")
@file:Suppress("DEPRECATION_ERROR")
package kotlinx.metadata.jvm
import kotlinx.metadata.Flag
import kotlinx.metadata.internal.FlagImpl
import org.jetbrains.kotlin.metadata.deserialization.Flags as F
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 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 {
/**
* 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 {
/**
* 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.
*/
@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)
}
/**
* 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 {
/**
* Applied to an interface compiled with -Xjvm-default=all or all-compatibility.
@@ -51,7 +50,7 @@ public object JvmFlag {
* class.
*/
@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)
/**
@@ -62,10 +61,10 @@ public object JvmFlag {
* clients compiled without all-compatibility.
*/
@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)
}
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.test.*
@Suppress("DEPRECATION")
@Suppress("DEPRECATION", "DEPRECATION_ERROR") // flags will become internal eventually
class FlagDelegatesTest {
private class Private
@@ -30,7 +30,7 @@ class MetadataSmokeTest {
val classMetadata = L::class.java.readMetadataAsKmClass()
val inlineFunctions = classMetadata.functions
.filter { Flag.Function.IS_INLINE(it.flags) }
.filter { it.isInline }
.mapNotNull { it.signature?.toString() }
assertEquals(
@@ -146,6 +146,7 @@ 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) {
@@ -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.
* 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
* (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.
*/
@file:Suppress("DEPRECATION")
@file:Suppress("DEPRECATION_ERROR") // flags will become internal eventually
@file:JvmName("Attributes")
package kotlinx.metadata
@@ -127,23 +127,23 @@ public var KmClass.kind: ClassKind by EnumFlagDelegate(
/**
* 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`.
* 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`.
*/
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`.
*/
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.
@@ -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.
* 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`.
*
* 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.
@@ -166,7 +166,7 @@ public var KmClass.isFunInterface: Boolean by classBooleanFlag(Flag(ProtoFlags.I
* Always `false` if [KmClass.kind] is not an enum.
* 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 ---
@@ -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.
*/
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.
@@ -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.
* 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 ---
@@ -221,37 +221,37 @@ public var KmFunction.modality: Modality by modalityDelegate(KmFunction::flags)
/**
* 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`.
*/
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`.
*/
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`.
*/
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`.
*/
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`.
*/
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`.
*/
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.
@@ -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.
* 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 ---
@@ -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.
*/
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.
*/
@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.
*/
@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`.
*/
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`.
*/
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
@@ -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`.
*/
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.
@@ -351,12 +351,12 @@ public var KmProperty.isExternal: Boolean by propertyBooleanFlag(Flag(ProtoFlags
* Not to be confused with interface delegation.
* 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`.
*/
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 ---
@@ -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,
* 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`.
*/
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`.
*/
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
@@ -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
* 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`.
*/
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`.
*/
public var KmValueParameter.isNoinline: Boolean by valueParameterBooleanFlag(Flag(ProtoFlags.IS_NOINLINE))
public var KmValueParameter.isNoinline: Boolean by valueParameterBooleanFlag(FlagImpl(ProtoFlags.IS_NOINLINE))
// --- EFFECT EXPRESSION ---
@@ -464,7 +464,7 @@ public var KmValueParameter.isNoinline: Boolean by valueParameterBooleanFlag(Fla
* may change in a subsequent release.
*/
@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`.
@@ -473,4 +473,4 @@ public var KmEffectExpression.isNegated: Boolean by BooleanFlagDelegate(KmEffect
* may change in a subsequent release.
*/
@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
import kotlinx.metadata.internal.FlagImpl
import kotlinx.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
@@ -43,17 +43,27 @@ private const val prefix = "Flag API is deprecated. Please use"
* @see Flags
* @see flagsOf
*/
@Deprecated("$prefix corresponding extensions on Km nodes, such as KmClass.visibility")
@Suppress("DEPRECATION")
public abstract class Flag internal constructor() {
@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 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 */
@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 {
/**
* 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.
*/
@JvmField
@Deprecated("$prefix corresponding extension on a node, e.g. KmClass.hasAnnotations")
public val HAS_ANNOTATIONS: Flag = FlagImpl(F.HAS_ANNOTATIONS)
@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")
public val IS_INTERNAL: Flag = FlagImpl(F.VISIBILITY, ProtoVisibility.INTERNAL_VALUE)
@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")
public val IS_PRIVATE: Flag = FlagImpl(F.VISIBILITY, ProtoVisibility.PRIVATE_VALUE)
@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")
public val IS_PROTECTED: Flag = FlagImpl(F.VISIBILITY, ProtoVisibility.PROTECTED_VALUE)
@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")
public val IS_PUBLIC: Flag = FlagImpl(F.VISIBILITY, ProtoVisibility.PUBLIC_VALUE)
@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")
public val IS_PRIVATE_TO_THIS: Flag = FlagImpl(F.VISIBILITY, ProtoVisibility.PRIVATE_TO_THIS_VALUE)
@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")
public val IS_LOCAL: Flag = FlagImpl(F.VISIBILITY, ProtoVisibility.LOCAL_VALUE)
@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")
public val IS_FINAL: Flag = FlagImpl(F.MODALITY, ProtoModality.FINAL_VALUE)
@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")
public val IS_OPEN: Flag = FlagImpl(F.MODALITY, ProtoModality.OPEN_VALUE)
@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")
public val IS_ABSTRACT: Flag = FlagImpl(F.MODALITY, ProtoModality.ABSTRACT_VALUE)
@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")
public val IS_SEALED: Flag = FlagImpl(F.MODALITY, ProtoModality.SEALED_VALUE)
@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)
}
/**
@@ -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],
* [IS_COMPANION_OBJECT]
*/
@Deprecated("$prefix corresponding extension on a KmClass")
@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")
public val IS_CLASS: Flag = FlagImpl(F.CLASS_KIND, ClassKind.CLASS_VALUE)
@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")
public val IS_INTERFACE: Flag = FlagImpl(F.CLASS_KIND, ClassKind.INTERFACE_VALUE)
@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")
public val IS_ENUM_CLASS: Flag = FlagImpl(F.CLASS_KIND, ClassKind.ENUM_CLASS_VALUE)
@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")
public val IS_ENUM_ENTRY: Flag = FlagImpl(F.CLASS_KIND, ClassKind.ENUM_ENTRY_VALUE)
@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")
public val IS_ANNOTATION_CLASS: Flag = FlagImpl(F.CLASS_KIND, ClassKind.ANNOTATION_CLASS_VALUE)
@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")
public val IS_OBJECT: Flag = FlagImpl(F.CLASS_KIND, ClassKind.OBJECT_VALUE)
@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")
public val IS_COMPANION_OBJECT: Flag = FlagImpl(F.CLASS_KIND, ClassKind.COMPANION_OBJECT_VALUE)
@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")
public val IS_INNER: Flag = FlagImpl(F.IS_INNER)
@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")
public val IS_DATA: Flag = FlagImpl(F.IS_DATA)
@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")
public val IS_EXTERNAL: Flag = FlagImpl(F.IS_EXTERNAL_CLASS)
@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")
public val IS_EXPECT: Flag = FlagImpl(F.IS_EXPECT_CLASS)
@Deprecated("$prefix KmClass.isExpect", level = DeprecationLevel.ERROR)
public val IS_EXPECT: Flag = Flag(F.IS_EXPECT_CLASS)
@JvmField
@Deprecated(
@@ -234,29 +244,29 @@ public abstract class Flag internal constructor() {
level = DeprecationLevel.ERROR
)
@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.
*/
@JvmField
@Deprecated("$prefix KmClass.isValue")
public val IS_VALUE: Flag = FlagImpl(F.IS_VALUE_CLASS)
@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")
public val IS_FUN: Flag = FlagImpl(F.IS_FUN_INTERFACE)
@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")
public val HAS_ENUM_ENTRIES: Flag = FlagImpl(F.HAS_ENUM_ENTRIES)
@Deprecated("$prefix KmClass.hasEnumEntries", level = DeprecationLevel.ERROR)
public val HAS_ENUM_ENTRIES: Flag = Flag(F.HAS_ENUM_ENTRIES)
}
/**
@@ -266,21 +276,21 @@ public abstract class Flag internal constructor() {
@JvmField
@Deprecated("Use IS_SECONDARY which holds inverted value instead.", level = DeprecationLevel.ERROR)
@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.
*/
@JvmField
@Deprecated("$prefix KmConstructor.isSecondary")
public val IS_SECONDARY: Flag = FlagImpl(F.IS_SECONDARY)
@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")
public val HAS_NON_STABLE_PARAMETER_NAMES: Flag = FlagImpl(F.IS_CONSTRUCTOR_WITH_NON_STABLE_PARAMETER_NAMES)
@Deprecated("$prefix KmConstructor.hasNonStableParameterNames", level = DeprecationLevel.ERROR)
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.
*/
@JvmField
@Deprecated("$prefix KmFunction.kind")
public val IS_DECLARATION: Flag = FlagImpl(F.MEMBER_KIND, ProtoMemberKind.DECLARATION_VALUE)
@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")
public val IS_FAKE_OVERRIDE: Flag = FlagImpl(F.MEMBER_KIND, ProtoMemberKind.FAKE_OVERRIDE_VALUE)
@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")
public val IS_DELEGATION: Flag = FlagImpl(F.MEMBER_KIND, ProtoMemberKind.DELEGATION_VALUE)
@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")
public val IS_SYNTHESIZED: Flag = FlagImpl(F.MEMBER_KIND, ProtoMemberKind.SYNTHESIZED_VALUE)
@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")
public val IS_OPERATOR: Flag = FlagImpl(F.IS_OPERATOR)
@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")
public val IS_INFIX: Flag = FlagImpl(F.IS_INFIX)
@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")
public val IS_INLINE: Flag = FlagImpl(F.IS_INLINE)
@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")
public val IS_TAILREC: Flag = FlagImpl(F.IS_TAILREC)
@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")
public val IS_EXTERNAL: Flag = FlagImpl(F.IS_EXTERNAL_FUNCTION)
@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")
public val IS_SUSPEND: Flag = FlagImpl(F.IS_SUSPEND)
@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")
public val IS_EXPECT: Flag = FlagImpl(F.IS_EXPECT_FUNCTION)
@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")
public val HAS_NON_STABLE_PARAMETER_NAMES: Flag = FlagImpl(F.IS_FUNCTION_WITH_NON_STABLE_PARAMETER_NAMES)
@Deprecated("$prefix KmFunction.isFunctionWithNonStableParameterNames", level = DeprecationLevel.ERROR)
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.
*/
@JvmField
@Deprecated("$prefix KmProperty.kind")
public val IS_DECLARATION: Flag = FlagImpl(F.MEMBER_KIND, ProtoMemberKind.DECLARATION_VALUE)
@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")
public val IS_FAKE_OVERRIDE: Flag = FlagImpl(F.MEMBER_KIND, ProtoMemberKind.FAKE_OVERRIDE_VALUE)
@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")
public val IS_DELEGATION: Flag = FlagImpl(F.MEMBER_KIND, ProtoMemberKind.DELEGATION_VALUE)
@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")
public val IS_SYNTHESIZED: Flag = FlagImpl(F.MEMBER_KIND, ProtoMemberKind.SYNTHESIZED_VALUE)
@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")
public val IS_VAR: Flag = FlagImpl(F.IS_VAR)
@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")
public val HAS_GETTER: Flag = FlagImpl(F.HAS_GETTER)
@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")
public val HAS_SETTER: Flag = FlagImpl(F.HAS_SETTER)
@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")
public val IS_CONST: Flag = FlagImpl(F.IS_CONST)
@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")
public val IS_LATEINIT: Flag = FlagImpl(F.IS_LATEINIT)
@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
@@ -457,29 +467,29 @@ public abstract class Flag internal constructor() {
* reading the value from the bytecode in case there isn't one.
*/
@JvmField
@Deprecated("$prefix KmProperty.hasConstant")
public val HAS_CONSTANT: Flag = FlagImpl(F.HAS_CONSTANT)
@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")
public val IS_EXTERNAL: Flag = FlagImpl(F.IS_EXTERNAL_PROPERTY)
@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")
public val IS_DELEGATED: Flag = FlagImpl(F.IS_DELEGATED)
@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")
public val IS_EXPECT: Flag = FlagImpl(F.IS_EXPECT_PROPERTY)
@Deprecated("$prefix KmProperty.isExpect", level = DeprecationLevel.ERROR)
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.
*/
@JvmField
@Deprecated("$prefix KmPropertyAccessorAttributes.isNotDefault")
public val IS_NOT_DEFAULT: Flag = FlagImpl(F.IS_NOT_DEFAULT)
@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")
public val IS_EXTERNAL: Flag = FlagImpl(F.IS_EXTERNAL_ACCESSOR)
@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")
public val IS_INLINE: Flag = FlagImpl(F.IS_INLINE_ACCESSOR)
@Deprecated("$prefix KmPropertyAccessorAttributes.isInline", level = DeprecationLevel.ERROR)
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.
*/
@JvmField
@Deprecated("$prefix KmType.isNullable")
public val IS_NULLABLE: Flag = FlagImpl(0, 1, 1)
@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")
public val IS_SUSPEND: Flag = FlagImpl(F.SUSPEND_TYPE.offset + 1, F.SUSPEND_TYPE.bitWidth, 1)
@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")
public val IS_DEFINITELY_NON_NULL: Flag = FlagImpl(F.DEFINITELY_NOT_NULL_TYPE.offset + 1, F.DEFINITELY_NOT_NULL_TYPE.bitWidth, 1)
@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)
}
/**
@@ -544,8 +554,8 @@ public abstract class Flag internal constructor() {
* Signifies that the corresponding type parameter is `reified`.
*/
@JvmField
@Deprecated("$prefix KmTypeParameter.isReified")
public val IS_REIFIED: Flag = FlagImpl(0, 1, 1)
@Deprecated("$prefix KmTypeParameter.isReified", level = DeprecationLevel.ERROR)
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.
*/
@JvmField
@Deprecated("$prefix KmValueParameter.declaresDefaultValue")
public val DECLARES_DEFAULT_VALUE: Flag = FlagImpl(F.DECLARES_DEFAULT_VALUE)
@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")
public val IS_CROSSINLINE: Flag = FlagImpl(F.IS_CROSSINLINE)
@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")
public val IS_NOINLINE: Flag = FlagImpl(F.IS_NOINLINE)
@Deprecated("$prefix KmValueParameter.isNoinline", level = DeprecationLevel.ERROR)
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.
*/
@JvmField
@Deprecated("$prefix KmEffectExpression.isNegated")
public val IS_NEGATED: Flag = FlagImpl(F.IS_NEGATED)
@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")
public val IS_NULL_CHECK_PREDICATE: Flag = FlagImpl(F.IS_NULL_CHECK_PREDICATE)
@Deprecated("$prefix KmEffectExpression.isNullCheckPredicate", level = DeprecationLevel.ERROR)
public val IS_NULL_CHECK_PREDICATE: Flag = Flag(F.IS_NULL_CHECK_PREDICATE)
}
}
@@ -16,7 +16,8 @@ import kotlinx.metadata.internal.FlagImpl
*/
@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")
ReplaceWith("Int"),
DeprecationLevel.ERROR
)
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
* `flagsOf(Flag.IS_INTERNAL)`.
*/
@Suppress("DEPRECATION")
@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 as FlagImpl) + acc }
flags.fold(0) { acc, flag -> flag + acc }
@@ -5,7 +5,7 @@
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.ProtoBuf.Class.Kind as ProtoClassKind
import org.jetbrains.kotlin.metadata.ProtoBuf.Visibility as ProtoVisibility
@@ -71,7 +71,7 @@ public enum class Visibility(kind: Int) {
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)
;
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)
;
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)
;
internal val flag = Flag(ProtoFlags.MEMBER_KIND, kind)
internal val flag = FlagImpl(ProtoFlags.MEMBER_KIND, kind)
}
@@ -7,9 +7,8 @@
package kotlinx.metadata
import kotlinx.metadata.internal.Flag
import kotlinx.metadata.internal.FlagImpl
import kotlinx.metadata.internal.extensions.*
import kotlinx.metadata.internal.getDefaultPropertyAccessorFlags
import kotlinx.metadata.internal.propertyBooleanFlag
import org.jetbrains.kotlin.metadata.deserialization.Flags
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.
*/
@Deprecated("$flagAccessPrefix KmClass, such as KmClass.visibility")
@Deprecated("$flagAccessPrefix KmClass, such as KmClass.visibility", level = DeprecationLevel.ERROR)
public var flags: Int = 0
/**
@@ -317,8 +316,8 @@ public class KmLambda : KmLambdaVisitor() {
* such as [KmConstructor.visibility] or [KmConstructor.isSecondary].
*/
@Suppress("DEPRECATION", "DEPRECATION_ERROR")
public class KmConstructor @Deprecated(flagsCtorDeprecated) constructor(
@Deprecated("$flagAccessPrefix KmConstructor, such as KmConstructor.visibility") public var flags: Int,
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 constructor() : this(0)
@@ -371,8 +370,8 @@ public class KmConstructor @Deprecated(flagsCtorDeprecated) constructor(
* @property name the name of the function
*/
@Suppress("DEPRECATION", "DEPRECATION_ERROR")
public class KmFunction @Deprecated(flagsCtorDeprecated) constructor(
@Deprecated("$flagAccessPrefix KmFunction, such as KmFunction.visibility") public var flags: Int,
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() {
@@ -493,8 +492,8 @@ public class KmPropertyAccessorAttributes internal constructor(internal var flag
* @property name the name of the property
*/
@Suppress("DEPRECATION", "DEPRECATION_ERROR")
public class KmProperty @Deprecated(flagsCtorDeprecated) constructor(
@Deprecated("$flagAccessPrefix KmProperty, such as KmProperty.visibility") public var flags: Int,
public class KmProperty @Deprecated(flagsCtorDeprecated, level = DeprecationLevel.ERROR) constructor(
@Deprecated("$flagAccessPrefix KmProperty, such as KmProperty.visibility", level = DeprecationLevel.ERROR) public var flags: Int,
public var name: String,
getterFlags: Int,
setterFlags: Int,
@@ -503,8 +502,8 @@ public class KmProperty @Deprecated(flagsCtorDeprecated) constructor(
public constructor(name: String) : this(0, name, 0, 0)
// needed for reading/writing flags back to protobuf as a whole pack
private var _hasSetter: Boolean by propertyBooleanFlag(Flag(Flags.HAS_SETTER))
private var _hasGetter: Boolean by propertyBooleanFlag(Flag(Flags.HAS_GETTER))
private var _hasSetter: Boolean by propertyBooleanFlag(FlagImpl(Flags.HAS_SETTER))
private var _hasGetter: Boolean by propertyBooleanFlag(FlagImpl(Flags.HAS_GETTER))
/**
* 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
* 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
get() = getter.flags
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].
* 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
get() = setter?.flags ?: field
set(value) {
@@ -662,8 +661,8 @@ public class KmProperty @Deprecated(flagsCtorDeprecated) constructor(
* @property name the name of the type alias
*/
@Suppress("DEPRECATION", "DEPRECATION_ERROR")
public class KmTypeAlias @Deprecated(flagsCtorDeprecated) constructor(
@Deprecated("$flagAccessPrefix KmTypeAlias, such as KmTypeAlias.visibility") public var flags: Int,
public class KmTypeAlias @Deprecated(flagsCtorDeprecated, level = DeprecationLevel.ERROR) constructor(
@Deprecated("$flagAccessPrefix KmTypeAlias, such as KmTypeAlias.visibility", level = DeprecationLevel.ERROR) public var flags: Int,
public var name: String,
) : KmTypeAliasVisitor() {
@@ -749,8 +748,11 @@ public class KmTypeAlias @Deprecated(flagsCtorDeprecated) constructor(
* @property name the name of the value parameter
*/
@Suppress("DEPRECATION", "DEPRECATION_ERROR")
public class KmValueParameter @Deprecated(flagsCtorDeprecated) constructor(
@Deprecated("$flagAccessPrefix KmValueParameter, such as KmValueParameter.declaresDefaultValue") public var flags: Int,
public class KmValueParameter @Deprecated(flagsCtorDeprecated, level = DeprecationLevel.ERROR) constructor(
@Deprecated(
"$flagAccessPrefix KmValueParameter, such as KmValueParameter.declaresDefaultValue",
level = DeprecationLevel.ERROR
) public var flags: Int,
public var name: String,
) : KmValueParameterVisitor() {
@@ -808,8 +810,11 @@ public class KmValueParameter @Deprecated(flagsCtorDeprecated) constructor(
* @property variance the declaration-site variance of the type parameter
*/
@Suppress("DEPRECATION", "DEPRECATION_ERROR")
public class KmTypeParameter @Deprecated(flagsCtorDeprecated) constructor(
@Deprecated("$flagAccessPrefix KmTypeParameter, such as KmTypeParameter.isReified") public var flags: Int,
public class KmTypeParameter @Deprecated(flagsCtorDeprecated, level = DeprecationLevel.ERROR) constructor(
@Deprecated(
"$flagAccessPrefix KmTypeParameter, such as KmTypeParameter.isReified",
level = DeprecationLevel.ERROR
) public var flags: Int,
public var name: String,
public var id: Int,
public var variance: KmVariance,
@@ -853,8 +858,8 @@ public class KmTypeParameter @Deprecated(flagsCtorDeprecated) constructor(
* such as [KmType.isNullable].
*/
@Suppress("DEPRECATION", "DEPRECATION_ERROR")
public class KmType @Deprecated(flagsCtorDeprecated) constructor(
@Deprecated("$flagAccessPrefix KmType, such as KmType.isNullable") public var flags: Int
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 constructor() : this(0)
@@ -1124,7 +1129,7 @@ public class KmEffectExpression : KmEffectExpressionVisitor() {
/**
* 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()
/**
@@ -2,7 +2,7 @@
* 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")
@file:Suppress("DEPRECATION_ERROR") // flags will become internal eventually
package kotlinx.metadata.internal
@@ -7,7 +7,7 @@ package kotlinx.metadata.internal
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
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 =
(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.
* 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
@@ -2,7 +2,7 @@
* 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.
*/
@file:Suppress("DEPRECATION") // flags
@file:Suppress("DEPRECATION_ERROR") // flags will become internal eventually
package kotlinx.metadata.internal
import kotlinx.metadata.*