Deprecate old kotlinx-metadata flags API:
Flag, Flag constants, Flags typealias, flagsOf() function, and Flag accessors in nodes (such as KmClass.flags, KmClass.jvmFlags, KmProperty.setterFlags, etc) #KT-59440
This commit is contained in:
committed by
Space Team
parent
1a1cbcb321
commit
b15da7c63a
@@ -4,6 +4,7 @@ public final class kotlinx/metadata/Attributes {
|
||||
public static final fun getHasAnnotations (Lkotlinx/metadata/KmConstructor;)Z
|
||||
public static final fun getHasAnnotations (Lkotlinx/metadata/KmFunction;)Z
|
||||
public static final fun getHasAnnotations (Lkotlinx/metadata/KmProperty;)Z
|
||||
public static final fun getHasAnnotations (Lkotlinx/metadata/KmPropertyAccessorAttributes;)Z
|
||||
public static final fun getHasAnnotations (Lkotlinx/metadata/KmTypeAlias;)Z
|
||||
public static final fun getHasAnnotations (Lkotlinx/metadata/KmValueParameter;)Z
|
||||
public static final fun getHasConstant (Lkotlinx/metadata/KmProperty;)Z
|
||||
@@ -68,11 +69,13 @@ public final class kotlinx/metadata/Attributes {
|
||||
public static final fun setExternal (Lkotlinx/metadata/KmClass;Z)V
|
||||
public static final fun setExternal (Lkotlinx/metadata/KmFunction;Z)V
|
||||
public static final fun setExternal (Lkotlinx/metadata/KmProperty;Z)V
|
||||
public static final fun setExternal (Lkotlinx/metadata/KmPropertyAccessorAttributes;Z)V
|
||||
public static final fun setFunInterface (Lkotlinx/metadata/KmClass;Z)V
|
||||
public static final fun setHasAnnotations (Lkotlinx/metadata/KmClass;Z)V
|
||||
public static final fun setHasAnnotations (Lkotlinx/metadata/KmConstructor;Z)V
|
||||
public static final fun setHasAnnotations (Lkotlinx/metadata/KmFunction;Z)V
|
||||
public static final fun setHasAnnotations (Lkotlinx/metadata/KmProperty;Z)V
|
||||
public static final fun setHasAnnotations (Lkotlinx/metadata/KmPropertyAccessorAttributes;Z)V
|
||||
public static final fun setHasAnnotations (Lkotlinx/metadata/KmTypeAlias;Z)V
|
||||
public static final fun setHasAnnotations (Lkotlinx/metadata/KmValueParameter;Z)V
|
||||
public static final fun setHasConstant (Lkotlinx/metadata/KmProperty;Z)V
|
||||
@@ -83,6 +86,7 @@ public final class kotlinx/metadata/Attributes {
|
||||
public static final fun setHasSetter (Lkotlinx/metadata/KmProperty;Z)V
|
||||
public static final fun setInfix (Lkotlinx/metadata/KmFunction;Z)V
|
||||
public static final fun setInline (Lkotlinx/metadata/KmFunction;Z)V
|
||||
public static final fun setInline (Lkotlinx/metadata/KmPropertyAccessorAttributes;Z)V
|
||||
public static final fun setInner (Lkotlinx/metadata/KmClass;Z)V
|
||||
public static final fun setKind (Lkotlinx/metadata/KmClass;Lkotlinx/metadata/ClassKind;)V
|
||||
public static final fun setKind (Lkotlinx/metadata/KmFunction;Lkotlinx/metadata/MemberKind;)V
|
||||
@@ -134,7 +138,7 @@ public final class kotlinx/metadata/ClassNameKt {
|
||||
public abstract interface annotation class kotlinx/metadata/ExperimentalContextReceivers : java/lang/annotation/Annotation {
|
||||
}
|
||||
|
||||
public final class kotlinx/metadata/Flag {
|
||||
public abstract 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;
|
||||
@@ -147,8 +151,7 @@ public final 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 fun <init> (III)V
|
||||
public final fun invoke (I)Z
|
||||
public abstract fun invoke (I)Z
|
||||
}
|
||||
|
||||
public final class kotlinx/metadata/Flag$Class {
|
||||
|
||||
@@ -3,6 +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:JvmName("JvmAttributes")
|
||||
|
||||
package kotlinx.metadata.jvm
|
||||
@@ -10,7 +11,8 @@ package kotlinx.metadata.jvm
|
||||
import kotlinx.metadata.KmClass
|
||||
import kotlinx.metadata.KmProperty
|
||||
import kotlinx.metadata.internal.BooleanFlagDelegate
|
||||
import kotlinx.metadata.jvm.JvmFlag.booleanFlag
|
||||
import kotlinx.metadata.internal.FlagImpl
|
||||
import org.jetbrains.kotlin.metadata.deserialization.Flags
|
||||
import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmFlags as JF
|
||||
|
||||
/**
|
||||
@@ -38,3 +40,6 @@ var KmClass.hasMethodBodiesInInterface by BooleanFlagDelegate(KmClass::jvmFlags,
|
||||
* clients compiled without all-compatibility.
|
||||
*/
|
||||
var KmClass.isCompiledInCompatibilityMode by BooleanFlagDelegate(KmClass::jvmFlags, booleanFlag(JF.IS_COMPILED_IN_COMPATIBILITY_MODE))
|
||||
|
||||
private fun booleanFlag(f: Flags.BooleanFlagField): FlagImpl =
|
||||
FlagImpl(f.offset, f.bitWidth, 1)
|
||||
|
||||
@@ -32,7 +32,7 @@ abstract class JvmDeclarationContainerExtensionVisitor @JvmOverloads constructor
|
||||
* @param setterFlags property accessor flags, consisting of [Flag.HAS_ANNOTATIONS], visibility flag, modality flag
|
||||
* and [Flag.PropertyAccessor] flags
|
||||
*/
|
||||
open fun visitLocalDelegatedProperty(flags: Flags, name: String, getterFlags: Flags, setterFlags: Flags): KmPropertyVisitor? =
|
||||
open fun visitLocalDelegatedProperty(flags: Int, name: String, getterFlags: Int, setterFlags: Int): KmPropertyVisitor? =
|
||||
delegate?.visitLocalDelegatedProperty(flags, name, getterFlags, setterFlags)
|
||||
|
||||
/**
|
||||
@@ -67,7 +67,7 @@ open class JvmClassExtensionVisitor @JvmOverloads constructor(
|
||||
/**
|
||||
* Visits the JVM-specific flags of the class, consisting of [JvmFlag.Class] flags.
|
||||
*/
|
||||
open fun visitJvmFlags(flags: Flags) {
|
||||
open fun visitJvmFlags(flags: Int) {
|
||||
delegate?.visitJvmFlags(flags)
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ open class JvmPropertyExtensionVisitor @JvmOverloads constructor(
|
||||
* Example: `JvmMethodSignature("setX", "(Ljava/lang/Object;)V")`
|
||||
*/
|
||||
open fun visit(
|
||||
jvmFlags: Flags,
|
||||
jvmFlags: Int,
|
||||
fieldSignature: JvmFieldSignature?,
|
||||
getterSignature: JvmMethodSignature?,
|
||||
setterSignature: JvmMethodSignature?
|
||||
|
||||
@@ -45,7 +45,8 @@ var KmClass.anonymousObjectOriginName: String?
|
||||
/**
|
||||
* JVM-specific flags of the class, consisting of [JvmFlag.Class] flags.
|
||||
*/
|
||||
var KmClass.jvmFlags: Flags
|
||||
@Deprecated("Flag API is deprecated. Please use corresponding member extensions on KmClass, such as KmClass.hasMethodBodiesInInterface")
|
||||
var KmClass.jvmFlags: Int
|
||||
get() = jvm.jvmFlags
|
||||
set(value) {
|
||||
jvm.jvmFlags = value
|
||||
@@ -96,7 +97,8 @@ var KmFunction.lambdaClassOriginName: String?
|
||||
/**
|
||||
* JVM-specific flags of the property, consisting of [JvmFlag.Property] flags.
|
||||
*/
|
||||
var KmProperty.jvmFlags: Flags
|
||||
@Deprecated("Flag API is deprecated. Please use corresponding member extensions on KmProperty, such as KmProperty.isMovedFromInterfaceCompanion")
|
||||
var KmProperty.jvmFlags: Int
|
||||
get() = jvm.jvmFlags
|
||||
set(value) {
|
||||
jvm.jvmFlags = value
|
||||
|
||||
@@ -3,23 +3,29 @@
|
||||
* 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")
|
||||
|
||||
package kotlinx.metadata.jvm
|
||||
|
||||
import kotlinx.metadata.Flag
|
||||
import kotlinx.metadata.Flags
|
||||
import kotlinx.metadata.internal.FlagImpl
|
||||
import org.jetbrains.kotlin.metadata.deserialization.Flags as F
|
||||
import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmFlags as JF
|
||||
|
||||
private const val prefix = "Flag API is deprecated. Please use"
|
||||
|
||||
/**
|
||||
* JVM-specific flags in addition to common flags declared in [Flag].
|
||||
*
|
||||
* @see Flag
|
||||
* @see Flags
|
||||
*/
|
||||
@Deprecated("$prefix corresponding extensions on Km nodes, such as KmClass.hasMethodBodiesInInterface")
|
||||
object JvmFlag {
|
||||
/**
|
||||
* JVM-specific property flags in addition to common property flags declared in [Flag.Property].
|
||||
*/
|
||||
@Deprecated("$prefix corresponding extension on KmProperty: KmProperty.isMovedFromInterfaceCompanion")
|
||||
object Property {
|
||||
/**
|
||||
* Applied to a property declared in an interface's companion object, signifies that its backing field is declared as a static
|
||||
@@ -28,12 +34,14 @@ object JvmFlag {
|
||||
* Has no effect if the property is not declared in a companion object of some interface.
|
||||
*/
|
||||
@JvmField
|
||||
@Deprecated("$prefix KmProperty.isMovedFromInterfaceCompanion")
|
||||
val IS_MOVED_FROM_INTERFACE_COMPANION = 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")
|
||||
object Class {
|
||||
/**
|
||||
* Applied to an interface compiled with -Xjvm-default=all or all-compatibility.
|
||||
@@ -43,6 +51,7 @@ object JvmFlag {
|
||||
* class.
|
||||
*/
|
||||
@JvmField
|
||||
@Deprecated("$prefix KmClass.hasMethodBodiesInInterface")
|
||||
val HAS_METHOD_BODIES_IN_INTERFACE = booleanFlag(JF.IS_COMPILED_IN_JVM_DEFAULT_MODE)
|
||||
|
||||
/**
|
||||
@@ -53,9 +62,10 @@ object JvmFlag {
|
||||
* clients compiled without all-compatibility.
|
||||
*/
|
||||
@JvmField
|
||||
@Deprecated("$prefix KmProperty.isCompiledInCompatibilityMode")
|
||||
val IS_COMPILED_IN_COMPATIBILITY_MODE = booleanFlag(JF.IS_COMPILED_IN_COMPATIBILITY_MODE)
|
||||
}
|
||||
|
||||
internal fun booleanFlag(f: F.BooleanFlagField): Flag =
|
||||
Flag(f.offset, f.bitWidth, 1)
|
||||
FlagImpl(f.offset, f.bitWidth, 1)
|
||||
}
|
||||
|
||||
+6
-6
@@ -36,9 +36,9 @@ internal class JvmClassExtension : JvmClassExtensionVisitor(), KmClassExtension
|
||||
val localDelegatedProperties: MutableList<KmProperty> = ArrayList(0)
|
||||
var moduleName: String? = null
|
||||
var anonymousObjectOriginName: String? = null
|
||||
var jvmFlags: Flags = 0
|
||||
var jvmFlags: Int = 0
|
||||
|
||||
override fun visitLocalDelegatedProperty(flags: Flags, name: String, getterFlags: Flags, setterFlags: Flags): KmPropertyVisitor =
|
||||
override fun visitLocalDelegatedProperty(flags: Int, name: String, getterFlags: Int, setterFlags: Int): KmPropertyVisitor =
|
||||
KmProperty(flags, name, getterFlags, setterFlags).also { localDelegatedProperties.add(it) }
|
||||
|
||||
override fun visitModuleName(name: String) {
|
||||
@@ -49,7 +49,7 @@ internal class JvmClassExtension : JvmClassExtensionVisitor(), KmClassExtension
|
||||
this.anonymousObjectOriginName = internalName
|
||||
}
|
||||
|
||||
override fun visitJvmFlags(flags: Flags) {
|
||||
override fun visitJvmFlags(flags: Int) {
|
||||
this.jvmFlags = flags
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ internal class JvmPackageExtension : JvmPackageExtensionVisitor(), KmPackageExte
|
||||
val localDelegatedProperties: MutableList<KmProperty> = ArrayList(0)
|
||||
var moduleName: String? = null
|
||||
|
||||
override fun visitLocalDelegatedProperty(flags: Flags, name: String, getterFlags: Flags, setterFlags: Flags): KmPropertyVisitor =
|
||||
override fun visitLocalDelegatedProperty(flags: Int, name: String, getterFlags: Int, setterFlags: Int): KmPropertyVisitor =
|
||||
KmProperty(flags, name, getterFlags, setterFlags).also { localDelegatedProperties.add(it) }
|
||||
|
||||
override fun visitModuleName(name: String) {
|
||||
@@ -109,7 +109,7 @@ internal class JvmFunctionExtension : JvmFunctionExtensionVisitor(), KmFunctionE
|
||||
}
|
||||
|
||||
internal class JvmPropertyExtension : JvmPropertyExtensionVisitor(), KmPropertyExtension {
|
||||
var jvmFlags: Flags = 0
|
||||
var jvmFlags: Int = 0
|
||||
var fieldSignature: JvmFieldSignature? = null
|
||||
var getterSignature: JvmMethodSignature? = null
|
||||
var setterSignature: JvmMethodSignature? = null
|
||||
@@ -117,7 +117,7 @@ internal class JvmPropertyExtension : JvmPropertyExtensionVisitor(), KmPropertyE
|
||||
var syntheticMethodForDelegate: JvmMethodSignature? = null
|
||||
|
||||
override fun visit(
|
||||
jvmFlags: Flags,
|
||||
jvmFlags: Int,
|
||||
fieldSignature: JvmFieldSignature?,
|
||||
getterSignature: JvmMethodSignature?,
|
||||
setterSignature: JvmMethodSignature?
|
||||
|
||||
+5
-5
@@ -127,7 +127,7 @@ internal class JvmMetadataExtensions : MetadataExtensions {
|
||||
}
|
||||
|
||||
override fun visitLocalDelegatedProperty(
|
||||
flags: Flags, name: String, getterFlags: Flags, setterFlags: Flags
|
||||
flags: Int, name: String, getterFlags: Int, setterFlags: Int
|
||||
): KmPropertyVisitor = writeProperty(c, flags, name, getterFlags, setterFlags) {
|
||||
proto.addExtension(JvmProtoBuf.classLocalVariable, it.build())
|
||||
}
|
||||
@@ -138,7 +138,7 @@ internal class JvmMetadataExtensions : MetadataExtensions {
|
||||
}
|
||||
}
|
||||
|
||||
override fun visitJvmFlags(flags: Flags) {
|
||||
override fun visitJvmFlags(flags: Int) {
|
||||
if (flags != 0) {
|
||||
proto.setExtension(JvmProtoBuf.jvmClassFlags, flags)
|
||||
}
|
||||
@@ -152,7 +152,7 @@ internal class JvmMetadataExtensions : MetadataExtensions {
|
||||
if (type != JvmPackageExtensionVisitor.TYPE) return null
|
||||
return object : JvmPackageExtensionVisitor() {
|
||||
override fun visitLocalDelegatedProperty(
|
||||
flags: Flags, name: String, getterFlags: Flags, setterFlags: Flags
|
||||
flags: Int, name: String, getterFlags: Int, setterFlags: Int
|
||||
): KmPropertyVisitor = writeProperty(c, flags, name, getterFlags, setterFlags) {
|
||||
proto.addExtension(JvmProtoBuf.packageLocalVariable, it.build())
|
||||
}
|
||||
@@ -194,14 +194,14 @@ internal class JvmMetadataExtensions : MetadataExtensions {
|
||||
): KmPropertyExtensionVisitor? {
|
||||
if (type != JvmPropertyExtensionVisitor.TYPE) return null
|
||||
return object : JvmPropertyExtensionVisitor() {
|
||||
private var jvmFlags: Flags = ProtoBuf.Property.getDefaultInstance().getExtension(JvmProtoBuf.flags)
|
||||
private var jvmFlags: Int = ProtoBuf.Property.getDefaultInstance().getExtension(JvmProtoBuf.flags)
|
||||
private var signatureOrNull: JvmProtoBuf.JvmPropertySignature.Builder? = null
|
||||
|
||||
private val signature: JvmProtoBuf.JvmPropertySignature.Builder
|
||||
get() = signatureOrNull ?: JvmProtoBuf.JvmPropertySignature.newBuilder().also { signatureOrNull = it }
|
||||
|
||||
override fun visit(
|
||||
jvmFlags: Flags,
|
||||
jvmFlags: Int,
|
||||
fieldSignature: JvmFieldSignature?,
|
||||
getterSignature: JvmMethodSignature?,
|
||||
setterSignature: JvmMethodSignature?
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.junit.Test
|
||||
import kotlin.reflect.KMutableProperty0
|
||||
import kotlin.test.*
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
class FlagDelegatesTest {
|
||||
private class Private
|
||||
|
||||
@@ -47,7 +48,7 @@ class FlagDelegatesTest {
|
||||
@Test
|
||||
fun testBooleanFlags() {
|
||||
val klass = Public::class.java.readMetadataAsKmClass()
|
||||
fun doTest(prop: KMutableProperty0<Boolean>, flags: () -> Flags, rawFlag: Flag) {
|
||||
fun doTest(prop: KMutableProperty0<Boolean>, flags: () -> Int, rawFlag: Flag) {
|
||||
assertFalse(prop.get())
|
||||
assertFalse(rawFlag(flags()))
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ class MetadataSmokeTest {
|
||||
|
||||
val klass = KmClass().apply {
|
||||
name = "Hello"
|
||||
flags = flagsOf(Flag.IS_PUBLIC)
|
||||
visibility = Visibility.PUBLIC
|
||||
constructors += KmConstructor().apply {
|
||||
visibility = Visibility.PUBLIC
|
||||
signature = JvmMethodSignature("<init>", "()V")
|
||||
@@ -56,7 +56,7 @@ class MetadataSmokeTest {
|
||||
functions += KmFunction("hello").apply {
|
||||
visibility = Visibility.PUBLIC
|
||||
kind = MemberKind.DECLARATION
|
||||
returnType = KmType(flagsOf()).apply {
|
||||
returnType = KmType().apply {
|
||||
classifier = KmClassifier.Class("kotlin/String")
|
||||
}
|
||||
signature = JvmMethodSignature("hello", "()Ljava/lang/String;")
|
||||
@@ -127,7 +127,7 @@ class MetadataSmokeTest {
|
||||
class ClassNameReader : KmClassVisitor() {
|
||||
lateinit var className: ClassName
|
||||
|
||||
override fun visit(flags: Flags, name: ClassName) {
|
||||
override fun visit(flags: Int, name: ClassName) {
|
||||
className = name
|
||||
}
|
||||
}
|
||||
@@ -176,10 +176,10 @@ class MetadataSmokeTest {
|
||||
KmClass().apply {
|
||||
classWithStableParameterNames.accept(
|
||||
object : KmClassVisitor(this) {
|
||||
override fun visitConstructor(flags: Flags) =
|
||||
override fun visitConstructor(flags: Int) =
|
||||
super.visitConstructor(flags + flagsOf(Flag.Constructor.HAS_NON_STABLE_PARAMETER_NAMES))
|
||||
|
||||
override fun visitFunction(flags: Flags, name: String) =
|
||||
override fun visitFunction(flags: Int, name: String) =
|
||||
super.visitFunction(flags + flagsOf(Flag.Function.HAS_NON_STABLE_PARAMETER_NAMES), name)
|
||||
}
|
||||
)
|
||||
@@ -215,19 +215,19 @@ class MetadataSmokeTest {
|
||||
// exist are controlled by compiler options, so we have to manually create metadata with the
|
||||
// flags set. Since the current flags only apply to interfaces with default functions we modify
|
||||
// the metadata for the kotlin.coroutines.CoroutineContext interface.
|
||||
val jvmClassFlags: Flags = flagsOf(
|
||||
JvmFlag.Class.IS_COMPILED_IN_COMPATIBILITY_MODE,
|
||||
JvmFlag.Class.HAS_METHOD_BODIES_IN_INTERFACE
|
||||
)
|
||||
|
||||
val metadata = CoroutineContext::class.java.getMetadata()
|
||||
val kmClass = metadata.readAsKmClass()
|
||||
kmClass.jvmFlags = jvmClassFlags
|
||||
assertFalse(kmClass.isCompiledInCompatibilityMode)
|
||||
assertFalse(kmClass.hasMethodBodiesInInterface)
|
||||
kmClass.isCompiledInCompatibilityMode = true
|
||||
kmClass.hasMethodBodiesInInterface = true
|
||||
|
||||
val kmClassCopy = KotlinClassMetadata
|
||||
.writeClass(kmClass, metadata.metadataVersion, metadata.extraInt)
|
||||
.readAsKmClass()
|
||||
assertEquals(kmClassCopy.jvmFlags, jvmClassFlags)
|
||||
assertTrue(kmClassCopy.isCompiledInCompatibilityMode)
|
||||
assertTrue(kmClassCopy.hasMethodBodiesInInterface)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -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:OptIn(ExperimentalStdlibApi::class)
|
||||
@file:Suppress("DEPRECATION")
|
||||
@file:JvmName("Attributes")
|
||||
|
||||
package kotlinx.metadata
|
||||
@@ -54,6 +54,15 @@ var KmFunction.hasAnnotations by annotationsOn(KmFunction::flags)
|
||||
*/
|
||||
var KmProperty.hasAnnotations by annotationsOn(KmProperty::flags)
|
||||
|
||||
/**
|
||||
* Signifies that the corresponding property accessor has at least one annotation.
|
||||
*
|
||||
* This flag is useful for reading Kotlin metadata on JVM efficiently. On JVM, most of the annotations are written not to the Kotlin
|
||||
* metadata, but directly on the corresponding declarations in the class file. This flag can be used as an optimization to avoid
|
||||
* reading annotations from the class file (which can be slow) in case when a property accessor has no annotations.
|
||||
*/
|
||||
var KmPropertyAccessorAttributes.hasAnnotations by annotationsOn(KmPropertyAccessorAttributes::flags)
|
||||
|
||||
/**
|
||||
* Signifies that the corresponding value parameter has at least one annotation.
|
||||
*
|
||||
@@ -293,30 +302,30 @@ var KmPropertyAccessorAttributes.isNotDefault: Boolean by propertyAccessorBoolea
|
||||
/**
|
||||
* Signifies that the corresponding property accessor is `external`.
|
||||
*/
|
||||
val KmPropertyAccessorAttributes.isExternal: Boolean by propertyAccessorBooleanFlag(Flag(ProtoFlags.IS_EXTERNAL_ACCESSOR))
|
||||
var KmPropertyAccessorAttributes.isExternal: Boolean by propertyAccessorBooleanFlag(Flag(ProtoFlags.IS_EXTERNAL_ACCESSOR))
|
||||
|
||||
/**
|
||||
* Signifies that the corresponding property accessor is `inline`.
|
||||
*/
|
||||
val KmPropertyAccessorAttributes.isInline: Boolean by propertyAccessorBooleanFlag(Flag(ProtoFlags.IS_INLINE_ACCESSOR))
|
||||
var KmPropertyAccessorAttributes.isInline: Boolean by propertyAccessorBooleanFlag(Flag(ProtoFlags.IS_INLINE_ACCESSOR))
|
||||
|
||||
// --- TYPE & TYPE_PARAM
|
||||
|
||||
/**
|
||||
* Signifies that the corresponding type is marked as nullable, i.e. has a question mark at the end of its notation.
|
||||
*/
|
||||
var KmType.isNullable: Boolean by typeBooleanFlag(Flag(0, 1, 1))
|
||||
var KmType.isNullable: Boolean by typeBooleanFlag(FlagImpl(0, 1, 1))
|
||||
|
||||
/**
|
||||
* Signifies that the corresponding type is `suspend`.
|
||||
*/
|
||||
var KmType.isSuspend: Boolean by typeBooleanFlag(Flag(ProtoFlags.SUSPEND_TYPE.offset + 1, ProtoFlags.SUSPEND_TYPE.bitWidth, 1))
|
||||
var KmType.isSuspend: Boolean by typeBooleanFlag(FlagImpl(ProtoFlags.SUSPEND_TYPE.offset + 1, ProtoFlags.SUSPEND_TYPE.bitWidth, 1))
|
||||
|
||||
/**
|
||||
* Signifies that the corresponding type is [definitely non-null](https://kotlinlang.org/docs/whatsnew17.html#stable-definitely-non-nullable-types).
|
||||
*/
|
||||
var KmType.isDefinitelyNonNull: Boolean by typeBooleanFlag(
|
||||
Flag(
|
||||
FlagImpl(
|
||||
ProtoFlags.DEFINITELY_NOT_NULL_TYPE.offset + 1,
|
||||
ProtoFlags.DEFINITELY_NOT_NULL_TYPE.bitWidth,
|
||||
1
|
||||
@@ -327,7 +336,7 @@ var KmType.isDefinitelyNonNull: Boolean by typeBooleanFlag(
|
||||
/**
|
||||
* Signifies that the corresponding type parameter is `reified`.
|
||||
*/
|
||||
var KmTypeParameter.isReified: Boolean by BooleanFlagDelegate(KmTypeParameter::flags, Flag(0, 1, 1))
|
||||
var KmTypeParameter.isReified: Boolean by BooleanFlagDelegate(KmTypeParameter::flags, FlagImpl(0, 1, 1))
|
||||
|
||||
// --- TYPE ALIAS ---
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
package kotlinx.metadata
|
||||
|
||||
import kotlinx.metadata.internal.IgnoreInApiDump
|
||||
import kotlinx.metadata.internal.FlagImpl
|
||||
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
|
||||
@@ -13,6 +13,8 @@ import org.jetbrains.kotlin.metadata.ProtoBuf.Modality as ProtoModality
|
||||
import org.jetbrains.kotlin.metadata.ProtoBuf.Visibility as ProtoVisibility
|
||||
import org.jetbrains.kotlin.metadata.ProtoBuf.MemberKind as ProtoMemberKind
|
||||
|
||||
private const val prefix = "Flag API is deprecated. Please use"
|
||||
|
||||
/**
|
||||
* Represents a boolean flag that is either present or not in a Kotlin declaration. A "flag" is a boolean trait that is either present
|
||||
* or not in a declaration. To check whether the flag is present in the bitmask, call [Flag.invoke] on the flag, passing the bitmask
|
||||
@@ -41,23 +43,17 @@ import org.jetbrains.kotlin.metadata.ProtoBuf.MemberKind as ProtoMemberKind
|
||||
* @see Flags
|
||||
* @see flagsOf
|
||||
*/
|
||||
class Flag(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)
|
||||
|
||||
@IgnoreInApiDump
|
||||
internal constructor(field: F.BooleanFlagField) : this(field, 1)
|
||||
|
||||
internal operator fun plus(flags: Flags): Flags =
|
||||
(flags and (((1 shl bitWidth) - 1) shl offset).inv()) + (value shl offset)
|
||||
@Deprecated("$prefix corresponding extensions on Km nodes, such as KmClass.visibility")
|
||||
@Suppress("DEPRECATION")
|
||||
abstract class Flag internal constructor() {
|
||||
|
||||
/**
|
||||
* Checks whether the flag is present in the given bitmask.
|
||||
*/
|
||||
operator fun invoke(flags: Flags): Boolean =
|
||||
(flags ushr offset) and ((1 shl bitWidth) - 1) == value
|
||||
abstract operator fun invoke(flags: Int): Boolean
|
||||
|
||||
/** @suppress deprecated in another PR */
|
||||
/** @suppress deprecated */
|
||||
@Deprecated("$prefix corresponding extensions on Km nodes, such as KmClass.visibility")
|
||||
companion object Common {
|
||||
/**
|
||||
* Signifies that the corresponding declaration has at least one annotation.
|
||||
@@ -67,71 +63,82 @@ class Flag(internal val offset: Int, internal val bitWidth: Int, internal val va
|
||||
* reading annotations from the class file (which can be slow) in case when a declaration has no annotations.
|
||||
*/
|
||||
@JvmField
|
||||
val HAS_ANNOTATIONS = Flag(F.HAS_ANNOTATIONS)
|
||||
@Deprecated("$prefix corresponding extension on a node, e.g. KmClass.hasAnnotations")
|
||||
val HAS_ANNOTATIONS: Flag = FlagImpl(F.HAS_ANNOTATIONS)
|
||||
|
||||
|
||||
/**
|
||||
* A visibility flag, signifying that the corresponding declaration is `internal`.
|
||||
*/
|
||||
@JvmField
|
||||
val IS_INTERNAL = Flag(F.VISIBILITY, ProtoVisibility.INTERNAL_VALUE)
|
||||
@Deprecated("$prefix visibility extension on a node, e.g. KmClass.visibility")
|
||||
val IS_INTERNAL: Flag = FlagImpl(F.VISIBILITY, ProtoVisibility.INTERNAL_VALUE)
|
||||
|
||||
/**
|
||||
* A visibility flag, signifying that the corresponding declaration is `private`.
|
||||
*/
|
||||
@JvmField
|
||||
val IS_PRIVATE = Flag(F.VISIBILITY, ProtoVisibility.PRIVATE_VALUE)
|
||||
@Deprecated("$prefix visibility extension on a node, e.g. KmClass.visibility")
|
||||
val IS_PRIVATE: Flag = FlagImpl(F.VISIBILITY, ProtoVisibility.PRIVATE_VALUE)
|
||||
|
||||
/**
|
||||
* A visibility flag, signifying that the corresponding declaration is `protected`.
|
||||
*/
|
||||
@JvmField
|
||||
val IS_PROTECTED = Flag(F.VISIBILITY, ProtoVisibility.PROTECTED_VALUE)
|
||||
@Deprecated("$prefix visibility extension on a node, e.g. KmClass.visibility")
|
||||
val IS_PROTECTED: Flag = FlagImpl(F.VISIBILITY, ProtoVisibility.PROTECTED_VALUE)
|
||||
|
||||
/**
|
||||
* A visibility flag, signifying that the corresponding declaration is `public`.
|
||||
*/
|
||||
@JvmField
|
||||
val IS_PUBLIC = Flag(F.VISIBILITY, ProtoVisibility.PUBLIC_VALUE)
|
||||
@Deprecated("$prefix visibility extension on a node, e.g. KmClass.visibility")
|
||||
val IS_PUBLIC: Flag = FlagImpl(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
|
||||
val IS_PRIVATE_TO_THIS = Flag(F.VISIBILITY, ProtoVisibility.PRIVATE_TO_THIS_VALUE)
|
||||
@Deprecated("$prefix visibility extension on a node, e.g. KmClass.visibility")
|
||||
val IS_PRIVATE_TO_THIS: Flag = FlagImpl(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
|
||||
val IS_LOCAL = Flag(F.VISIBILITY, ProtoVisibility.LOCAL_VALUE)
|
||||
@Deprecated("$prefix visibility extension on a node, e.g. KmClass.visibility")
|
||||
val IS_LOCAL: Flag = FlagImpl(F.VISIBILITY, ProtoVisibility.LOCAL_VALUE)
|
||||
|
||||
|
||||
/**
|
||||
* A modality flag, signifying that the corresponding declaration is `final`.
|
||||
*/
|
||||
@JvmField
|
||||
val IS_FINAL = Flag(F.MODALITY, ProtoModality.FINAL_VALUE)
|
||||
@Deprecated("$prefix modality extension on a node, e.g. KmClass.modality or KmFunction.modality")
|
||||
val IS_FINAL: Flag = FlagImpl(F.MODALITY, ProtoModality.FINAL_VALUE)
|
||||
|
||||
/**
|
||||
* A modality flag, signifying that the corresponding declaration is `open`.
|
||||
*/
|
||||
@JvmField
|
||||
val IS_OPEN = Flag(F.MODALITY, ProtoModality.OPEN_VALUE)
|
||||
@Deprecated("$prefix modality extension on a node, e.g. KmClass.modality or KmFunction.modality")
|
||||
val IS_OPEN: Flag = FlagImpl(F.MODALITY, ProtoModality.OPEN_VALUE)
|
||||
|
||||
/**
|
||||
* A modality flag, signifying that the corresponding declaration is `abstract`.
|
||||
*/
|
||||
@JvmField
|
||||
val IS_ABSTRACT = Flag(F.MODALITY, ProtoModality.ABSTRACT_VALUE)
|
||||
@Deprecated("$prefix modality extension on a node, e.g. KmClass.modality or KmFunction.modality")
|
||||
val IS_ABSTRACT: Flag = FlagImpl(F.MODALITY, ProtoModality.ABSTRACT_VALUE)
|
||||
|
||||
/**
|
||||
* A modality flag, signifying that the corresponding declaration is `sealed`.
|
||||
*/
|
||||
@JvmField
|
||||
val IS_SEALED = Flag(F.MODALITY, ProtoModality.SEALED_VALUE)
|
||||
@Deprecated("$prefix modality extension on a node, e.g. KmClass.modality")
|
||||
val IS_SEALED: Flag = FlagImpl(F.MODALITY, ProtoModality.SEALED_VALUE)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -141,73 +148,85 @@ class Flag(internal val offset: Int, internal val bitWidth: Int, internal val va
|
||||
* * 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")
|
||||
object Class {
|
||||
/**
|
||||
* A class kind flag, signifying that the corresponding class is a usual `class`.
|
||||
*/
|
||||
@JvmField
|
||||
val IS_CLASS = Flag(F.CLASS_KIND, ClassKind.CLASS_VALUE)
|
||||
@Deprecated("$prefix KmClass.kind")
|
||||
val IS_CLASS: Flag = FlagImpl(F.CLASS_KIND, ClassKind.CLASS_VALUE)
|
||||
|
||||
/**
|
||||
* A class kind flag, signifying that the corresponding class is an `interface`.
|
||||
*/
|
||||
@JvmField
|
||||
val IS_INTERFACE = Flag(F.CLASS_KIND, ClassKind.INTERFACE_VALUE)
|
||||
@Deprecated("$prefix KmClass.kind")
|
||||
val IS_INTERFACE: Flag = FlagImpl(F.CLASS_KIND, ClassKind.INTERFACE_VALUE)
|
||||
|
||||
/**
|
||||
* A class kind flag, signifying that the corresponding class is an `enum class`.
|
||||
*/
|
||||
@JvmField
|
||||
val IS_ENUM_CLASS = Flag(F.CLASS_KIND, ClassKind.ENUM_CLASS_VALUE)
|
||||
@Deprecated("$prefix KmClass.kind")
|
||||
val IS_ENUM_CLASS: Flag = FlagImpl(F.CLASS_KIND, ClassKind.ENUM_CLASS_VALUE)
|
||||
|
||||
/**
|
||||
* A class kind flag, signifying that the corresponding class is an enum entry.
|
||||
*/
|
||||
@JvmField
|
||||
val IS_ENUM_ENTRY = Flag(F.CLASS_KIND, ClassKind.ENUM_ENTRY_VALUE)
|
||||
@Deprecated("$prefix KmClass.kind")
|
||||
val IS_ENUM_ENTRY: Flag = FlagImpl(F.CLASS_KIND, ClassKind.ENUM_ENTRY_VALUE)
|
||||
|
||||
/**
|
||||
* A class kind flag, signifying that the corresponding class is an `annotation class`.
|
||||
*/
|
||||
@JvmField
|
||||
val IS_ANNOTATION_CLASS = Flag(F.CLASS_KIND, ClassKind.ANNOTATION_CLASS_VALUE)
|
||||
@Deprecated("$prefix KmClass.kind")
|
||||
val IS_ANNOTATION_CLASS: Flag = FlagImpl(F.CLASS_KIND, ClassKind.ANNOTATION_CLASS_VALUE)
|
||||
|
||||
/**
|
||||
* A class kind flag, signifying that the corresponding class is a non-companion `object`.
|
||||
*/
|
||||
@JvmField
|
||||
val IS_OBJECT = Flag(F.CLASS_KIND, ClassKind.OBJECT_VALUE)
|
||||
@Deprecated("$prefix KmClass.kind")
|
||||
val IS_OBJECT: Flag = FlagImpl(F.CLASS_KIND, ClassKind.OBJECT_VALUE)
|
||||
|
||||
/**
|
||||
* A class kind flag, signifying that the corresponding class is a `companion object`.
|
||||
*/
|
||||
@JvmField
|
||||
val IS_COMPANION_OBJECT = Flag(F.CLASS_KIND, ClassKind.COMPANION_OBJECT_VALUE)
|
||||
@Deprecated("$prefix KmClass.kind")
|
||||
val IS_COMPANION_OBJECT: Flag = FlagImpl(F.CLASS_KIND, ClassKind.COMPANION_OBJECT_VALUE)
|
||||
|
||||
|
||||
/**
|
||||
* Signifies that the corresponding class is `inner`.
|
||||
*/
|
||||
@JvmField
|
||||
val IS_INNER = Flag(F.IS_INNER)
|
||||
@Deprecated("$prefix KmClass.isInner")
|
||||
val IS_INNER: Flag = FlagImpl(F.IS_INNER)
|
||||
|
||||
/**
|
||||
* Signifies that the corresponding class is `data`.
|
||||
*/
|
||||
@JvmField
|
||||
val IS_DATA = Flag(F.IS_DATA)
|
||||
@Deprecated("$prefix KmClass.isData")
|
||||
val IS_DATA: Flag = FlagImpl(F.IS_DATA)
|
||||
|
||||
/**
|
||||
* Signifies that the corresponding class is `external`.
|
||||
*/
|
||||
@JvmField
|
||||
val IS_EXTERNAL = Flag(F.IS_EXTERNAL_CLASS)
|
||||
@Deprecated("$prefix KmClass.isExternal")
|
||||
val IS_EXTERNAL: Flag = FlagImpl(F.IS_EXTERNAL_CLASS)
|
||||
|
||||
/**
|
||||
* Signifies that the corresponding class is `expect`.
|
||||
*/
|
||||
@JvmField
|
||||
val IS_EXPECT = Flag(F.IS_EXPECT_CLASS)
|
||||
@Deprecated("$prefix KmClass.isExpect")
|
||||
val IS_EXPECT: Flag = FlagImpl(F.IS_EXPECT_CLASS)
|
||||
|
||||
@JvmField
|
||||
@Deprecated(
|
||||
@@ -215,26 +234,29 @@ class Flag(internal val offset: Int, internal val bitWidth: Int, internal val va
|
||||
level = DeprecationLevel.ERROR
|
||||
)
|
||||
@Suppress("unused")
|
||||
val IS_INLINE = Flag(F.IS_VALUE_CLASS)
|
||||
val IS_INLINE: Flag = FlagImpl(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
|
||||
val IS_VALUE = Flag(F.IS_VALUE_CLASS)
|
||||
@Deprecated("$prefix KmClass.isValue")
|
||||
val IS_VALUE: Flag = FlagImpl(F.IS_VALUE_CLASS)
|
||||
|
||||
/**
|
||||
* Signifies that the corresponding class is a functional interface, i.e. marked with the keyword `fun`.
|
||||
*/
|
||||
@JvmField
|
||||
val IS_FUN = Flag(F.IS_FUN_INTERFACE)
|
||||
@Deprecated("$prefix KmClass.isFun")
|
||||
val IS_FUN: Flag = FlagImpl(F.IS_FUN_INTERFACE)
|
||||
|
||||
/**
|
||||
* Signifies that the corresponding enum class has ".entries" property in bytecode.
|
||||
* Always `false` for not enum classes.
|
||||
*/
|
||||
@JvmField
|
||||
val HAS_ENUM_ENTRIES = Flag(F.HAS_ENUM_ENTRIES)
|
||||
@Deprecated("$prefix KmClass.hasEnumEntries")
|
||||
val HAS_ENUM_ENTRIES: Flag = FlagImpl(F.HAS_ENUM_ENTRIES)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -244,19 +266,21 @@ class Flag(internal val offset: Int, internal val bitWidth: Int, internal val va
|
||||
@JvmField
|
||||
@Deprecated("Use IS_SECONDARY which holds inverted value instead.", level = DeprecationLevel.ERROR)
|
||||
@Suppress("unused")
|
||||
val IS_PRIMARY = Flag(F.IS_SECONDARY, 0)
|
||||
val IS_PRIMARY: Flag = FlagImpl(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
|
||||
val IS_SECONDARY = Flag(F.IS_SECONDARY)
|
||||
@Deprecated("$prefix KmConstructor.isSecondary")
|
||||
val IS_SECONDARY: Flag = FlagImpl(F.IS_SECONDARY)
|
||||
|
||||
/**
|
||||
* Signifies that the corresponding constructor has non-stable parameter names, i.e. cannot be called with named arguments.
|
||||
*/
|
||||
@JvmField
|
||||
val HAS_NON_STABLE_PARAMETER_NAMES = Flag(F.IS_CONSTRUCTOR_WITH_NON_STABLE_PARAMETER_NAMES)
|
||||
@Deprecated("$prefix KmConstructor.hasNonStableParameterNames")
|
||||
val HAS_NON_STABLE_PARAMETER_NAMES: Flag = FlagImpl(F.IS_CONSTRUCTOR_WITH_NON_STABLE_PARAMETER_NAMES)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -270,77 +294,88 @@ class Flag(internal val offset: Int, internal val bitWidth: Int, internal val va
|
||||
* A member kind flag, signifying that the corresponding function is explicitly declared in the containing class.
|
||||
*/
|
||||
@JvmField
|
||||
val IS_DECLARATION = Flag(F.MEMBER_KIND, ProtoMemberKind.DECLARATION_VALUE)
|
||||
@Deprecated("$prefix KmFunction.kind")
|
||||
val IS_DECLARATION: Flag = FlagImpl(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
|
||||
val IS_FAKE_OVERRIDE = Flag(F.MEMBER_KIND, ProtoMemberKind.FAKE_OVERRIDE_VALUE)
|
||||
@Deprecated("$prefix KmFunction.kind")
|
||||
val IS_FAKE_OVERRIDE: Flag = FlagImpl(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
|
||||
val IS_DELEGATION = Flag(F.MEMBER_KIND, ProtoMemberKind.DELEGATION_VALUE)
|
||||
@Deprecated("$prefix KmFunction.kind")
|
||||
val IS_DELEGATION: Flag = FlagImpl(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
|
||||
val IS_SYNTHESIZED = Flag(F.MEMBER_KIND, ProtoMemberKind.SYNTHESIZED_VALUE)
|
||||
|
||||
@Deprecated("$prefix KmFunction.kind")
|
||||
val IS_SYNTHESIZED: Flag = FlagImpl(F.MEMBER_KIND, ProtoMemberKind.SYNTHESIZED_VALUE)
|
||||
|
||||
/**
|
||||
* Signifies that the corresponding function is `operator`.
|
||||
*/
|
||||
@JvmField
|
||||
val IS_OPERATOR = Flag(F.IS_OPERATOR)
|
||||
@Deprecated("$prefix KmFunction.isOperator")
|
||||
val IS_OPERATOR: Flag = FlagImpl(F.IS_OPERATOR)
|
||||
|
||||
/**
|
||||
* Signifies that the corresponding function is `infix`.
|
||||
*/
|
||||
@JvmField
|
||||
val IS_INFIX = Flag(F.IS_INFIX)
|
||||
@Deprecated("$prefix KmFunction.isInfix")
|
||||
val IS_INFIX: Flag = FlagImpl(F.IS_INFIX)
|
||||
|
||||
/**
|
||||
* Signifies that the corresponding function is `inline`.
|
||||
*/
|
||||
@JvmField
|
||||
val IS_INLINE = Flag(F.IS_INLINE)
|
||||
@Deprecated("$prefix KmFunction.isInline")
|
||||
val IS_INLINE: Flag = FlagImpl(F.IS_INLINE)
|
||||
|
||||
/**
|
||||
* Signifies that the corresponding function is `tailrec`.
|
||||
*/
|
||||
@JvmField
|
||||
val IS_TAILREC = Flag(F.IS_TAILREC)
|
||||
@Deprecated("$prefix KmFunction.isTailrec")
|
||||
val IS_TAILREC: Flag = FlagImpl(F.IS_TAILREC)
|
||||
|
||||
/**
|
||||
* Signifies that the corresponding function is `external`.
|
||||
*/
|
||||
@JvmField
|
||||
val IS_EXTERNAL = Flag(F.IS_EXTERNAL_FUNCTION)
|
||||
@Deprecated("$prefix KmFunction.isExternalFunction")
|
||||
val IS_EXTERNAL: Flag = FlagImpl(F.IS_EXTERNAL_FUNCTION)
|
||||
|
||||
/**
|
||||
* Signifies that the corresponding function is `suspend`.
|
||||
*/
|
||||
@JvmField
|
||||
val IS_SUSPEND = Flag(F.IS_SUSPEND)
|
||||
@Deprecated("$prefix KmFunction.isSuspend")
|
||||
val IS_SUSPEND: Flag = FlagImpl(F.IS_SUSPEND)
|
||||
|
||||
/**
|
||||
* Signifies that the corresponding function is `expect`.
|
||||
*/
|
||||
@JvmField
|
||||
val IS_EXPECT = Flag(F.IS_EXPECT_FUNCTION)
|
||||
@Deprecated("$prefix KmFunction.isExpectFunction")
|
||||
val IS_EXPECT: Flag = FlagImpl(F.IS_EXPECT_FUNCTION)
|
||||
|
||||
/**
|
||||
* Signifies that the corresponding function has non-stable parameter names, i.e. cannot be called with named arguments.
|
||||
*/
|
||||
@JvmField
|
||||
val HAS_NON_STABLE_PARAMETER_NAMES = Flag(F.IS_FUNCTION_WITH_NON_STABLE_PARAMETER_NAMES)
|
||||
@Deprecated("$prefix KmFunction.isFunctionWithNonStableParameterNames")
|
||||
val HAS_NON_STABLE_PARAMETER_NAMES: Flag = FlagImpl(F.IS_FUNCTION_WITH_NON_STABLE_PARAMETER_NAMES)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -354,59 +389,67 @@ class Flag(internal val offset: Int, internal val bitWidth: Int, internal val va
|
||||
* A member kind flag, signifying that the corresponding property is explicitly declared in the containing class.
|
||||
*/
|
||||
@JvmField
|
||||
val IS_DECLARATION = Flag(F.MEMBER_KIND, ProtoMemberKind.DECLARATION_VALUE)
|
||||
@Deprecated("$prefix KmProperty.kind")
|
||||
val IS_DECLARATION: Flag = FlagImpl(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
|
||||
val IS_FAKE_OVERRIDE = Flag(F.MEMBER_KIND, ProtoMemberKind.FAKE_OVERRIDE_VALUE)
|
||||
@Deprecated("$prefix KmProperty.kind")
|
||||
val IS_FAKE_OVERRIDE: Flag = FlagImpl(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
|
||||
val IS_DELEGATION = Flag(F.MEMBER_KIND, ProtoMemberKind.DELEGATION_VALUE)
|
||||
@Deprecated("$prefix KmProperty.kind")
|
||||
val IS_DELEGATION: Flag = FlagImpl(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
|
||||
val IS_SYNTHESIZED = Flag(F.MEMBER_KIND, ProtoMemberKind.SYNTHESIZED_VALUE)
|
||||
|
||||
@Deprecated("$prefix KmProperty.kind")
|
||||
val IS_SYNTHESIZED: Flag = FlagImpl(F.MEMBER_KIND, ProtoMemberKind.SYNTHESIZED_VALUE)
|
||||
|
||||
/**
|
||||
* Signifies that the corresponding property is `var`.
|
||||
*/
|
||||
@JvmField
|
||||
val IS_VAR = Flag(F.IS_VAR)
|
||||
@Deprecated("$prefix KmProperty.isVar")
|
||||
val IS_VAR: Flag = FlagImpl(F.IS_VAR)
|
||||
|
||||
/**
|
||||
* Signifies that the corresponding property has a getter.
|
||||
*/
|
||||
@JvmField
|
||||
val HAS_GETTER = Flag(F.HAS_GETTER)
|
||||
@Deprecated("$prefix KmProperty.hasGetter")
|
||||
val HAS_GETTER: Flag = FlagImpl(F.HAS_GETTER)
|
||||
|
||||
/**
|
||||
* Signifies that the corresponding property has a setter.
|
||||
*/
|
||||
@JvmField
|
||||
val HAS_SETTER = Flag(F.HAS_SETTER)
|
||||
@Deprecated("$prefix KmProperty.hasSetter")
|
||||
val HAS_SETTER: Flag = FlagImpl(F.HAS_SETTER)
|
||||
|
||||
/**
|
||||
* Signifies that the corresponding property is `const`.
|
||||
*/
|
||||
@JvmField
|
||||
val IS_CONST = Flag(F.IS_CONST)
|
||||
@Deprecated("$prefix KmProperty.isConst")
|
||||
val IS_CONST: Flag = FlagImpl(F.IS_CONST)
|
||||
|
||||
/**
|
||||
* Signifies that the corresponding property is `lateinit`.
|
||||
*/
|
||||
@JvmField
|
||||
val IS_LATEINIT = Flag(F.IS_LATEINIT)
|
||||
@Deprecated("$prefix KmProperty.isLateinit")
|
||||
val IS_LATEINIT: Flag = FlagImpl(F.IS_LATEINIT)
|
||||
|
||||
/**
|
||||
* Signifies that the corresponding property has a constant value. On JVM, this flag allows an optimization similarly to
|
||||
@@ -414,27 +457,32 @@ class Flag(internal val offset: Int, internal val bitWidth: Int, internal val va
|
||||
* reading the value from the bytecode in case there isn't one.
|
||||
*/
|
||||
@JvmField
|
||||
val HAS_CONSTANT = Flag(F.HAS_CONSTANT)
|
||||
@Deprecated("$prefix KmProperty.hasConstant")
|
||||
val HAS_CONSTANT: Flag = FlagImpl(F.HAS_CONSTANT)
|
||||
|
||||
/**
|
||||
* Signifies that the corresponding property is `external`.
|
||||
*/
|
||||
@JvmField
|
||||
val IS_EXTERNAL = Flag(F.IS_EXTERNAL_PROPERTY)
|
||||
@Deprecated("$prefix KmProperty.isExternal")
|
||||
val IS_EXTERNAL: Flag = FlagImpl(F.IS_EXTERNAL_PROPERTY)
|
||||
|
||||
/**
|
||||
* Signifies that the corresponding property is a delegated property.
|
||||
*/
|
||||
@JvmField
|
||||
val IS_DELEGATED = Flag(F.IS_DELEGATED)
|
||||
@Deprecated("$prefix KmProperty.isDelegated")
|
||||
val IS_DELEGATED: Flag = FlagImpl(F.IS_DELEGATED)
|
||||
|
||||
/**
|
||||
* Signifies that the corresponding property is `expect`.
|
||||
*/
|
||||
@JvmField
|
||||
val IS_EXPECT = Flag(F.IS_EXPECT_PROPERTY)
|
||||
@Deprecated("$prefix KmProperty.isExpect")
|
||||
val IS_EXPECT: Flag = FlagImpl(F.IS_EXPECT_PROPERTY)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A container of flags applicable to Kotlin property getters and setters.
|
||||
*/
|
||||
@@ -443,19 +491,22 @@ class Flag(internal val offset: Int, internal val bitWidth: Int, internal val va
|
||||
* Signifies that the corresponding property accessor is not default, i.e. it has a body and/or annotations in the source code.
|
||||
*/
|
||||
@JvmField
|
||||
val IS_NOT_DEFAULT = Flag(F.IS_NOT_DEFAULT)
|
||||
@Deprecated("$prefix KmPropertyAccessorAttributes.isNotDefault")
|
||||
val IS_NOT_DEFAULT: Flag = FlagImpl(F.IS_NOT_DEFAULT)
|
||||
|
||||
/**
|
||||
* Signifies that the corresponding property accessor is `external`.
|
||||
*/
|
||||
@JvmField
|
||||
val IS_EXTERNAL = Flag(F.IS_EXTERNAL_ACCESSOR)
|
||||
@Deprecated("$prefix KmPropertyAccessorAttributes.isExternal")
|
||||
val IS_EXTERNAL: Flag = FlagImpl(F.IS_EXTERNAL_ACCESSOR)
|
||||
|
||||
/**
|
||||
* Signifies that the corresponding property accessor is `inline`.
|
||||
*/
|
||||
@JvmField
|
||||
val IS_INLINE = Flag(F.IS_INLINE_ACCESSOR)
|
||||
@Deprecated("$prefix KmPropertyAccessorAttributes.isInline")
|
||||
val IS_INLINE: Flag = FlagImpl(F.IS_INLINE_ACCESSOR)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -466,20 +517,23 @@ class Flag(internal val offset: Int, internal val bitWidth: Int, internal val va
|
||||
* Signifies that the corresponding type is marked as nullable, i.e. has a question mark at the end of its notation.
|
||||
*/
|
||||
@JvmField
|
||||
val IS_NULLABLE = Flag(0, 1, 1)
|
||||
@Deprecated("$prefix KmType.isNullable")
|
||||
val IS_NULLABLE: Flag = FlagImpl(0, 1, 1)
|
||||
|
||||
/**
|
||||
* Signifies that the corresponding type is `suspend`.
|
||||
*/
|
||||
@JvmField
|
||||
val IS_SUSPEND = Flag(F.SUSPEND_TYPE.offset + 1, F.SUSPEND_TYPE.bitWidth, 1)
|
||||
@Deprecated("$prefix KmType.isSuspend")
|
||||
val IS_SUSPEND: Flag = FlagImpl(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
|
||||
val IS_DEFINITELY_NON_NULL = Flag(F.DEFINITELY_NOT_NULL_TYPE.offset + 1, F.DEFINITELY_NOT_NULL_TYPE.bitWidth, 1)
|
||||
@Deprecated("$prefix KmType.isDefinitelyNonNull")
|
||||
val IS_DEFINITELY_NON_NULL: Flag = FlagImpl(F.DEFINITELY_NOT_NULL_TYPE.offset + 1, F.DEFINITELY_NOT_NULL_TYPE.bitWidth, 1)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -490,7 +544,8 @@ class Flag(internal val offset: Int, internal val bitWidth: Int, internal val va
|
||||
* Signifies that the corresponding type parameter is `reified`.
|
||||
*/
|
||||
@JvmField
|
||||
val IS_REIFIED = Flag(0, 1, 1)
|
||||
@Deprecated("$prefix KmTypeParameter.isReified")
|
||||
val IS_REIFIED: Flag = FlagImpl(0, 1, 1)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -504,19 +559,22 @@ class Flag(internal val offset: Int, internal val bitWidth: Int, internal val va
|
||||
* still optional at the call site because the default value from the base method is used.
|
||||
*/
|
||||
@JvmField
|
||||
val DECLARES_DEFAULT_VALUE = Flag(F.DECLARES_DEFAULT_VALUE)
|
||||
@Deprecated("$prefix KmValueParameter.declaresDefaultValue")
|
||||
val DECLARES_DEFAULT_VALUE: Flag = FlagImpl(F.DECLARES_DEFAULT_VALUE)
|
||||
|
||||
/**
|
||||
* Signifies that the corresponding value parameter is `crossinline`.
|
||||
*/
|
||||
@JvmField
|
||||
val IS_CROSSINLINE = Flag(F.IS_CROSSINLINE)
|
||||
@Deprecated("$prefix KmValueParameter.isCrossinline")
|
||||
val IS_CROSSINLINE: Flag = FlagImpl(F.IS_CROSSINLINE)
|
||||
|
||||
/**
|
||||
* Signifies that the corresponding value parameter is `noinline`.
|
||||
*/
|
||||
@JvmField
|
||||
val IS_NOINLINE = Flag(F.IS_NOINLINE)
|
||||
@Deprecated("$prefix KmValueParameter.isNoinline")
|
||||
val IS_NOINLINE: Flag = FlagImpl(F.IS_NOINLINE)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -530,12 +588,14 @@ class Flag(internal val offset: Int, internal val bitWidth: Int, internal val va
|
||||
* Signifies that the corresponding effect expression should be negated to compute the proposition or the conclusion of an effect.
|
||||
*/
|
||||
@JvmField
|
||||
val IS_NEGATED = Flag(F.IS_NEGATED)
|
||||
@Deprecated("$prefix KmEffectExpression.isNegated")
|
||||
val IS_NEGATED: Flag = FlagImpl(F.IS_NEGATED)
|
||||
|
||||
/**
|
||||
* Signifies that the corresponding effect expression checks whether a value of some variable is `null`.
|
||||
*/
|
||||
@JvmField
|
||||
val IS_NULL_CHECK_PREDICATE = Flag(F.IS_NULL_CHECK_PREDICATE)
|
||||
@Deprecated("$prefix KmEffectExpression.isNullCheckPredicate")
|
||||
val IS_NULL_CHECK_PREDICATE: Flag = FlagImpl(F.IS_NULL_CHECK_PREDICATE)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,11 +7,17 @@
|
||||
|
||||
package kotlinx.metadata
|
||||
|
||||
import kotlinx.metadata.internal.FlagImpl
|
||||
|
||||
/**
|
||||
* Declaration flags are represented as bitmasks of this type.
|
||||
*
|
||||
* @see Flag
|
||||
*/
|
||||
@Deprecated(
|
||||
"Flags API is deprecated and this typealias will be removed. Use Int directly and then migrate to corresponding Km nodes extensions, e.g. KmClass.visibility",
|
||||
ReplaceWith("Int")
|
||||
)
|
||||
typealias Flags = Int
|
||||
|
||||
/**
|
||||
@@ -21,5 +27,9 @@ 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)`.
|
||||
*/
|
||||
fun flagsOf(vararg flags: Flag): Flags =
|
||||
flags.fold(0) { acc, flag -> flag + acc }
|
||||
@Suppress("DEPRECATION")
|
||||
@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",
|
||||
)
|
||||
fun flagsOf(vararg flags: Flag): Int =
|
||||
flags.fold(0) { acc, flag -> (flag as FlagImpl) + acc }
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
package kotlinx.metadata
|
||||
|
||||
import kotlinx.metadata.internal.Flag
|
||||
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
|
||||
|
||||
@@ -39,7 +39,8 @@ class KmClass : KmClassVisitor(), KmDeclarationContainer {
|
||||
/**
|
||||
* Class flags, consisting of [Flag.HAS_ANNOTATIONS], visibility flag, modality flag and [Flag.Class] flags.
|
||||
*/
|
||||
var flags: Flags = flagsOf()
|
||||
@Deprecated("$flagAccessPrefix KmClass, such as KmClass.visibility")
|
||||
var flags: Int = 0
|
||||
|
||||
/**
|
||||
* Name of the class.
|
||||
@@ -121,33 +122,33 @@ class KmClass : KmClassVisitor(), KmDeclarationContainer {
|
||||
MetadataExtensions.INSTANCES.map(MetadataExtensions::createClassExtension)
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
override fun visit(flags: Flags, name: ClassName) {
|
||||
override fun visit(flags: Int, name: ClassName) {
|
||||
this.flags = flags
|
||||
this.name = name
|
||||
}
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
override fun visitTypeParameter(flags: Flags, name: String, id: Int, variance: KmVariance): KmTypeParameterVisitor =
|
||||
override fun visitTypeParameter(flags: Int, name: String, id: Int, variance: KmVariance): KmTypeParameterVisitor =
|
||||
KmTypeParameter(flags, name, id, variance).addTo(typeParameters)
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
override fun visitSupertype(flags: Flags): KmTypeVisitor =
|
||||
override fun visitSupertype(flags: Int): KmTypeVisitor =
|
||||
KmType(flags).addTo(supertypes)
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
override fun visitFunction(flags: Flags, name: String): KmFunctionVisitor =
|
||||
override fun visitFunction(flags: Int, name: String): KmFunctionVisitor =
|
||||
KmFunction(flags, name).addTo(functions)
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
override fun visitProperty(flags: Flags, name: String, getterFlags: Flags, setterFlags: Flags): KmPropertyVisitor =
|
||||
override fun visitProperty(flags: Int, name: String, getterFlags: Int, setterFlags: Int): KmPropertyVisitor =
|
||||
KmProperty(flags, name, getterFlags, setterFlags).addTo(properties)
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
override fun visitTypeAlias(flags: Flags, name: String): KmTypeAliasVisitor =
|
||||
override fun visitTypeAlias(flags: Int, name: String): KmTypeAliasVisitor =
|
||||
KmTypeAlias(flags, name).addTo(typeAliases)
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
override fun visitConstructor(flags: Flags): KmConstructorVisitor =
|
||||
override fun visitConstructor(flags: Int): KmConstructorVisitor =
|
||||
KmConstructor(flags).addTo(constructors)
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
@@ -176,12 +177,12 @@ class KmClass : KmClassVisitor(), KmDeclarationContainer {
|
||||
}
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
override fun visitInlineClassUnderlyingType(flags: Flags): KmTypeVisitor =
|
||||
override fun visitInlineClassUnderlyingType(flags: Int): KmTypeVisitor =
|
||||
KmType(flags).also { inlineClassUnderlyingType = it }
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
@ExperimentalContextReceivers
|
||||
override fun visitContextReceiverType(flags: Flags): KmTypeVisitor =
|
||||
override fun visitContextReceiverType(flags: Int): KmTypeVisitor =
|
||||
KmType(flags).addTo(contextReceiverTypes)
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
@@ -246,15 +247,15 @@ class KmPackage : KmPackageVisitor(), KmDeclarationContainer {
|
||||
MetadataExtensions.INSTANCES.map(MetadataExtensions::createPackageExtension)
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
override fun visitFunction(flags: Flags, name: String): KmFunctionVisitor =
|
||||
override fun visitFunction(flags: Int, name: String): KmFunctionVisitor =
|
||||
KmFunction(flags, name).addTo(functions)
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
override fun visitProperty(flags: Flags, name: String, getterFlags: Flags, setterFlags: Flags): KmPropertyVisitor =
|
||||
override fun visitProperty(flags: Int, name: String, getterFlags: Int, setterFlags: Int): KmPropertyVisitor =
|
||||
KmProperty(flags, name, getterFlags, setterFlags).addTo(properties)
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
override fun visitTypeAlias(flags: Flags, name: String): KmTypeAliasVisitor =
|
||||
override fun visitTypeAlias(flags: Int, name: String): KmTypeAliasVisitor =
|
||||
KmTypeAlias(flags, name).addTo(typeAliases)
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
@@ -287,7 +288,7 @@ class KmLambda : KmLambdaVisitor() {
|
||||
lateinit var function: KmFunction
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
override fun visitFunction(flags: Flags, name: String): KmFunctionVisitor =
|
||||
override fun visitFunction(flags: Int, name: String): KmFunctionVisitor =
|
||||
KmFunction(flags, name).also { function = it }
|
||||
|
||||
/**
|
||||
@@ -308,7 +309,9 @@ class KmLambda : KmLambdaVisitor() {
|
||||
* @property flags constructor flags, consisting of [Flag.HAS_ANNOTATIONS], a visibility flag and [Flag.Constructor] flags
|
||||
*/
|
||||
@Suppress("DEPRECATION")
|
||||
class KmConstructor @Deprecated(FLAGS_CTOR_DEPRECATED) constructor(var flags: Flags) :
|
||||
class KmConstructor @Deprecated(flagsCtorDeprecated) constructor(
|
||||
@Deprecated("$flagAccessPrefix KmConstructor, such as KmConstructor.visibility") var flags: Int,
|
||||
) :
|
||||
KmConstructorVisitor() {
|
||||
constructor() : this(0)
|
||||
|
||||
@@ -326,7 +329,7 @@ class KmConstructor @Deprecated(FLAGS_CTOR_DEPRECATED) constructor(var flags: Fl
|
||||
MetadataExtensions.INSTANCES.map(MetadataExtensions::createConstructorExtension)
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
override fun visitValueParameter(flags: Flags, name: String): KmValueParameterVisitor =
|
||||
override fun visitValueParameter(flags: Int, name: String): KmValueParameterVisitor =
|
||||
KmValueParameter(flags, name).addTo(valueParameters)
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
@@ -358,8 +361,8 @@ class KmConstructor @Deprecated(FLAGS_CTOR_DEPRECATED) constructor(var flags: Fl
|
||||
* @property name the name of the function
|
||||
*/
|
||||
@Suppress("DEPRECATION")
|
||||
class KmFunction @Deprecated(FLAGS_CTOR_DEPRECATED) constructor(
|
||||
var flags: Flags,
|
||||
class KmFunction @Deprecated(flagsCtorDeprecated) constructor(
|
||||
@Deprecated("$flagAccessPrefix KmFunction, such as KmFunction.visibility") var flags: Int,
|
||||
var name: String,
|
||||
) : KmFunctionVisitor() {
|
||||
|
||||
@@ -406,24 +409,24 @@ class KmFunction @Deprecated(FLAGS_CTOR_DEPRECATED) constructor(
|
||||
MetadataExtensions.INSTANCES.map(MetadataExtensions::createFunctionExtension)
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
override fun visitTypeParameter(flags: Flags, name: String, id: Int, variance: KmVariance): KmTypeParameterVisitor =
|
||||
override fun visitTypeParameter(flags: Int, name: String, id: Int, variance: KmVariance): KmTypeParameterVisitor =
|
||||
KmTypeParameter(flags, name, id, variance).addTo(typeParameters)
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
override fun visitReceiverParameterType(flags: Flags): KmTypeVisitor =
|
||||
override fun visitReceiverParameterType(flags: Int): KmTypeVisitor =
|
||||
KmType(flags).also { receiverParameterType = it }
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
@ExperimentalContextReceivers
|
||||
override fun visitContextReceiverType(flags: Flags): KmTypeVisitor =
|
||||
override fun visitContextReceiverType(flags: Int): KmTypeVisitor =
|
||||
KmType(flags).addTo(contextReceiverTypes)
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
override fun visitValueParameter(flags: Flags, name: String): KmValueParameterVisitor =
|
||||
override fun visitValueParameter(flags: Int, name: String): KmValueParameterVisitor =
|
||||
KmValueParameter(flags, name).addTo(valueParameters)
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
override fun visitReturnType(flags: Flags): KmTypeVisitor =
|
||||
override fun visitReturnType(flags: Int): KmTypeVisitor =
|
||||
KmType(flags).also { returnType = it }
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
@@ -464,7 +467,7 @@ class KmFunction @Deprecated(FLAGS_CTOR_DEPRECATED) constructor(
|
||||
* Does not contain meaningful information except attributes, such as visibility and modality.
|
||||
* Attributes can be read and written using extension functions, e.g. [KmPropertyAccessorAttributes.visibility] or [KmPropertyAccessorAttributes.isNotDefault].
|
||||
*/
|
||||
public class KmPropertyAccessorAttributes internal constructor(internal var flags: Flags) {
|
||||
public class KmPropertyAccessorAttributes internal constructor(internal var flags: Int) {
|
||||
public constructor() : this(0)
|
||||
}
|
||||
|
||||
@@ -475,11 +478,11 @@ public class KmPropertyAccessorAttributes internal constructor(internal var flag
|
||||
* @property name the name of the property
|
||||
*/
|
||||
@Suppress("DEPRECATION")
|
||||
class KmProperty @Deprecated(FLAGS_CTOR_DEPRECATED) constructor(
|
||||
var flags: Flags,
|
||||
class KmProperty @Deprecated(flagsCtorDeprecated) constructor(
|
||||
@Deprecated("$flagAccessPrefix KmProperty, such as KmProperty.visibility") var flags: Int,
|
||||
var name: String,
|
||||
getterFlags: Flags,
|
||||
setterFlags: Flags,
|
||||
getterFlags: Int,
|
||||
setterFlags: Int,
|
||||
) : KmPropertyVisitor() {
|
||||
|
||||
constructor(name: String) : this(0, name, 0, 0)
|
||||
@@ -510,7 +513,8 @@ class KmProperty @Deprecated(FLAGS_CTOR_DEPRECATED) constructor(
|
||||
* Property accessor flags, consisting of [Flag.HAS_ANNOTATIONS], visibility flag, modality flag
|
||||
* and [Flag.PropertyAccessor] flags.
|
||||
*/
|
||||
var getterFlags: Flags
|
||||
@Deprecated("$flagAccessPrefix KmProperty.getter, such as KmProperty.getter.isNotDefault")
|
||||
var getterFlags: Int
|
||||
get() = getter.flags
|
||||
set(value) {
|
||||
getter.flags = value
|
||||
@@ -530,7 +534,8 @@ class KmProperty @Deprecated(FLAGS_CTOR_DEPRECATED) 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.
|
||||
*/
|
||||
var setterFlags: Flags = getDefaultPropertyAccessorFlags(flags)
|
||||
@Deprecated("$flagAccessPrefix KmProperty.setter, such as KmProperty.setter.isNotDefault")
|
||||
var setterFlags: Int = getDefaultPropertyAccessorFlags(flags)
|
||||
get() = setter?.flags ?: field
|
||||
set(value) {
|
||||
setter?.flags = value
|
||||
@@ -580,24 +585,24 @@ class KmProperty @Deprecated(FLAGS_CTOR_DEPRECATED) constructor(
|
||||
MetadataExtensions.INSTANCES.map(MetadataExtensions::createPropertyExtension)
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
override fun visitTypeParameter(flags: Flags, name: String, id: Int, variance: KmVariance): KmTypeParameterVisitor =
|
||||
override fun visitTypeParameter(flags: Int, name: String, id: Int, variance: KmVariance): KmTypeParameterVisitor =
|
||||
KmTypeParameter(flags, name, id, variance).addTo(typeParameters)
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
override fun visitReceiverParameterType(flags: Flags): KmTypeVisitor =
|
||||
override fun visitReceiverParameterType(flags: Int): KmTypeVisitor =
|
||||
KmType(flags).also { receiverParameterType = it }
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
@ExperimentalContextReceivers
|
||||
override fun visitContextReceiverType(flags: Flags): KmTypeVisitor =
|
||||
override fun visitContextReceiverType(flags: Int): KmTypeVisitor =
|
||||
KmType(flags).addTo(contextReceiverTypes)
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
override fun visitSetterParameter(flags: Flags, name: String): KmValueParameterVisitor =
|
||||
override fun visitSetterParameter(flags: Int, name: String): KmValueParameterVisitor =
|
||||
KmValueParameter(flags, name).also { setterParameter = it }
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
override fun visitReturnType(flags: Flags): KmTypeVisitor =
|
||||
override fun visitReturnType(flags: Int): KmTypeVisitor =
|
||||
KmType(flags).also { returnType = it }
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
@@ -634,8 +639,8 @@ class KmProperty @Deprecated(FLAGS_CTOR_DEPRECATED) constructor(
|
||||
* @property name the name of the type alias
|
||||
*/
|
||||
@Suppress("DEPRECATION")
|
||||
class KmTypeAlias @Deprecated(FLAGS_CTOR_DEPRECATED) constructor(
|
||||
var flags: Flags,
|
||||
class KmTypeAlias @Deprecated(flagsCtorDeprecated) constructor(
|
||||
@Deprecated("$flagAccessPrefix KmTypeAlias, such as KmTypeAlias.visibility") var flags: Int,
|
||||
var name: String,
|
||||
) : KmTypeAliasVisitor() {
|
||||
|
||||
@@ -671,15 +676,15 @@ class KmTypeAlias @Deprecated(FLAGS_CTOR_DEPRECATED) constructor(
|
||||
MetadataExtensions.INSTANCES.mapNotNull(MetadataExtensions::createTypeAliasExtension)
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
override fun visitTypeParameter(flags: Flags, name: String, id: Int, variance: KmVariance): KmTypeParameterVisitor =
|
||||
override fun visitTypeParameter(flags: Int, name: String, id: Int, variance: KmVariance): KmTypeParameterVisitor =
|
||||
KmTypeParameter(flags, name, id, variance).addTo(typeParameters)
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
override fun visitUnderlyingType(flags: Flags): KmTypeVisitor =
|
||||
override fun visitUnderlyingType(flags: Int): KmTypeVisitor =
|
||||
KmType(flags).also { underlyingType = it }
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
override fun visitExpandedType(flags: Flags): KmTypeVisitor =
|
||||
override fun visitExpandedType(flags: Int): KmTypeVisitor =
|
||||
KmType(flags).also { expandedType = it }
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
@@ -719,8 +724,8 @@ class KmTypeAlias @Deprecated(FLAGS_CTOR_DEPRECATED) constructor(
|
||||
* @property name the name of the value parameter
|
||||
*/
|
||||
@Suppress("DEPRECATION")
|
||||
class KmValueParameter @Deprecated(FLAGS_CTOR_DEPRECATED) constructor(
|
||||
var flags: Flags,
|
||||
class KmValueParameter @Deprecated(flagsCtorDeprecated) constructor(
|
||||
@Deprecated("$flagAccessPrefix KmValueParameter, such as KmValueParameter.declaresDefaultValue") var flags: Int,
|
||||
var name: String,
|
||||
) : KmValueParameterVisitor() {
|
||||
|
||||
@@ -741,11 +746,11 @@ class KmValueParameter @Deprecated(FLAGS_CTOR_DEPRECATED) constructor(
|
||||
MetadataExtensions.INSTANCES.mapNotNull(MetadataExtensions::createValueParameterExtension)
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
override fun visitType(flags: Flags): KmTypeVisitor =
|
||||
override fun visitType(flags: Int): KmTypeVisitor =
|
||||
KmType(flags).also { type = it }
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
override fun visitVarargElementType(flags: Flags): KmTypeVisitor =
|
||||
override fun visitVarargElementType(flags: Int): KmTypeVisitor =
|
||||
KmType(flags).also { varargElementType = it }
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
@@ -776,8 +781,8 @@ class KmValueParameter @Deprecated(FLAGS_CTOR_DEPRECATED) constructor(
|
||||
* @property variance the declaration-site variance of the type parameter
|
||||
*/
|
||||
@Suppress("DEPRECATION")
|
||||
class KmTypeParameter @Deprecated(FLAGS_CTOR_DEPRECATED) constructor(
|
||||
var flags: Flags,
|
||||
class KmTypeParameter @Deprecated(flagsCtorDeprecated) constructor(
|
||||
@Deprecated("$flagAccessPrefix KmTypeParameter, such as KmTypeParameter.isReified") var flags: Int,
|
||||
var name: String,
|
||||
var id: Int,
|
||||
var variance: KmVariance,
|
||||
@@ -794,7 +799,7 @@ class KmTypeParameter @Deprecated(FLAGS_CTOR_DEPRECATED) constructor(
|
||||
MetadataExtensions.INSTANCES.map(MetadataExtensions::createTypeParameterExtension)
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
override fun visitUpperBound(flags: Flags): KmTypeVisitor =
|
||||
override fun visitUpperBound(flags: Int): KmTypeVisitor =
|
||||
KmType(flags).addTo(upperBounds)
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
@@ -820,7 +825,9 @@ class KmTypeParameter @Deprecated(FLAGS_CTOR_DEPRECATED) constructor(
|
||||
* @property flags type flags, consisting of [Flag.Type] flags
|
||||
*/
|
||||
@Suppress("DEPRECATION")
|
||||
class KmType @Deprecated(FLAGS_CTOR_DEPRECATED) constructor(var flags: Flags) : KmTypeVisitor() {
|
||||
class KmType @Deprecated(flagsCtorDeprecated) constructor(
|
||||
@Deprecated("$flagAccessPrefix KmType, such as KmType.isNullable") var flags: Int
|
||||
) : KmTypeVisitor() {
|
||||
|
||||
constructor() : this(0)
|
||||
|
||||
@@ -883,7 +890,7 @@ class KmType @Deprecated(FLAGS_CTOR_DEPRECATED) constructor(var flags: Flags) :
|
||||
}
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
override fun visitArgument(flags: Flags, variance: KmVariance): KmTypeVisitor =
|
||||
override fun visitArgument(flags: Int, variance: KmVariance): KmTypeVisitor =
|
||||
KmType(flags).also { arguments.add(KmTypeProjection(variance, it)) }
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
@@ -892,15 +899,15 @@ class KmType @Deprecated(FLAGS_CTOR_DEPRECATED) constructor(var flags: Flags) :
|
||||
}
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
override fun visitAbbreviatedType(flags: Flags): KmTypeVisitor =
|
||||
override fun visitAbbreviatedType(flags: Int): KmTypeVisitor =
|
||||
KmType(flags).also { abbreviatedType = it }
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
override fun visitOuterType(flags: Flags): KmTypeVisitor =
|
||||
override fun visitOuterType(flags: Int): KmTypeVisitor =
|
||||
KmType(flags).also { outerType = it }
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
override fun visitFlexibleTypeUpperBound(flags: Flags, typeFlexibilityId: String?): KmTypeVisitor =
|
||||
override fun visitFlexibleTypeUpperBound(flags: Int, typeFlexibilityId: String?): KmTypeVisitor =
|
||||
KmType(flags).also { flexibleTypeUpperBound = KmFlexibleTypeUpperBound(it, typeFlexibilityId) }
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
@@ -1086,7 +1093,8 @@ class KmEffectExpression : KmEffectExpressionVisitor() {
|
||||
/**
|
||||
* Effect expression flags, consisting of [Flag.EffectExpression] flags.
|
||||
*/
|
||||
var flags: Flags = flagsOf()
|
||||
@Deprecated("$flagAccessPrefix KmEffectExpression, such as KmEffectExpression.isNegated")
|
||||
var flags: Int = flagsOf()
|
||||
|
||||
/**
|
||||
* Optional 1-based index of the value parameter of the function, for effects which assert something about
|
||||
@@ -1117,7 +1125,7 @@ class KmEffectExpression : KmEffectExpressionVisitor() {
|
||||
val orArguments: MutableList<KmEffectExpression> = ArrayList(0)
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
override fun visit(flags: Flags, parameterIndex: Int?) {
|
||||
override fun visit(flags: Int, parameterIndex: Int?) {
|
||||
this.flags = flags
|
||||
this.parameterIndex = parameterIndex
|
||||
}
|
||||
@@ -1128,7 +1136,7 @@ class KmEffectExpression : KmEffectExpressionVisitor() {
|
||||
}
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
override fun visitIsInstanceType(flags: Flags): KmTypeVisitor =
|
||||
override fun visitIsInstanceType(flags: Int): KmTypeVisitor =
|
||||
KmType(flags).also { isInstanceType = it }
|
||||
|
||||
@Deprecated(VISITOR_API_MESSAGE)
|
||||
@@ -1244,5 +1252,7 @@ internal fun <T> T.addTo(collection: MutableCollection<T>): T {
|
||||
return this
|
||||
}
|
||||
|
||||
private const val FLAGS_CTOR_DEPRECATED =
|
||||
private const val flagsCtorDeprecated =
|
||||
"Constructor with flags is deprecated, use constructor without flags and assign them or corresponding extension properties directly."
|
||||
|
||||
private const val flagAccessPrefix = "Flag API is deprecated. Please use corresponding member extensions on"
|
||||
|
||||
@@ -22,7 +22,7 @@ abstract class KmDeclarationContainerVisitor @JvmOverloads constructor(protected
|
||||
* @param flags function flags, consisting of [Flag.HAS_ANNOTATIONS], visibility flag, modality flag and [Flag.Function] flags
|
||||
* @param name the name of the function
|
||||
*/
|
||||
open fun visitFunction(flags: Flags, name: String): KmFunctionVisitor? =
|
||||
open fun visitFunction(flags: Int, name: String): KmFunctionVisitor? =
|
||||
delegate?.visitFunction(flags, name)
|
||||
|
||||
/**
|
||||
@@ -35,7 +35,7 @@ abstract class KmDeclarationContainerVisitor @JvmOverloads constructor(protected
|
||||
* @param setterFlags property accessor flags, consisting of [Flag.HAS_ANNOTATIONS], visibility flag, modality flag
|
||||
* and [Flag.PropertyAccessor] flags
|
||||
*/
|
||||
open fun visitProperty(flags: Flags, name: String, getterFlags: Flags, setterFlags: Flags): KmPropertyVisitor? =
|
||||
open fun visitProperty(flags: Int, name: String, getterFlags: Int, setterFlags: Int): KmPropertyVisitor? =
|
||||
delegate?.visitProperty(flags, name, getterFlags, setterFlags)
|
||||
|
||||
/**
|
||||
@@ -44,7 +44,7 @@ abstract class KmDeclarationContainerVisitor @JvmOverloads constructor(protected
|
||||
* @param flags type alias flags, consisting of [Flag.HAS_ANNOTATIONS] and visibility flag
|
||||
* @param name the name of the type alias
|
||||
*/
|
||||
open fun visitTypeAlias(flags: Flags, name: String): KmTypeAliasVisitor? =
|
||||
open fun visitTypeAlias(flags: Int, name: String): KmTypeAliasVisitor? =
|
||||
delegate?.visitTypeAlias(flags, name)
|
||||
|
||||
/**
|
||||
@@ -73,7 +73,7 @@ abstract class KmClassVisitor @JvmOverloads constructor(delegate: KmClassVisitor
|
||||
* @param flags class flags, consisting of [Flag.HAS_ANNOTATIONS], visibility flag, modality flag and [Flag.Class] flags
|
||||
* @param name the name of the class
|
||||
*/
|
||||
open fun visit(flags: Flags, name: ClassName) {
|
||||
open fun visit(flags: Int, name: ClassName) {
|
||||
delegate?.visit(flags, name)
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ abstract class KmClassVisitor @JvmOverloads constructor(delegate: KmClassVisitor
|
||||
* the name isn't enough (e.g. `class A<T> { fun <T> foo(t: T) }`)
|
||||
* @param variance the declaration-site variance of the type parameter
|
||||
*/
|
||||
open fun visitTypeParameter(flags: Flags, name: String, id: Int, variance: KmVariance): KmTypeParameterVisitor? =
|
||||
open fun visitTypeParameter(flags: Int, name: String, id: Int, variance: KmVariance): KmTypeParameterVisitor? =
|
||||
delegate?.visitTypeParameter(flags, name, id, variance)
|
||||
|
||||
/**
|
||||
@@ -94,7 +94,7 @@ abstract class KmClassVisitor @JvmOverloads constructor(delegate: KmClassVisitor
|
||||
*
|
||||
* @param flags type flags, consisting of [Flag.Type] flags
|
||||
*/
|
||||
open fun visitSupertype(flags: Flags): KmTypeVisitor? =
|
||||
open fun visitSupertype(flags: Int): KmTypeVisitor? =
|
||||
delegate?.visitSupertype(flags)
|
||||
|
||||
/**
|
||||
@@ -102,7 +102,7 @@ abstract class KmClassVisitor @JvmOverloads constructor(delegate: KmClassVisitor
|
||||
*
|
||||
* @param flags constructor flags, consisting of [Flag.HAS_ANNOTATIONS], visibility flag and [Flag.Constructor] flags
|
||||
*/
|
||||
open fun visitConstructor(flags: Flags): KmConstructorVisitor? =
|
||||
open fun visitConstructor(flags: Int): KmConstructorVisitor? =
|
||||
delegate?.visitConstructor(flags)
|
||||
|
||||
/**
|
||||
@@ -155,7 +155,7 @@ abstract class KmClassVisitor @JvmOverloads constructor(delegate: KmClassVisitor
|
||||
*
|
||||
* @param flags type flags, consisting of [Flag.Type] flags
|
||||
*/
|
||||
open fun visitInlineClassUnderlyingType(flags: Flags): KmTypeVisitor? =
|
||||
open fun visitInlineClassUnderlyingType(flags: Int): KmTypeVisitor? =
|
||||
delegate?.visitInlineClassUnderlyingType(flags)
|
||||
|
||||
/**
|
||||
@@ -164,7 +164,7 @@ abstract class KmClassVisitor @JvmOverloads constructor(delegate: KmClassVisitor
|
||||
* @param flags type flags, consisting of [Flag.Type] flags
|
||||
*/
|
||||
@ExperimentalContextReceivers
|
||||
open fun visitContextReceiverType(flags: Flags): KmTypeVisitor? =
|
||||
open fun visitContextReceiverType(flags: Int): KmTypeVisitor? =
|
||||
delegate?.visitContextReceiverType(flags)
|
||||
|
||||
/**
|
||||
@@ -230,7 +230,7 @@ abstract class KmLambdaVisitor @JvmOverloads constructor(private val delegate: K
|
||||
* @param flags function flags, consisting of [Flag.HAS_ANNOTATIONS], visibility flag, modality flag and [Flag.Function] flags
|
||||
* @param name the name of the function (usually `"<anonymous>"` or `"<no name provided>"` for lambdas emitted by the Kotlin compiler)
|
||||
*/
|
||||
open fun visitFunction(flags: Flags, name: String): KmFunctionVisitor? =
|
||||
open fun visitFunction(flags: Int, name: String): KmFunctionVisitor? =
|
||||
delegate?.visitFunction(flags, name)
|
||||
|
||||
/**
|
||||
@@ -255,7 +255,7 @@ abstract class KmConstructorVisitor @JvmOverloads constructor(private val delega
|
||||
* @param flags value parameter flags, consisting of [Flag.ValueParameter] flags
|
||||
* @param name the name of the value parameter
|
||||
*/
|
||||
open fun visitValueParameter(flags: Flags, name: String): KmValueParameterVisitor? =
|
||||
open fun visitValueParameter(flags: Int, name: String): KmValueParameterVisitor? =
|
||||
delegate?.visitValueParameter(flags, name)
|
||||
|
||||
/**
|
||||
@@ -298,7 +298,7 @@ abstract class KmFunctionVisitor @JvmOverloads constructor(private val delegate:
|
||||
* the name isn't enough (e.g. `class A<T> { fun <T> foo(t: T) }`)
|
||||
* @param variance the declaration-site variance of the type parameter
|
||||
*/
|
||||
open fun visitTypeParameter(flags: Flags, name: String, id: Int, variance: KmVariance): KmTypeParameterVisitor? =
|
||||
open fun visitTypeParameter(flags: Int, name: String, id: Int, variance: KmVariance): KmTypeParameterVisitor? =
|
||||
delegate?.visitTypeParameter(flags, name, id, variance)
|
||||
|
||||
/**
|
||||
@@ -306,7 +306,7 @@ abstract class KmFunctionVisitor @JvmOverloads constructor(private val delegate:
|
||||
*
|
||||
* @param flags type flags, consisting of [Flag.Type] flags
|
||||
*/
|
||||
open fun visitReceiverParameterType(flags: Flags): KmTypeVisitor? =
|
||||
open fun visitReceiverParameterType(flags: Int): KmTypeVisitor? =
|
||||
delegate?.visitReceiverParameterType(flags)
|
||||
|
||||
/**
|
||||
@@ -315,7 +315,7 @@ abstract class KmFunctionVisitor @JvmOverloads constructor(private val delegate:
|
||||
* @param flags type flags, consisting of [Flag.Type] flags
|
||||
*/
|
||||
@ExperimentalContextReceivers
|
||||
open fun visitContextReceiverType(flags: Flags): KmTypeVisitor? =
|
||||
open fun visitContextReceiverType(flags: Int): KmTypeVisitor? =
|
||||
delegate?.visitContextReceiverType(flags)
|
||||
|
||||
/**
|
||||
@@ -324,7 +324,7 @@ abstract class KmFunctionVisitor @JvmOverloads constructor(private val delegate:
|
||||
* @param flags value parameter flags, consisting of [Flag.ValueParameter] flags
|
||||
* @param name the name of the value parameter
|
||||
*/
|
||||
open fun visitValueParameter(flags: Flags, name: String): KmValueParameterVisitor? =
|
||||
open fun visitValueParameter(flags: Int, name: String): KmValueParameterVisitor? =
|
||||
delegate?.visitValueParameter(flags, name)
|
||||
|
||||
/**
|
||||
@@ -332,7 +332,7 @@ abstract class KmFunctionVisitor @JvmOverloads constructor(private val delegate:
|
||||
*
|
||||
* @param flags type flags, consisting of [Flag.Type] flags
|
||||
*/
|
||||
open fun visitReturnType(flags: Flags): KmTypeVisitor? =
|
||||
open fun visitReturnType(flags: Int): KmTypeVisitor? =
|
||||
delegate?.visitReturnType(flags)
|
||||
|
||||
/**
|
||||
@@ -382,7 +382,7 @@ abstract class KmPropertyVisitor @JvmOverloads constructor(private val delegate:
|
||||
* the name isn't enough (e.g. `class A<T> { fun <T> foo(t: T) }`)
|
||||
* @param variance the declaration-site variance of the type parameter
|
||||
*/
|
||||
open fun visitTypeParameter(flags: Flags, name: String, id: Int, variance: KmVariance): KmTypeParameterVisitor? =
|
||||
open fun visitTypeParameter(flags: Int, name: String, id: Int, variance: KmVariance): KmTypeParameterVisitor? =
|
||||
delegate?.visitTypeParameter(flags, name, id, variance)
|
||||
|
||||
/**
|
||||
@@ -390,7 +390,7 @@ abstract class KmPropertyVisitor @JvmOverloads constructor(private val delegate:
|
||||
*
|
||||
* @param flags type flags, consisting of [Flag.Type] flags
|
||||
*/
|
||||
open fun visitReceiverParameterType(flags: Flags): KmTypeVisitor? =
|
||||
open fun visitReceiverParameterType(flags: Int): KmTypeVisitor? =
|
||||
delegate?.visitReceiverParameterType(flags)
|
||||
|
||||
/**
|
||||
@@ -399,7 +399,7 @@ abstract class KmPropertyVisitor @JvmOverloads constructor(private val delegate:
|
||||
* @param flags type flags, consisting of [Flag.Type] flags
|
||||
*/
|
||||
@ExperimentalContextReceivers
|
||||
open fun visitContextReceiverType(flags: Flags): KmTypeVisitor? =
|
||||
open fun visitContextReceiverType(flags: Int): KmTypeVisitor? =
|
||||
delegate?.visitContextReceiverType(flags)
|
||||
|
||||
/**
|
||||
@@ -408,7 +408,7 @@ abstract class KmPropertyVisitor @JvmOverloads constructor(private val delegate:
|
||||
* @param flags value parameter flags, consisting of [Flag.ValueParameter] flags
|
||||
* @param name the name of the value parameter (`"<set-?>"` for properties emitted by the Kotlin compiler)
|
||||
*/
|
||||
open fun visitSetterParameter(flags: Flags, name: String): KmValueParameterVisitor? =
|
||||
open fun visitSetterParameter(flags: Int, name: String): KmValueParameterVisitor? =
|
||||
delegate?.visitSetterParameter(flags, name)
|
||||
|
||||
/**
|
||||
@@ -416,7 +416,7 @@ abstract class KmPropertyVisitor @JvmOverloads constructor(private val delegate:
|
||||
*
|
||||
* @param flags type flags, consisting of [Flag.Type] flags
|
||||
*/
|
||||
open fun visitReturnType(flags: Flags): KmTypeVisitor? =
|
||||
open fun visitReturnType(flags: Int): KmTypeVisitor? =
|
||||
delegate?.visitReturnType(flags)
|
||||
|
||||
/**
|
||||
@@ -459,7 +459,7 @@ abstract class KmTypeAliasVisitor @JvmOverloads constructor(private val delegate
|
||||
* the name isn't enough (e.g. `class A<T> { fun <T> foo(t: T) }`)
|
||||
* @param variance the declaration-site variance of the type parameter
|
||||
*/
|
||||
open fun visitTypeParameter(flags: Flags, name: String, id: Int, variance: KmVariance): KmTypeParameterVisitor? =
|
||||
open fun visitTypeParameter(flags: Int, name: String, id: Int, variance: KmVariance): KmTypeParameterVisitor? =
|
||||
delegate?.visitTypeParameter(flags, name, id, variance)
|
||||
|
||||
/**
|
||||
@@ -467,7 +467,7 @@ abstract class KmTypeAliasVisitor @JvmOverloads constructor(private val delegate
|
||||
*
|
||||
* @param flags type flags, consisting of [Flag.Type] flags
|
||||
*/
|
||||
open fun visitUnderlyingType(flags: Flags): KmTypeVisitor? =
|
||||
open fun visitUnderlyingType(flags: Int): KmTypeVisitor? =
|
||||
delegate?.visitUnderlyingType(flags)
|
||||
|
||||
/**
|
||||
@@ -476,7 +476,7 @@ abstract class KmTypeAliasVisitor @JvmOverloads constructor(private val delegate
|
||||
*
|
||||
* @param flags type flags, consisting of [Flag.Type] flags
|
||||
*/
|
||||
open fun visitExpandedType(flags: Flags): KmTypeVisitor? =
|
||||
open fun visitExpandedType(flags: Int): KmTypeVisitor? =
|
||||
delegate?.visitExpandedType(flags)
|
||||
|
||||
/**
|
||||
@@ -524,7 +524,7 @@ abstract class KmValueParameterVisitor @JvmOverloads constructor(private val del
|
||||
*
|
||||
* @param flags type flags, consisting of [Flag.Type] flags
|
||||
*/
|
||||
open fun visitType(flags: Flags): KmTypeVisitor? =
|
||||
open fun visitType(flags: Int): KmTypeVisitor? =
|
||||
delegate?.visitType(flags)
|
||||
|
||||
/**
|
||||
@@ -532,7 +532,7 @@ abstract class KmValueParameterVisitor @JvmOverloads constructor(private val del
|
||||
*
|
||||
* @param flags type flags, consisting of [Flag.Type] flags
|
||||
*/
|
||||
open fun visitVarargElementType(flags: Flags): KmTypeVisitor? =
|
||||
open fun visitVarargElementType(flags: Int): KmTypeVisitor? =
|
||||
delegate?.visitVarargElementType(flags)
|
||||
|
||||
/**
|
||||
@@ -564,7 +564,7 @@ abstract class KmTypeParameterVisitor @JvmOverloads constructor(private val dele
|
||||
*
|
||||
* @param flags type flags, consisting of [Flag.Type] flags
|
||||
*/
|
||||
open fun visitUpperBound(flags: Flags): KmTypeVisitor? =
|
||||
open fun visitUpperBound(flags: Int): KmTypeVisitor? =
|
||||
delegate?.visitUpperBound(flags)
|
||||
|
||||
/**
|
||||
@@ -632,7 +632,7 @@ abstract class KmTypeVisitor @JvmOverloads constructor(private val delegate: KmT
|
||||
* @param flags type flags, consisting of [Flag.Type] flags
|
||||
* @param variance the variance of the type projection
|
||||
*/
|
||||
open fun visitArgument(flags: Flags, variance: KmVariance): KmTypeVisitor? =
|
||||
open fun visitArgument(flags: Int, variance: KmVariance): KmTypeVisitor? =
|
||||
delegate?.visitArgument(flags, variance)
|
||||
|
||||
/**
|
||||
@@ -654,7 +654,7 @@ abstract class KmTypeVisitor @JvmOverloads constructor(private val delegate: KmT
|
||||
*
|
||||
* @param flags type flags, consisting of [Flag.Type] flags
|
||||
*/
|
||||
open fun visitAbbreviatedType(flags: Flags): KmTypeVisitor? =
|
||||
open fun visitAbbreviatedType(flags: Int): KmTypeVisitor? =
|
||||
delegate?.visitAbbreviatedType(flags)
|
||||
|
||||
/**
|
||||
@@ -669,7 +669,7 @@ abstract class KmTypeVisitor @JvmOverloads constructor(private val delegate: KmT
|
||||
*
|
||||
* @param flags type flags, consisting of [Flag.Type] flags
|
||||
*/
|
||||
open fun visitOuterType(flags: Flags): KmTypeVisitor? =
|
||||
open fun visitOuterType(flags: Int): KmTypeVisitor? =
|
||||
delegate?.visitOuterType(flags)
|
||||
|
||||
/**
|
||||
@@ -680,7 +680,7 @@ abstract class KmTypeVisitor @JvmOverloads constructor(private val delegate: KmT
|
||||
* @param typeFlexibilityId id of the kind of flexibility this type has. For example, "kotlin.jvm.PlatformType" for JVM platform types,
|
||||
* or "kotlin.DynamicType" for JS dynamic type
|
||||
*/
|
||||
open fun visitFlexibleTypeUpperBound(flags: Flags, typeFlexibilityId: String?): KmTypeVisitor? =
|
||||
open fun visitFlexibleTypeUpperBound(flags: Int, typeFlexibilityId: String?): KmTypeVisitor? =
|
||||
delegate?.visitFlexibleTypeUpperBound(flags, typeFlexibilityId)
|
||||
|
||||
/**
|
||||
@@ -825,7 +825,7 @@ abstract class KmEffectExpressionVisitor @JvmOverloads constructor(private val d
|
||||
* @param parameterIndex optional 1-based index of the value parameter of the function, for effects which assert something about
|
||||
* the function parameters. The index 0 means the extension receiver parameter
|
||||
*/
|
||||
open fun visit(flags: Flags, parameterIndex: Int?) {
|
||||
open fun visit(flags: Int, parameterIndex: Int?) {
|
||||
delegate?.visit(flags, parameterIndex)
|
||||
}
|
||||
|
||||
@@ -843,7 +843,7 @@ abstract class KmEffectExpressionVisitor @JvmOverloads constructor(private val d
|
||||
*
|
||||
* @param flags type flags, consisting of [Flag.Type] flags
|
||||
*/
|
||||
open fun visitIsInstanceType(flags: Flags): KmTypeVisitor? =
|
||||
open fun visitIsInstanceType(flags: Int): KmTypeVisitor? =
|
||||
delegate?.visitIsInstanceType(flags)
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,11 +2,12 @@
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
@file:OptIn(ExperimentalStdlibApi::class)
|
||||
@file:Suppress("DEPRECATION")
|
||||
|
||||
package kotlinx.metadata.internal
|
||||
|
||||
import kotlinx.metadata.*
|
||||
import kotlinx.metadata.internal.FlagImpl as Flag
|
||||
import kotlin.enums.EnumEntries
|
||||
import kotlin.reflect.KMutableProperty1
|
||||
import kotlin.reflect.KProperty
|
||||
@@ -15,7 +16,7 @@ import org.jetbrains.kotlin.metadata.deserialization.Flags as ProtoFlags
|
||||
import org.jetbrains.kotlin.protobuf.Internal.EnumLite as ProtoEnumLite
|
||||
|
||||
internal class EnumFlagDelegate<Node, E : Enum<E>>(
|
||||
val flags: KMutableProperty1<Node, Flags>,
|
||||
val flags: KMutableProperty1<Node, Int>,
|
||||
private val protoSet: ProtoFlagSet<out ProtoEnumLite>,
|
||||
private val entries: EnumEntries<E>,
|
||||
private val flagValues: List<Flag>
|
||||
@@ -30,7 +31,7 @@ internal class EnumFlagDelegate<Node, E : Enum<E>>(
|
||||
}
|
||||
|
||||
// Public in internal package - for reuse in JvmFlags
|
||||
public class BooleanFlagDelegate<Node>(private val flags: KMutableProperty1<Node, Flags>, private val flag: Flag) {
|
||||
public class BooleanFlagDelegate<Node>(private val flags: KMutableProperty1<Node, Int>, private val flag: Flag) {
|
||||
private val mask: Int
|
||||
|
||||
init {
|
||||
@@ -47,13 +48,13 @@ public class BooleanFlagDelegate<Node>(private val flags: KMutableProperty1<Node
|
||||
}
|
||||
|
||||
|
||||
internal fun <Node> visibilityDelegate(flags: KMutableProperty1<Node, Flags>) =
|
||||
internal fun <Node> visibilityDelegate(flags: KMutableProperty1<Node, Int>) =
|
||||
EnumFlagDelegate(flags, ProtoFlags.VISIBILITY, Visibility.entries, Visibility.entries.map { it.flag })
|
||||
|
||||
internal fun <Node> modalityDelegate(flags: KMutableProperty1<Node, Flags>) =
|
||||
internal fun <Node> modalityDelegate(flags: KMutableProperty1<Node, Int>) =
|
||||
EnumFlagDelegate(flags, ProtoFlags.MODALITY, Modality.entries, Modality.entries.map { it.flag })
|
||||
|
||||
internal fun <Node> memberKindDelegate(flags: KMutableProperty1<Node, Flags>) =
|
||||
internal fun <Node> memberKindDelegate(flags: KMutableProperty1<Node, Int>) =
|
||||
EnumFlagDelegate(flags, ProtoFlags.MEMBER_KIND, MemberKind.entries, MemberKind.entries.map { it.flag })
|
||||
|
||||
internal fun classBooleanFlag(flag: Flag) = BooleanFlagDelegate(KmClass::flags, flag)
|
||||
@@ -70,5 +71,5 @@ internal fun typeBooleanFlag(flag: Flag) = BooleanFlagDelegate(KmType::flags, fl
|
||||
|
||||
internal fun valueParameterBooleanFlag(flag: Flag) = BooleanFlagDelegate(KmValueParameter::flags, flag)
|
||||
|
||||
internal fun <Node> annotationsOn(flags: KMutableProperty1<Node, Flags>) = BooleanFlagDelegate(flags, Flag(ProtoFlags.HAS_ANNOTATIONS))
|
||||
internal fun <Node> annotationsOn(flags: KMutableProperty1<Node, Int>) = BooleanFlagDelegate(flags, Flag(ProtoFlags.HAS_ANNOTATIONS))
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package kotlinx.metadata.internal
|
||||
|
||||
import org.jetbrains.kotlin.metadata.deserialization.Flags as F
|
||||
|
||||
class FlagImpl(internal val offset: Int, internal val bitWidth: Int, internal val value: Int) : @Suppress("DEPRECATION") kotlinx.metadata.Flag() {
|
||||
@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)
|
||||
|
||||
override 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)
|
||||
@@ -7,7 +7,6 @@
|
||||
package kotlinx.metadata.internal
|
||||
|
||||
import kotlinx.metadata.*
|
||||
import kotlinx.metadata.Flags // Don't remove this import. See KT-45553
|
||||
import kotlinx.metadata.internal.extensions.MetadataExtensions
|
||||
import kotlinx.metadata.internal.common.KmModuleFragmentVisitor
|
||||
import org.jetbrains.kotlin.metadata.ProtoBuf
|
||||
@@ -344,7 +343,7 @@ private fun ProtoBuf.ValueParameter.accept(v: KmValueParameterVisitor, c: ReadCo
|
||||
}
|
||||
|
||||
private inline fun ProtoBuf.TypeParameter.accept(
|
||||
visit: (flags: Flags, name: String, id: Int, variance: KmVariance) -> KmTypeParameterVisitor?,
|
||||
visit: (flags: Int, name: String, id: Int, variance: KmVariance) -> KmTypeParameterVisitor?,
|
||||
c: ReadContext
|
||||
) {
|
||||
val variance = when (requireNotNull(variance)) {
|
||||
@@ -514,18 +513,18 @@ private fun ProtoBuf.Expression.accept(v: KmEffectExpressionVisitor, c: ReadCont
|
||||
v.visitEnd()
|
||||
}
|
||||
|
||||
private val ProtoBuf.Type.typeFlags: Flags
|
||||
private val ProtoBuf.Type.typeFlags: Int
|
||||
get() = (if (nullable) 1 shl 0 else 0) +
|
||||
(flags shl 1)
|
||||
|
||||
private val ProtoBuf.TypeParameter.typeParameterFlags: Flags
|
||||
private val ProtoBuf.TypeParameter.typeParameterFlags: Int
|
||||
get() = if (reified) 1 else 0
|
||||
|
||||
fun ProtoBuf.Property.getPropertyGetterFlags(): Flags =
|
||||
fun ProtoBuf.Property.getPropertyGetterFlags(): Int =
|
||||
if (hasGetterFlags()) getterFlags else getDefaultPropertyAccessorFlags(flags)
|
||||
|
||||
fun ProtoBuf.Property.getPropertySetterFlags(): Flags =
|
||||
fun ProtoBuf.Property.getPropertySetterFlags(): Int =
|
||||
if (hasSetterFlags()) setterFlags else getDefaultPropertyAccessorFlags(flags)
|
||||
|
||||
internal fun getDefaultPropertyAccessorFlags(flags: Flags): Flags =
|
||||
internal fun getDefaultPropertyAccessorFlags(flags: Int): Int =
|
||||
F.getAccessorFlags(F.HAS_ANNOTATIONS.get(flags), F.VISIBILITY.get(flags), F.MODALITY.get(flags), false, false, false)
|
||||
|
||||
@@ -32,13 +32,13 @@ open class WriteContext(val strings: StringTable, val contextExtensions: List<Wr
|
||||
}
|
||||
|
||||
private fun writeTypeParameter(
|
||||
c: WriteContext, flags: Flags, name: String, id: Int, variance: KmVariance,
|
||||
c: WriteContext, flags: Int, name: String, id: Int, variance: KmVariance,
|
||||
output: (ProtoBuf.TypeParameter.Builder) -> Unit
|
||||
): KmTypeParameterVisitor =
|
||||
object : KmTypeParameterVisitor() {
|
||||
private val t = ProtoBuf.TypeParameter.newBuilder()
|
||||
|
||||
override fun visitUpperBound(flags: Flags): KmTypeVisitor? =
|
||||
override fun visitUpperBound(flags: Int): KmTypeVisitor? =
|
||||
writeType(c, flags) { t.addUpperBound(it) }
|
||||
|
||||
override fun visitExtensions(type: KmExtensionType): KmTypeParameterExtensionVisitor? =
|
||||
@@ -62,7 +62,7 @@ private fun writeTypeParameter(
|
||||
}
|
||||
}
|
||||
|
||||
private fun writeType(c: WriteContext, flags: Flags, output: (ProtoBuf.Type.Builder) -> Unit): KmTypeVisitor =
|
||||
private fun writeType(c: WriteContext, flags: Int, output: (ProtoBuf.Type.Builder) -> Unit): KmTypeVisitor =
|
||||
object : KmTypeVisitor() {
|
||||
private val t = ProtoBuf.Type.newBuilder()
|
||||
|
||||
@@ -80,7 +80,7 @@ private fun writeType(c: WriteContext, flags: Flags, output: (ProtoBuf.Type.Buil
|
||||
})
|
||||
}
|
||||
|
||||
override fun visitArgument(flags: Flags, variance: KmVariance): KmTypeVisitor? =
|
||||
override fun visitArgument(flags: Int, variance: KmVariance): KmTypeVisitor? =
|
||||
writeType(c, flags) { argument ->
|
||||
t.addArgument(ProtoBuf.Type.Argument.newBuilder().apply {
|
||||
if (variance == KmVariance.IN) {
|
||||
@@ -96,13 +96,13 @@ private fun writeType(c: WriteContext, flags: Flags, output: (ProtoBuf.Type.Buil
|
||||
t.typeParameter = id
|
||||
}
|
||||
|
||||
override fun visitAbbreviatedType(flags: Flags): KmTypeVisitor? =
|
||||
override fun visitAbbreviatedType(flags: Int): KmTypeVisitor? =
|
||||
writeType(c, flags) { t.abbreviatedType = it.build() }
|
||||
|
||||
override fun visitOuterType(flags: Flags): KmTypeVisitor? =
|
||||
override fun visitOuterType(flags: Int): KmTypeVisitor? =
|
||||
writeType(c, flags) { t.outerType = it.build() }
|
||||
|
||||
override fun visitFlexibleTypeUpperBound(flags: Flags, typeFlexibilityId: String?): KmTypeVisitor? =
|
||||
override fun visitFlexibleTypeUpperBound(flags: Int, typeFlexibilityId: String?): KmTypeVisitor? =
|
||||
writeType(c, flags) {
|
||||
if (typeFlexibilityId != null) {
|
||||
t.flexibleTypeCapabilitiesId = c[typeFlexibilityId]
|
||||
@@ -127,11 +127,11 @@ private fun writeType(c: WriteContext, flags: Flags, output: (ProtoBuf.Type.Buil
|
||||
}
|
||||
}
|
||||
|
||||
private fun writeConstructor(c: WriteContext, flags: Flags, output: (ProtoBuf.Constructor.Builder) -> Unit): KmConstructorVisitor =
|
||||
private fun writeConstructor(c: WriteContext, flags: Int, output: (ProtoBuf.Constructor.Builder) -> Unit): KmConstructorVisitor =
|
||||
object : KmConstructorVisitor() {
|
||||
val t = ProtoBuf.Constructor.newBuilder()
|
||||
|
||||
override fun visitValueParameter(flags: Flags, name: String): KmValueParameterVisitor? =
|
||||
override fun visitValueParameter(flags: Int, name: String): KmValueParameterVisitor? =
|
||||
writeValueParameter(c, flags, name) { t.addValueParameter(it.build()) }
|
||||
|
||||
override fun visitVersionRequirement(): KmVersionRequirementVisitor? =
|
||||
@@ -150,24 +150,24 @@ private fun writeConstructor(c: WriteContext, flags: Flags, output: (ProtoBuf.Co
|
||||
}
|
||||
}
|
||||
|
||||
private fun writeFunction(c: WriteContext, flags: Flags, name: String, output: (ProtoBuf.Function.Builder) -> Unit): KmFunctionVisitor =
|
||||
private fun writeFunction(c: WriteContext, flags: Int, name: String, output: (ProtoBuf.Function.Builder) -> Unit): KmFunctionVisitor =
|
||||
object : KmFunctionVisitor() {
|
||||
val t = ProtoBuf.Function.newBuilder()
|
||||
|
||||
override fun visitTypeParameter(flags: Flags, name: String, id: Int, variance: KmVariance): KmTypeParameterVisitor? =
|
||||
override fun visitTypeParameter(flags: Int, name: String, id: Int, variance: KmVariance): KmTypeParameterVisitor? =
|
||||
writeTypeParameter(c, flags, name, id, variance) { t.addTypeParameter(it) }
|
||||
|
||||
override fun visitReceiverParameterType(flags: Flags): KmTypeVisitor? =
|
||||
override fun visitReceiverParameterType(flags: Int): KmTypeVisitor? =
|
||||
writeType(c, flags) { t.receiverType = it.build() }
|
||||
|
||||
@ExperimentalContextReceivers
|
||||
override fun visitContextReceiverType(flags: Flags): KmTypeVisitor =
|
||||
override fun visitContextReceiverType(flags: Int): KmTypeVisitor =
|
||||
writeType(c, flags) { t.addContextReceiverType(it) }
|
||||
|
||||
override fun visitValueParameter(flags: Flags, name: String): KmValueParameterVisitor? =
|
||||
override fun visitValueParameter(flags: Int, name: String): KmValueParameterVisitor? =
|
||||
writeValueParameter(c, flags, name) { t.addValueParameter(it) }
|
||||
|
||||
override fun visitReturnType(flags: Flags): KmTypeVisitor? =
|
||||
override fun visitReturnType(flags: Int): KmTypeVisitor? =
|
||||
writeType(c, flags) { t.returnType = it.build() }
|
||||
|
||||
override fun visitVersionRequirement(): KmVersionRequirementVisitor? =
|
||||
@@ -192,24 +192,24 @@ private fun writeFunction(c: WriteContext, flags: Flags, name: String, output: (
|
||||
}
|
||||
|
||||
fun writeProperty(
|
||||
c: WriteContext, flags: Flags, name: String, getterFlags: Flags, setterFlags: Flags, output: (ProtoBuf.Property.Builder) -> Unit
|
||||
c: WriteContext, flags: Int, name: String, getterFlags: Int, setterFlags: Int, output: (ProtoBuf.Property.Builder) -> Unit
|
||||
): KmPropertyVisitor = object : KmPropertyVisitor() {
|
||||
val t = ProtoBuf.Property.newBuilder()
|
||||
|
||||
override fun visitTypeParameter(flags: Flags, name: String, id: Int, variance: KmVariance): KmTypeParameterVisitor? =
|
||||
override fun visitTypeParameter(flags: Int, name: String, id: Int, variance: KmVariance): KmTypeParameterVisitor? =
|
||||
writeTypeParameter(c, flags, name, id, variance) { t.addTypeParameter(it) }
|
||||
|
||||
override fun visitReceiverParameterType(flags: Flags): KmTypeVisitor? =
|
||||
override fun visitReceiverParameterType(flags: Int): KmTypeVisitor? =
|
||||
writeType(c, flags) { t.receiverType = it.build() }
|
||||
|
||||
@ExperimentalContextReceivers
|
||||
override fun visitContextReceiverType(flags: Flags): KmTypeVisitor =
|
||||
override fun visitContextReceiverType(flags: Int): KmTypeVisitor =
|
||||
writeType(c, flags) { t.addContextReceiverType(it) }
|
||||
|
||||
override fun visitSetterParameter(flags: Flags, name: String): KmValueParameterVisitor? =
|
||||
override fun visitSetterParameter(flags: Int, name: String): KmValueParameterVisitor? =
|
||||
writeValueParameter(c, flags, name) { t.setterValueParameter = it.build() }
|
||||
|
||||
override fun visitReturnType(flags: Flags): KmTypeVisitor? =
|
||||
override fun visitReturnType(flags: Int): KmTypeVisitor? =
|
||||
writeType(c, flags) { t.returnType = it.build() }
|
||||
|
||||
override fun visitVersionRequirement(): KmVersionRequirementVisitor? =
|
||||
@@ -233,15 +233,15 @@ fun writeProperty(
|
||||
}
|
||||
|
||||
private fun writeValueParameter(
|
||||
c: WriteContext, flags: Flags, name: String,
|
||||
c: WriteContext, flags: Int, name: String,
|
||||
output: (ProtoBuf.ValueParameter.Builder) -> Unit
|
||||
): KmValueParameterVisitor = object : KmValueParameterVisitor() {
|
||||
val t = ProtoBuf.ValueParameter.newBuilder()
|
||||
|
||||
override fun visitType(flags: Flags): KmTypeVisitor? =
|
||||
override fun visitType(flags: Int): KmTypeVisitor? =
|
||||
writeType(c, flags) { t.type = it.build() }
|
||||
|
||||
override fun visitVarargElementType(flags: Flags): KmTypeVisitor? =
|
||||
override fun visitVarargElementType(flags: Int): KmTypeVisitor? =
|
||||
writeType(c, flags) { t.varargElementType = it.build() }
|
||||
|
||||
override fun visitExtensions(type: KmExtensionType): KmValueParameterExtensionVisitor? =
|
||||
@@ -259,18 +259,18 @@ private fun writeValueParameter(
|
||||
}
|
||||
|
||||
private fun writeTypeAlias(
|
||||
c: WriteContext, flags: Flags, name: String,
|
||||
c: WriteContext, flags: Int, name: String,
|
||||
output: (ProtoBuf.TypeAlias.Builder) -> Unit
|
||||
): KmTypeAliasVisitor = object : KmTypeAliasVisitor() {
|
||||
val t = ProtoBuf.TypeAlias.newBuilder()
|
||||
|
||||
override fun visitTypeParameter(flags: Flags, name: String, id: Int, variance: KmVariance): KmTypeParameterVisitor? =
|
||||
override fun visitTypeParameter(flags: Int, name: String, id: Int, variance: KmVariance): KmTypeParameterVisitor? =
|
||||
writeTypeParameter(c, flags, name, id, variance) { t.addTypeParameter(it) }
|
||||
|
||||
override fun visitUnderlyingType(flags: Flags): KmTypeVisitor? =
|
||||
override fun visitUnderlyingType(flags: Int): KmTypeVisitor? =
|
||||
writeType(c, flags) { t.underlyingType = it.build() }
|
||||
|
||||
override fun visitExpandedType(flags: Flags): KmTypeVisitor? =
|
||||
override fun visitExpandedType(flags: Int): KmTypeVisitor? =
|
||||
writeType(c, flags) { t.expandedType = it.build() }
|
||||
|
||||
override fun visitAnnotation(annotation: KmAnnotation) {
|
||||
@@ -392,7 +392,7 @@ private fun writeEffectExpression(c: WriteContext, output: (ProtoBuf.Expression.
|
||||
object : KmEffectExpressionVisitor() {
|
||||
val t = ProtoBuf.Expression.newBuilder()
|
||||
|
||||
override fun visit(flags: Flags, parameterIndex: Int?) {
|
||||
override fun visit(flags: Int, parameterIndex: Int?) {
|
||||
if (flags != ProtoBuf.Expression.getDefaultInstance().flags) {
|
||||
t.flags = flags
|
||||
}
|
||||
@@ -410,7 +410,7 @@ private fun writeEffectExpression(c: WriteContext, output: (ProtoBuf.Expression.
|
||||
}
|
||||
}
|
||||
|
||||
override fun visitIsInstanceType(flags: Flags): KmTypeVisitor? =
|
||||
override fun visitIsInstanceType(flags: Int): KmTypeVisitor? =
|
||||
writeType(c, flags) { t.isInstanceType = it.build() }
|
||||
|
||||
override fun visitAndArgument(): KmEffectExpressionVisitor? =
|
||||
@@ -428,29 +428,29 @@ open class ClassWriter(stringTable: StringTable, contextExtensions: List<WriteCo
|
||||
protected val t = ProtoBuf.Class.newBuilder()!!
|
||||
protected val c: WriteContext = WriteContext(stringTable, contextExtensions)
|
||||
|
||||
override fun visit(flags: Flags, name: ClassName) {
|
||||
override fun visit(flags: Int, name: ClassName) {
|
||||
if (flags != ProtoBuf.Class.getDefaultInstance().flags) {
|
||||
t.flags = flags
|
||||
}
|
||||
t.fqName = c.getClassName(name)
|
||||
}
|
||||
|
||||
override fun visitTypeParameter(flags: Flags, name: String, id: Int, variance: KmVariance): KmTypeParameterVisitor? =
|
||||
override fun visitTypeParameter(flags: Int, name: String, id: Int, variance: KmVariance): KmTypeParameterVisitor? =
|
||||
writeTypeParameter(c, flags, name, id, variance) { t.addTypeParameter(it) }
|
||||
|
||||
override fun visitSupertype(flags: Flags): KmTypeVisitor? =
|
||||
override fun visitSupertype(flags: Int): KmTypeVisitor? =
|
||||
writeType(c, flags) { t.addSupertype(it) }
|
||||
|
||||
override fun visitConstructor(flags: Flags): KmConstructorVisitor? =
|
||||
override fun visitConstructor(flags: Int): KmConstructorVisitor? =
|
||||
writeConstructor(c, flags) { t.addConstructor(it) }
|
||||
|
||||
override fun visitFunction(flags: Flags, name: String): KmFunctionVisitor? =
|
||||
override fun visitFunction(flags: Int, name: String): KmFunctionVisitor? =
|
||||
writeFunction(c, flags, name) { t.addFunction(it) }
|
||||
|
||||
override fun visitProperty(flags: Flags, name: String, getterFlags: Flags, setterFlags: Flags): KmPropertyVisitor? =
|
||||
override fun visitProperty(flags: Int, name: String, getterFlags: Int, setterFlags: Int): KmPropertyVisitor? =
|
||||
writeProperty(c, flags, name, getterFlags, setterFlags) { t.addProperty(it) }
|
||||
|
||||
override fun visitTypeAlias(flags: Flags, name: String): KmTypeAliasVisitor? =
|
||||
override fun visitTypeAlias(flags: Int, name: String): KmTypeAliasVisitor? =
|
||||
writeTypeAlias(c, flags, name) { t.addTypeAlias(it) }
|
||||
|
||||
override fun visitCompanionObject(name: String) {
|
||||
@@ -475,11 +475,11 @@ open class ClassWriter(stringTable: StringTable, contextExtensions: List<WriteCo
|
||||
t.inlineClassUnderlyingPropertyName = c[name]
|
||||
}
|
||||
|
||||
override fun visitInlineClassUnderlyingType(flags: Flags): KmTypeVisitor? =
|
||||
override fun visitInlineClassUnderlyingType(flags: Int): KmTypeVisitor? =
|
||||
writeType(c, flags) { t.inlineClassUnderlyingType = it.build() }
|
||||
|
||||
@ExperimentalContextReceivers
|
||||
override fun visitContextReceiverType(flags: Flags): KmTypeVisitor =
|
||||
override fun visitContextReceiverType(flags: Int): KmTypeVisitor =
|
||||
writeType(c, flags) { t.addContextReceiverType(it) }
|
||||
|
||||
override fun visitVersionRequirement(): KmVersionRequirementVisitor? =
|
||||
@@ -501,13 +501,13 @@ open class PackageWriter(stringTable: StringTable, contextExtensions: List<Write
|
||||
protected val t = ProtoBuf.Package.newBuilder()!!
|
||||
protected val c: WriteContext = WriteContext(stringTable, contextExtensions)
|
||||
|
||||
override fun visitFunction(flags: Flags, name: String): KmFunctionVisitor? =
|
||||
override fun visitFunction(flags: Int, name: String): KmFunctionVisitor? =
|
||||
writeFunction(c, flags, name) { t.addFunction(it) }
|
||||
|
||||
override fun visitProperty(flags: Flags, name: String, getterFlags: Flags, setterFlags: Flags): KmPropertyVisitor? =
|
||||
override fun visitProperty(flags: Int, name: String, getterFlags: Int, setterFlags: Int): KmPropertyVisitor? =
|
||||
writeProperty(c, flags, name, getterFlags, setterFlags) { t.addProperty(it) }
|
||||
|
||||
override fun visitTypeAlias(flags: Flags, name: String): KmTypeAliasVisitor? =
|
||||
override fun visitTypeAlias(flags: Int, name: String): KmTypeAliasVisitor? =
|
||||
writeTypeAlias(c, flags, name) { t.addTypeAlias(it) }
|
||||
|
||||
override fun visitExtensions(type: KmExtensionType): KmPackageExtensionVisitor? =
|
||||
@@ -551,6 +551,6 @@ open class LambdaWriter(stringTable: StringTable) : KmLambdaVisitor() {
|
||||
protected var t: ProtoBuf.Function.Builder? = null
|
||||
protected val c = WriteContext(stringTable)
|
||||
|
||||
override fun visitFunction(flags: Flags, name: String): KmFunctionVisitor? =
|
||||
override fun visitFunction(flags: Int, name: String): KmFunctionVisitor? =
|
||||
writeFunction(c, flags, name) { t = it }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user