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
+105
-123
@@ -119,7 +119,7 @@ internal class ModuleMetadataEmitter(
|
||||
val kmClass = data.withMappingExtensions {
|
||||
KmClass().also { km ->
|
||||
element.annotations.mapTo(km.annotations) { it.map() }
|
||||
km.flags = element.flags
|
||||
km.modifiersFrom(element)
|
||||
km.name = element.classifier.fqNameSerialized
|
||||
element.superClassInit?.let { km.supertypes += it.type.map() }
|
||||
element.interfaces.mapTo(km.supertypes) { it.map() }
|
||||
@@ -141,7 +141,7 @@ internal class ModuleMetadataEmitter(
|
||||
override fun visitTypealias(element: TypealiasStub, data: VisitingContext): KmTypeAlias =
|
||||
data.withMappingExtensions {
|
||||
KmTypeAlias(element.alias.topLevelName).also { km ->
|
||||
km.flags = element.flags
|
||||
km.visibility = Visibility.PUBLIC
|
||||
km.underlyingType = element.aliasee.map(shouldExpandTypeAliases = false)
|
||||
km.expandedType = element.aliasee.map()
|
||||
}
|
||||
@@ -158,7 +158,7 @@ internal class ModuleMetadataEmitter(
|
||||
)
|
||||
}
|
||||
KmFunction(function.name).also { km ->
|
||||
km.flags = function.flags
|
||||
km.modifiersFrom(function)
|
||||
km.receiverParameterType = function.receiver?.type?.map()
|
||||
function.typeParameters.mapTo(km.typeParameters) { it.map() }
|
||||
function.parameters.mapTo(km.valueParameters) { it.map() }
|
||||
@@ -179,9 +179,9 @@ internal class ModuleMetadataEmitter(
|
||||
}
|
||||
val name = getPropertyNameInScope(property, data.container)
|
||||
KmProperty(name).also { km ->
|
||||
km.flags = property.flags
|
||||
km.getterFlags = property.getterFlags
|
||||
km.setterFlags = property.setterFlags
|
||||
km.modifiersFrom(property)
|
||||
km.getter.getterModifiersFrom(property)
|
||||
km.setter = setterFrom(property)
|
||||
property.annotations.mapTo(km.annotations) { it.map() }
|
||||
km.receiverParameterType = property.receiverType?.map()
|
||||
km.returnType = property.type.map()
|
||||
@@ -205,7 +205,7 @@ internal class ModuleMetadataEmitter(
|
||||
override fun visitConstructor(constructorStub: ConstructorStub, data: VisitingContext) =
|
||||
data.withMappingExtensions {
|
||||
KmConstructor().apply {
|
||||
flags = constructorStub.flags
|
||||
modifiersFrom(constructorStub)
|
||||
constructorStub.parameters.mapTo(valueParameters, { it.map() })
|
||||
constructorStub.annotations.mapTo(annotations, { it.map() })
|
||||
}
|
||||
@@ -239,34 +239,31 @@ private class MappingExtensions(
|
||||
private val bridgeBuilderResult: BridgeBuilderResult
|
||||
) {
|
||||
|
||||
private fun flagsOfNotNull(vararg flags: Flag?): Flags =
|
||||
flagsOf(*listOfNotNull(*flags).toTypedArray())
|
||||
|
||||
private fun <K, V> mapOfNotNull(vararg entries: Pair<K, V>?): Map<K, V> =
|
||||
listOfNotNull(*entries).toMap()
|
||||
|
||||
private val VisibilityModifier.flags: Flags
|
||||
get() = flagsOfNotNull(
|
||||
Flag.IS_PUBLIC.takeIf { this == VisibilityModifier.PUBLIC },
|
||||
Flag.IS_PROTECTED.takeIf { this == VisibilityModifier.PROTECTED },
|
||||
Flag.IS_INTERNAL.takeIf { this == VisibilityModifier.INTERNAL },
|
||||
Flag.IS_PRIVATE.takeIf { this == VisibilityModifier.PRIVATE }
|
||||
)
|
||||
private val VisibilityModifier.kmVisibility: Visibility
|
||||
get() = when (this) {
|
||||
VisibilityModifier.PUBLIC -> Visibility.PUBLIC
|
||||
VisibilityModifier.PROTECTED -> Visibility.PROTECTED
|
||||
VisibilityModifier.INTERNAL -> Visibility.INTERNAL
|
||||
VisibilityModifier.PRIVATE -> Visibility.PRIVATE
|
||||
}
|
||||
|
||||
private val MemberStubModality.flags: Flags
|
||||
get() = flagsOfNotNull(
|
||||
Flag.IS_FINAL.takeIf { this == MemberStubModality.FINAL },
|
||||
Flag.IS_OPEN.takeIf { this == MemberStubModality.OPEN },
|
||||
Flag.IS_ABSTRACT.takeIf { this == MemberStubModality.ABSTRACT }
|
||||
)
|
||||
private val MemberStubModality.kmModality: Modality
|
||||
get() = when (this) {
|
||||
MemberStubModality.FINAL -> Modality.FINAL
|
||||
MemberStubModality.OPEN -> Modality.OPEN
|
||||
MemberStubModality.ABSTRACT -> Modality.ABSTRACT
|
||||
}
|
||||
|
||||
val FunctionStub.flags: Flags
|
||||
get() = flagsOfNotNull(
|
||||
Flag.IS_PUBLIC,
|
||||
Flag.Function.IS_EXTERNAL.takeIf { this.external },
|
||||
Flag.HAS_ANNOTATIONS.takeIf { annotations.isNotEmpty() },
|
||||
Flag.Function.HAS_NON_STABLE_PARAMETER_NAMES.takeIf { !this.hasStableParameterNames }
|
||||
) or modality.flags
|
||||
fun KmFunction.modifiersFrom(fs: FunctionStub) {
|
||||
visibility = Visibility.PUBLIC
|
||||
modality = fs.modality.kmModality
|
||||
isExternal = fs.external
|
||||
hasAnnotations = fs.annotations.isNotEmpty()
|
||||
hasNonStableParameterNames = !fs.hasStableParameterNames
|
||||
}
|
||||
|
||||
val Classifier.fqNameSerialized: String
|
||||
get() = buildString {
|
||||
@@ -278,96 +275,81 @@ private class MappingExtensions(
|
||||
append(getRelativeFqName(asSimpleName = false))
|
||||
}
|
||||
|
||||
val PropertyStub.flags: Flags
|
||||
get() = flagsOfNotNull(
|
||||
Flag.IS_PUBLIC,
|
||||
Flag.Property.IS_DECLARATION,
|
||||
Flag.HAS_ANNOTATIONS.takeIf { annotations.isNotEmpty() },
|
||||
Flag.Property.HAS_CONSTANT.takeIf { kind is PropertyStub.Kind.Constant },
|
||||
Flag.Property.HAS_GETTER,
|
||||
Flag.Property.HAS_SETTER.takeIf { kind is PropertyStub.Kind.Var },
|
||||
when (kind) {
|
||||
is PropertyStub.Kind.Val -> null
|
||||
is PropertyStub.Kind.Var -> Flag.Property.IS_VAR
|
||||
is PropertyStub.Kind.Constant -> Flag.Property.IS_CONST
|
||||
fun KmProperty.modifiersFrom(ps: PropertyStub) {
|
||||
visibility = Visibility.PUBLIC
|
||||
modality = ps.modality.kmModality
|
||||
kind = MemberKind.DECLARATION
|
||||
hasAnnotations = ps.annotations.isNotEmpty()
|
||||
hasGetter = true
|
||||
when (ps.kind) {
|
||||
is PropertyStub.Kind.Val -> {}
|
||||
is PropertyStub.Kind.Var -> {
|
||||
isVar = true
|
||||
hasGetter = true
|
||||
}
|
||||
is PropertyStub.Kind.Constant -> {
|
||||
isConst = true
|
||||
hasConstant = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun KmPropertyAccessorAttributes.getterModifiersFrom(ps: PropertyStub) {
|
||||
val getter = when (val kind = ps.kind) {
|
||||
is PropertyStub.Kind.Val -> kind.getter
|
||||
is PropertyStub.Kind.Var -> kind.getter
|
||||
is PropertyStub.Kind.Constant -> null
|
||||
}
|
||||
if (getter == null) {
|
||||
// constant
|
||||
visibility = Visibility.PUBLIC
|
||||
modality = Modality.FINAL
|
||||
} else {
|
||||
visibility = Visibility.PUBLIC
|
||||
modality = ps.modality.kmModality
|
||||
hasAnnotations = getter.annotations.isNotEmpty()
|
||||
isNotDefault = true
|
||||
isExternal = getter is PropertyAccessor.Getter.ExternalGetter
|
||||
}
|
||||
}
|
||||
|
||||
fun setterFrom(ps: PropertyStub): KmPropertyAccessorAttributes? {
|
||||
val setter = if (ps.kind is PropertyStub.Kind.Var) ps.kind.setter else return null
|
||||
return KmPropertyAccessorAttributes().apply {
|
||||
hasAnnotations = setter.annotations.isNotEmpty()
|
||||
visibility = Visibility.PUBLIC
|
||||
modality = ps.modality.kmModality
|
||||
isNotDefault = true
|
||||
isExternal = setter is PropertyAccessor.Setter.ExternalSetter
|
||||
}
|
||||
}
|
||||
|
||||
fun KmType.modifiersFrom(st: StubType) {
|
||||
isNullable = st.nullable
|
||||
}
|
||||
|
||||
fun KmClass.modifiersFrom(cs: ClassStub) {
|
||||
hasAnnotations = cs.annotations.isNotEmpty()
|
||||
visibility = Visibility.PUBLIC
|
||||
kind = when (cs) {
|
||||
is ClassStub.Simple -> {
|
||||
modality = when (cs.modality) {
|
||||
ClassStubModality.NONE -> Modality.FINAL
|
||||
ClassStubModality.OPEN -> Modality.OPEN
|
||||
ClassStubModality.ABSTRACT, ClassStubModality.INTERFACE -> Modality.ABSTRACT
|
||||
}
|
||||
) or modality.flags
|
||||
|
||||
val PropertyStub.getterFlags: Flags
|
||||
get() = when (val kind = kind) {
|
||||
is PropertyStub.Kind.Val -> kind.getter.flags(modality)
|
||||
is PropertyStub.Kind.Var -> kind.getter.flags(modality)
|
||||
is PropertyStub.Kind.Constant -> kind.flags
|
||||
if (cs.modality == ClassStubModality.INTERFACE) ClassKind.INTERFACE else ClassKind.CLASS
|
||||
}
|
||||
is ClassStub.Companion -> ClassKind.COMPANION_OBJECT
|
||||
is ClassStub.Enum -> ClassKind.ENUM_CLASS
|
||||
}
|
||||
}
|
||||
|
||||
val PropertyStub.Kind.Constant.flags: Flags
|
||||
get() = flagsOfNotNull(
|
||||
Flag.IS_PUBLIC,
|
||||
Flag.IS_FINAL
|
||||
)
|
||||
|
||||
private fun PropertyAccessor.Getter.flags(propertyModality: MemberStubModality): Flags =
|
||||
flagsOfNotNull(
|
||||
Flag.HAS_ANNOTATIONS.takeIf { annotations.isNotEmpty() },
|
||||
Flag.IS_PUBLIC,
|
||||
Flag.PropertyAccessor.IS_NOT_DEFAULT,
|
||||
Flag.PropertyAccessor.IS_EXTERNAL.takeIf { this is PropertyAccessor.Getter.ExternalGetter }
|
||||
) or propertyModality.flags
|
||||
|
||||
val PropertyStub.setterFlags: Flags
|
||||
get() = when (val kind = kind) {
|
||||
is PropertyStub.Kind.Var -> kind.setter.flags(modality)
|
||||
else -> flagsOf()
|
||||
}
|
||||
|
||||
private fun PropertyAccessor.Setter.flags(propertyModality: MemberStubModality): Flags =
|
||||
flagsOfNotNull(
|
||||
Flag.HAS_ANNOTATIONS.takeIf { annotations.isNotEmpty() },
|
||||
Flag.IS_PUBLIC,
|
||||
Flag.PropertyAccessor.IS_NOT_DEFAULT,
|
||||
Flag.PropertyAccessor.IS_EXTERNAL.takeIf { this is PropertyAccessor.Setter.ExternalSetter }
|
||||
) or propertyModality.flags
|
||||
|
||||
val StubType.flags: Flags
|
||||
get() = flagsOfNotNull(
|
||||
Flag.Type.IS_NULLABLE.takeIf { nullable }
|
||||
)
|
||||
|
||||
val AbbreviatedType.expandedTypeFlags: Flags
|
||||
get() = flagsOfNotNull(
|
||||
Flag.Type.IS_NULLABLE.takeIf { isEffectivelyNullable() }
|
||||
)
|
||||
|
||||
val TypealiasStub.flags: Flags
|
||||
get() = flagsOfNotNull(
|
||||
Flag.IS_PUBLIC
|
||||
)
|
||||
|
||||
val FunctionParameterStub.flags: Flags
|
||||
get() = flagsOfNotNull(
|
||||
Flag.HAS_ANNOTATIONS.takeIf { annotations.isNotEmpty() }
|
||||
)
|
||||
|
||||
val ClassStub.flags: Flags
|
||||
get() = flagsOfNotNull(
|
||||
Flag.HAS_ANNOTATIONS.takeIf { annotations.isNotEmpty() },
|
||||
Flag.IS_PUBLIC,
|
||||
Flag.IS_OPEN.takeIf { this is ClassStub.Simple && modality == ClassStubModality.OPEN },
|
||||
Flag.IS_FINAL.takeIf { this is ClassStub.Simple && modality == ClassStubModality.NONE },
|
||||
Flag.IS_ABSTRACT.takeIf { this is ClassStub.Simple
|
||||
&& (modality == ClassStubModality.ABSTRACT || modality == ClassStubModality.INTERFACE) },
|
||||
Flag.Class.IS_INTERFACE.takeIf { this is ClassStub.Simple && modality == ClassStubModality.INTERFACE },
|
||||
Flag.Class.IS_COMPANION_OBJECT.takeIf { this is ClassStub.Companion },
|
||||
Flag.Class.IS_CLASS.takeIf { this is ClassStub.Simple && modality != ClassStubModality.INTERFACE },
|
||||
Flag.Class.IS_ENUM_CLASS.takeIf { this is ClassStub.Enum }
|
||||
)
|
||||
|
||||
|
||||
val ConstructorStub.flags: Flags
|
||||
get() = flagsOfNotNull(
|
||||
Flag.Constructor.IS_SECONDARY.takeIf { !isPrimary },
|
||||
Flag.HAS_ANNOTATIONS.takeIf { annotations.isNotEmpty() }
|
||||
) or visibility.flags
|
||||
fun KmConstructor.modifiersFrom(cs: ConstructorStub) {
|
||||
visibility = cs.visibility.kmVisibility
|
||||
isSecondary = !cs.isPrimary
|
||||
hasAnnotations = cs.annotations.isNotEmpty()
|
||||
}
|
||||
|
||||
private tailrec fun StubType.isEffectivelyNullable(): Boolean =
|
||||
when {
|
||||
@@ -490,13 +472,13 @@ private class MappingExtensions(
|
||||
val typeAliasClassifier = KmClassifier.TypeAlias(abbreviatedClassifier.fqNameSerialized)
|
||||
val typeArguments = typeArguments.map { it.map(shouldExpandTypeAliases) }
|
||||
val abbreviatedType = KmType().also { km ->
|
||||
km.flags = flags
|
||||
km.modifiersFrom(this)
|
||||
km.classifier = typeAliasClassifier
|
||||
km.arguments += typeArguments
|
||||
}
|
||||
if (shouldExpandTypeAliases) {
|
||||
KmType().also { km ->
|
||||
km.flags = expandedTypeFlags
|
||||
km.isNullable = this.isEffectivelyNullable()
|
||||
km.abbreviatedType = abbreviatedType
|
||||
val kmUnderlyingType = underlyingType.map(true)
|
||||
km.arguments += kmUnderlyingType.arguments
|
||||
@@ -507,24 +489,24 @@ private class MappingExtensions(
|
||||
}
|
||||
}
|
||||
is ClassifierStubType -> KmType().also { km ->
|
||||
km.flags = flags
|
||||
km.modifiersFrom(this)
|
||||
typeArguments.mapTo(km.arguments) { it.map(shouldExpandTypeAliases) }
|
||||
km.classifier = KmClassifier.Class(classifier.fqNameSerialized)
|
||||
}
|
||||
is FunctionalType -> KmType().also { km ->
|
||||
km.flags = flags
|
||||
km.modifiersFrom(this)
|
||||
typeArguments.mapTo(km.arguments) { it.map(shouldExpandTypeAliases) }
|
||||
km.classifier = KmClassifier.Class(classifier.fqNameSerialized)
|
||||
}
|
||||
is TypeParameterType -> KmType().also { km ->
|
||||
km.flags = flags
|
||||
km.modifiersFrom(this)
|
||||
km.classifier = KmClassifier.TypeParameter(id)
|
||||
}
|
||||
}
|
||||
|
||||
fun FunctionParameterStub.map(): KmValueParameter =
|
||||
KmValueParameter(name).also { km ->
|
||||
km.flags = flags
|
||||
km.hasAnnotations = annotations.isNotEmpty()
|
||||
val kmType = type.map()
|
||||
if (isVararg) {
|
||||
km.varargElementType = kmType
|
||||
|
||||
@@ -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 }
|
||||
}
|
||||
|
||||
+84
-87
@@ -20,8 +20,12 @@ import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
|
||||
object CirDeserializers {
|
||||
private fun annotations(flags: Flags, typeResolver: CirTypeResolver, annotations: () -> List<KmAnnotation>): List<CirAnnotation> {
|
||||
return if (!Flag.Common.HAS_ANNOTATIONS(flags))
|
||||
private fun annotations(
|
||||
hasAnnotations: Boolean,
|
||||
typeResolver: CirTypeResolver,
|
||||
annotations: () -> List<KmAnnotation>,
|
||||
): List<CirAnnotation> {
|
||||
return if (!hasAnnotations)
|
||||
emptyList()
|
||||
else
|
||||
annotations().compactMap { annotation(it, typeResolver) }
|
||||
@@ -72,12 +76,10 @@ object CirDeserializers {
|
||||
)
|
||||
}
|
||||
|
||||
private val ALWAYS_HAS_ANNOTATIONS: Flags = flagsOf(Flag.Common.HAS_ANNOTATIONS)
|
||||
|
||||
private fun typeParameter(source: KmTypeParameter, typeResolver: CirTypeResolver): CirTypeParameter = CirTypeParameter(
|
||||
annotations = annotations(ALWAYS_HAS_ANNOTATIONS, typeResolver, source::annotations),
|
||||
annotations = annotations(true, typeResolver, source::annotations),
|
||||
name = CirName.create(source.name),
|
||||
isReified = Flag.TypeParameter.IS_REIFIED(source.flags),
|
||||
isReified = source.isReified,
|
||||
variance = variance(source.variance),
|
||||
upperBounds = source.filteredUpperBounds.compactMap { type(it, typeResolver) }
|
||||
)
|
||||
@@ -91,7 +93,7 @@ object CirDeserializers {
|
||||
)
|
||||
|
||||
fun property(name: CirName, source: KmProperty, containingClass: CirContainingClass?, typeResolver: CirTypeResolver): CirProperty {
|
||||
val compileTimeInitializer = if (Flag.Property.HAS_CONSTANT(source.flags)) {
|
||||
val compileTimeInitializer = if (source.hasConstant) {
|
||||
constantValue(
|
||||
constantValue = source.compileTimeValue,
|
||||
owner = source,
|
||||
@@ -99,19 +101,19 @@ object CirDeserializers {
|
||||
} else CirConstantValue.NullValue
|
||||
|
||||
return CirProperty(
|
||||
annotations = annotations(source.flags, typeResolver, source::annotations),
|
||||
annotations = annotations(source.hasAnnotations, typeResolver, source::annotations),
|
||||
name = name,
|
||||
typeParameters = source.typeParameters.compactMap { typeParameter(it, typeResolver) },
|
||||
visibility = visibility(source.flags),
|
||||
modality = modality(source.flags),
|
||||
visibility = visibility(source.visibility),
|
||||
modality = modality(source.modality),
|
||||
containingClass = containingClass,
|
||||
extensionReceiver = source.receiverParameterType?.let { extensionReceiver(it, typeResolver) },
|
||||
returnType = type(source.returnType, typeResolver),
|
||||
kind = callableKind(source.flags),
|
||||
isVar = Flag.Property.IS_VAR(source.flags),
|
||||
isLateInit = Flag.Property.IS_LATEINIT(source.flags),
|
||||
isConst = Flag.Property.IS_CONST(source.flags),
|
||||
isDelegate = Flag.Property.IS_DELEGATED(source.flags),
|
||||
kind = callableKind(source.kind),
|
||||
isVar = source.isVar,
|
||||
isLateInit = source.isLateinit,
|
||||
isConst = source.isConst,
|
||||
isDelegate = source.isDelegated,
|
||||
getter = propertyGetter(source, typeResolver),
|
||||
setter = propertySetter(source, typeResolver),
|
||||
backingFieldAnnotations = emptyList(), // TODO unclear where to read backing/delegate field annotations from, see KT-44625
|
||||
@@ -121,13 +123,11 @@ object CirDeserializers {
|
||||
}
|
||||
|
||||
private fun propertyGetter(source: KmProperty, typeResolver: CirTypeResolver): CirPropertyGetter? {
|
||||
if (!Flag.Property.HAS_GETTER(source.flags))
|
||||
if (!source.hasGetter)
|
||||
return null
|
||||
|
||||
val getterFlags = source.getterFlags
|
||||
|
||||
val isDefault = !Flag.PropertyAccessor.IS_NOT_DEFAULT(getterFlags)
|
||||
val annotations = annotations(getterFlags, typeResolver, source::getterAnnotations)
|
||||
val isDefault = !source.getter.isNotDefault
|
||||
val annotations = annotations(source.getter.hasAnnotations, typeResolver, source::getterAnnotations)
|
||||
|
||||
if (isDefault && annotations.isEmpty())
|
||||
return CirPropertyGetter.DEFAULT_NO_ANNOTATIONS
|
||||
@@ -135,69 +135,68 @@ object CirDeserializers {
|
||||
return CirPropertyGetter.createInterned(
|
||||
annotations = annotations,
|
||||
isDefault = isDefault,
|
||||
isInline = Flag.PropertyAccessor.IS_INLINE(getterFlags)
|
||||
isInline = source.getter.isInline
|
||||
)
|
||||
}
|
||||
|
||||
private fun propertySetter(source: KmProperty, typeResolver: CirTypeResolver): CirPropertySetter? {
|
||||
if (!Flag.Property.HAS_SETTER(source.flags))
|
||||
if (!source.hasSetter)
|
||||
return null
|
||||
|
||||
val setterFlags = source.setterFlags
|
||||
val setter = source.setter ?: return null
|
||||
|
||||
return CirPropertySetter.createInterned(
|
||||
annotations = annotations(setterFlags, typeResolver, source::setterAnnotations),
|
||||
annotations = annotations(source.setter?.hasAnnotations == true, typeResolver, source::setterAnnotations),
|
||||
parameterAnnotations = source.setterParameter?.let { setterParameter ->
|
||||
annotations(setterParameter.flags, typeResolver, setterParameter::annotations)
|
||||
annotations(setterParameter.hasAnnotations, typeResolver, setterParameter::annotations)
|
||||
}.orEmpty(),
|
||||
visibility = visibility(setterFlags),
|
||||
isDefault = !Flag.PropertyAccessor.IS_NOT_DEFAULT(setterFlags),
|
||||
isInline = Flag.PropertyAccessor.IS_INLINE(setterFlags)
|
||||
visibility = visibility(setter.visibility),
|
||||
isDefault = !setter.isNotDefault,
|
||||
isInline = setter.isInline
|
||||
)
|
||||
}
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
private inline fun callableKind(flags: Flags): CallableMemberDescriptor.Kind =
|
||||
when {
|
||||
Flag.Property.IS_DECLARATION(flags) /*|| Flag.Function.IS_DECLARATION(flags)*/ -> CallableMemberDescriptor.Kind.DECLARATION
|
||||
Flag.Property.IS_FAKE_OVERRIDE(flags) /*|| Flag.Function.IS_FAKE_OVERRIDE(flags)*/ -> CallableMemberDescriptor.Kind.FAKE_OVERRIDE
|
||||
Flag.Property.IS_DELEGATION(flags) /*|| Flag.Function.IS_DELEGATION(flags)*/ -> CallableMemberDescriptor.Kind.DELEGATION
|
||||
Flag.Property.IS_SYNTHESIZED(flags) /*|| Flag.Function.IS_SYNTHESIZED(flags)*/ -> CallableMemberDescriptor.Kind.SYNTHESIZED
|
||||
else -> error("Can't decode callable kind from flags: $flags")
|
||||
private inline fun callableKind(memberKind: MemberKind): CallableMemberDescriptor.Kind =
|
||||
when (memberKind) {
|
||||
MemberKind.DECLARATION -> CallableMemberDescriptor.Kind.DECLARATION
|
||||
MemberKind.FAKE_OVERRIDE -> CallableMemberDescriptor.Kind.FAKE_OVERRIDE
|
||||
MemberKind.DELEGATION -> CallableMemberDescriptor.Kind.DELEGATION
|
||||
MemberKind.SYNTHESIZED -> CallableMemberDescriptor.Kind.SYNTHESIZED
|
||||
}
|
||||
|
||||
fun function(name: CirName, source: KmFunction, containingClass: CirContainingClass?, typeResolver: CirTypeResolver): CirFunction =
|
||||
CirFunction(
|
||||
annotations = annotations(source.flags, typeResolver, source::annotations),
|
||||
annotations = annotations(source.hasAnnotations, typeResolver, source::annotations),
|
||||
name = name,
|
||||
typeParameters = source.typeParameters.compactMap { typeParameter(it, typeResolver) },
|
||||
visibility = visibility(source.flags),
|
||||
modality = modality(source.flags),
|
||||
visibility = visibility(source.visibility),
|
||||
modality = modality(source.modality),
|
||||
containingClass = containingClass,
|
||||
valueParameters = source.valueParameters.compactMap { valueParameter(it, typeResolver) },
|
||||
hasStableParameterNames = !Flag.Function.HAS_NON_STABLE_PARAMETER_NAMES(source.flags),
|
||||
hasStableParameterNames = !source.hasNonStableParameterNames,
|
||||
extensionReceiver = source.receiverParameterType?.let { extensionReceiver(it, typeResolver) },
|
||||
returnType = type(source.returnType, typeResolver),
|
||||
kind = callableKind(source.flags),
|
||||
kind = callableKind(source.kind),
|
||||
modifiers = functionModifiers(source),
|
||||
)
|
||||
|
||||
private fun functionModifiers(source: KmFunction): CirFunctionModifiers = CirFunctionModifiers.createInterned(
|
||||
isOperator = Flag.Function.IS_OPERATOR(source.flags),
|
||||
isInfix = Flag.Function.IS_INFIX(source.flags),
|
||||
isInline = Flag.Function.IS_INLINE(source.flags),
|
||||
isSuspend = Flag.Function.IS_SUSPEND(source.flags),
|
||||
isOperator = source.isOperator,
|
||||
isInfix = source.isInfix,
|
||||
isInline = source.isInline,
|
||||
isSuspend = source.isSuspend,
|
||||
)
|
||||
|
||||
private fun valueParameter(source: KmValueParameter, typeResolver: CirTypeResolver): CirValueParameter =
|
||||
CirValueParameter.createInterned(
|
||||
annotations = annotations(source.flags, typeResolver, source::annotations),
|
||||
annotations = annotations(source.hasAnnotations, typeResolver, source::annotations),
|
||||
name = CirName.create(source.name),
|
||||
returnType = type(source.type, typeResolver),
|
||||
varargElementType = source.varargElementType?.let { type(it, typeResolver) },
|
||||
declaresDefaultValue = Flag.ValueParameter.DECLARES_DEFAULT_VALUE(source.flags),
|
||||
isCrossinline = Flag.ValueParameter.IS_CROSSINLINE(source.flags),
|
||||
isNoinline = Flag.ValueParameter.IS_NOINLINE(source.flags)
|
||||
declaresDefaultValue = source.declaresDefaultValue,
|
||||
isCrossinline = source.isCrossinline,
|
||||
isNoinline = source.isNoinline
|
||||
)
|
||||
|
||||
private fun constantValue(
|
||||
@@ -251,19 +250,19 @@ object CirDeserializers {
|
||||
}
|
||||
|
||||
fun clazz(name: CirName, source: KmClass, typeResolver: CirTypeResolver): CirClass = CirClass.create(
|
||||
annotations = annotations(source.flags, typeResolver, source::annotations),
|
||||
annotations = annotations(source.hasAnnotations, typeResolver, source::annotations),
|
||||
name = name,
|
||||
typeParameters = source.typeParameters.compactMap { typeParameter(it, typeResolver) },
|
||||
supertypes = source.filteredSupertypes.compactMap { type(it, typeResolver) },
|
||||
visibility = visibility(source.flags),
|
||||
modality = modality(source.flags),
|
||||
kind = classKind(source.flags),
|
||||
visibility = visibility(source.visibility),
|
||||
modality = modality(source.modality),
|
||||
kind = classKind(source.kind),
|
||||
companion = source.companionObject?.let(CirName::create),
|
||||
isCompanion = Flag.Class.IS_COMPANION_OBJECT(source.flags),
|
||||
isData = Flag.Class.IS_DATA(source.flags),
|
||||
isValue = Flag.Class.IS_VALUE(source.flags),
|
||||
isInner = Flag.Class.IS_INNER(source.flags),
|
||||
hasEnumEntries = Flag.Class.HAS_ENUM_ENTRIES(source.flags)
|
||||
isCompanion = source.kind == KmClassKind.COMPANION_OBJECT,
|
||||
isData = source.isData,
|
||||
isValue = source.isValue,
|
||||
isInner = source.isInner,
|
||||
hasEnumEntries = source.hasEnumEntries
|
||||
)
|
||||
|
||||
fun defaultEnumEntry(
|
||||
@@ -296,26 +295,25 @@ object CirDeserializers {
|
||||
)
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
private inline fun classKind(flags: Flags): ClassKind =
|
||||
when {
|
||||
Flag.Class.IS_CLASS(flags) -> ClassKind.CLASS
|
||||
Flag.Class.IS_INTERFACE(flags) -> ClassKind.INTERFACE
|
||||
Flag.Class.IS_ENUM_CLASS(flags) -> ClassKind.ENUM_CLASS
|
||||
Flag.Class.IS_ENUM_ENTRY(flags) -> ClassKind.ENUM_ENTRY
|
||||
Flag.Class.IS_ANNOTATION_CLASS(flags) -> ClassKind.ANNOTATION_CLASS
|
||||
Flag.Class.IS_OBJECT(flags) || Flag.Class.IS_COMPANION_OBJECT(flags) -> ClassKind.OBJECT
|
||||
else -> error("Can't decode class kind from flags: $flags")
|
||||
private inline fun classKind(kmClassKind: KmClassKind): ClassKind =
|
||||
when (kmClassKind) {
|
||||
KmClassKind.CLASS -> ClassKind.CLASS
|
||||
KmClassKind.INTERFACE -> ClassKind.INTERFACE
|
||||
KmClassKind.ENUM_CLASS -> ClassKind.ENUM_CLASS
|
||||
KmClassKind.ENUM_ENTRY -> ClassKind.ENUM_ENTRY
|
||||
KmClassKind.ANNOTATION_CLASS -> ClassKind.ANNOTATION_CLASS
|
||||
KmClassKind.OBJECT, KmClassKind.COMPANION_OBJECT -> ClassKind.OBJECT
|
||||
}
|
||||
|
||||
fun constructor(source: KmConstructor, containingClass: CirContainingClass, typeResolver: CirTypeResolver): CirClassConstructor =
|
||||
CirClassConstructor.create(
|
||||
annotations = annotations(source.flags, typeResolver, source::annotations),
|
||||
annotations = annotations(source.hasAnnotations, typeResolver, source::annotations),
|
||||
typeParameters = emptyList(), // TODO: nowhere to read constructor type parameters from
|
||||
visibility = visibility(source.flags),
|
||||
visibility = visibility(source.visibility),
|
||||
containingClass = containingClass,
|
||||
valueParameters = source.valueParameters.compactMap { valueParameter(it, typeResolver) },
|
||||
hasStableParameterNames = !Flag.Constructor.HAS_NON_STABLE_PARAMETER_NAMES(source.flags),
|
||||
isPrimary = !Flag.Constructor.IS_SECONDARY(source.flags)
|
||||
hasStableParameterNames = !source.hasNonStableParameterNames,
|
||||
isPrimary = !source.isSecondary
|
||||
)
|
||||
|
||||
fun typeAlias(name: CirName, source: KmTypeAlias, typeResolver: CirTypeResolver): CirTypeAlias {
|
||||
@@ -323,10 +321,10 @@ object CirDeserializers {
|
||||
val expandedType = underlyingType.unabbreviate()
|
||||
|
||||
return CirTypeAlias.create(
|
||||
annotations = annotations(source.flags, typeResolver, source::annotations),
|
||||
annotations = annotations(source.hasAnnotations, typeResolver, source::annotations),
|
||||
name = name,
|
||||
typeParameters = source.typeParameters.compactMap { typeParameter(it, typeResolver) },
|
||||
visibility = visibility(source.flags),
|
||||
visibility = visibility(source.visibility),
|
||||
underlyingType = underlyingType,
|
||||
expandedType = expandedType
|
||||
)
|
||||
@@ -335,7 +333,7 @@ object CirDeserializers {
|
||||
private fun type(source: KmType, typeResolver: CirTypeResolver): CirType {
|
||||
@Suppress("NAME_SHADOWING")
|
||||
val source = source.abbreviatedType ?: source
|
||||
val isMarkedNullable = Flag.Type.IS_NULLABLE(source.flags)
|
||||
val isMarkedNullable = source.isNullable
|
||||
|
||||
return when (val classifier = source.classifier) {
|
||||
is KmClassifier.Class -> {
|
||||
@@ -403,23 +401,22 @@ object CirDeserializers {
|
||||
}
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
private inline fun modality(flags: Flags): Modality =
|
||||
when {
|
||||
Flag.Common.IS_FINAL(flags) -> Modality.FINAL
|
||||
Flag.Common.IS_ABSTRACT(flags) -> Modality.ABSTRACT
|
||||
Flag.Common.IS_OPEN(flags) -> Modality.OPEN
|
||||
Flag.Common.IS_SEALED(flags) -> Modality.SEALED
|
||||
else -> error("Can't decode modality from flags: $flags")
|
||||
private inline fun modality(kmModality: KmModality): Modality =
|
||||
when (kmModality) {
|
||||
KmModality.FINAL -> Modality.FINAL
|
||||
KmModality.ABSTRACT -> Modality.ABSTRACT
|
||||
KmModality.OPEN -> Modality.OPEN
|
||||
KmModality.SEALED -> Modality.SEALED
|
||||
}
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
private inline fun visibility(flags: Flags): Visibility =
|
||||
when {
|
||||
Flag.Common.IS_PUBLIC(flags) -> Visibilities.Public
|
||||
Flag.Common.IS_PROTECTED(flags) -> Visibilities.Protected
|
||||
Flag.Common.IS_INTERNAL(flags) -> Visibilities.Internal
|
||||
Flag.Common.IS_PRIVATE(flags) -> Visibilities.Private
|
||||
else -> error("Can't decode visibility from flags: $flags")
|
||||
private inline fun visibility(kmVisibility: KmVisibility): Visibility =
|
||||
when (kmVisibility) {
|
||||
KmVisibility.PUBLIC -> Visibilities.Public
|
||||
KmVisibility.PROTECTED -> Visibilities.Protected
|
||||
KmVisibility.INTERNAL -> Visibilities.Internal
|
||||
KmVisibility.PRIVATE -> Visibilities.Private
|
||||
else -> error("Can't decode visibility $kmVisibility")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ internal fun CirClass.serializeClass(
|
||||
nestedFunctions: Collection<KmFunction>,
|
||||
nestedProperties: Collection<KmProperty>
|
||||
): KmClass = KmClass().also { clazz ->
|
||||
clazz.flags = classFlags(isExpect = context.isCommon)
|
||||
clazz.modifiersFrom(this, context.isCommon)
|
||||
annotations.mapTo(clazz.annotations) { it.serializeAnnotation() }
|
||||
typeParameters.serializeTypeParameters(context, output = clazz.typeParameters)
|
||||
clazz.name = className
|
||||
@@ -89,7 +89,7 @@ internal fun CirClass.serializeClass(
|
||||
directNestedClasses.forEach { directNestedClass ->
|
||||
val shortClassName = directNestedClass.name.substringAfterLast('.')
|
||||
|
||||
if (Flag.Class.IS_ENUM_ENTRY(directNestedClass.flags)) {
|
||||
if (directNestedClass.kind == ClassKind.ENUM_ENTRY) {
|
||||
clazz.enumEntries += shortClassName
|
||||
clazz.klibEnumEntries += KlibEnumEntry(name = shortClassName, annotations = directNestedClass.annotations)
|
||||
} else {
|
||||
@@ -127,7 +127,7 @@ internal fun linkSealedClassesWithSubclasses(packageName: CirPackageName, classC
|
||||
internal fun CirClassConstructor.serializeConstructor(
|
||||
context: CirTreeSerializationContext
|
||||
): KmConstructor = KmConstructor().also { constructor ->
|
||||
constructor.flags = classConstructorFlags()
|
||||
constructor.modifiersFrom(this)
|
||||
annotations.mapTo(constructor.annotations) { it.serializeAnnotation() }
|
||||
// TODO: nowhere to write constructor type parameters
|
||||
valueParameters.mapTo(constructor.valueParameters) { it.serializeValueParameter(context) }
|
||||
@@ -138,7 +138,7 @@ internal fun CirTypeAlias.serializeTypeAlias(
|
||||
): KmTypeAlias = KmTypeAlias(
|
||||
name = name.name
|
||||
).also { typeAlias ->
|
||||
typeAlias.flags = typeAliasFlags()
|
||||
typeAlias.modifiersFrom(this)
|
||||
annotations.mapTo(typeAlias.annotations) { it.serializeAnnotation() }
|
||||
typeParameters.serializeTypeParameters(context, output = typeAlias.typeParameters)
|
||||
typeAlias.underlyingType = underlyingType.serializeType(context, expansion = ONLY_ABBREVIATIONS)
|
||||
@@ -148,9 +148,9 @@ internal fun CirTypeAlias.serializeTypeAlias(
|
||||
internal fun CirProperty.serializeProperty(
|
||||
context: CirTreeSerializationContext,
|
||||
): KmProperty = KmProperty(name = name.name).also { property ->
|
||||
property.flags = propertyFlags(isExpect = context.isCommon && !isLiftedUp)
|
||||
property.getterFlags = getter?.propertyAccessorFlags(this, this) ?: NO_FLAGS
|
||||
property.setterFlags = setter?.let { setter -> setter.propertyAccessorFlags(setter, this) } ?: NO_FLAGS
|
||||
property.modifiersFrom(this, isExpect = context.isCommon && !isLiftedUp)
|
||||
this.getter?.let { property.getter.modifiersFrom(it, this, this) }
|
||||
property.setter = this.setter?.let { KmPropertyAccessorAttributes().apply { modifiersFrom(it, it, this@serializeProperty) } }
|
||||
annotations.mapTo(property.annotations) { it.serializeAnnotation() }
|
||||
getter?.annotations?.mapTo(property.getterAnnotations) { it.serializeAnnotation() }
|
||||
setter?.annotations?.mapTo(property.setterAnnotations) { it.serializeAnnotation() }
|
||||
@@ -180,7 +180,7 @@ internal fun CirFunction.serializeFunction(
|
||||
): KmFunction = KmFunction(
|
||||
name = name.name
|
||||
).also { function ->
|
||||
function.flags = functionFlags(isExpect = context.isCommon && kind != CallableMemberDescriptor.Kind.SYNTHESIZED)
|
||||
function.modifiersFrom(this, isExpect = context.isCommon && kind != CallableMemberDescriptor.Kind.SYNTHESIZED)
|
||||
annotations.mapTo(function.annotations) { it.serializeAnnotation() }
|
||||
typeParameters.serializeTypeParameters(context, output = function.typeParameters)
|
||||
valueParameters.mapTo(function.valueParameters) { it.serializeValueParameter(context) }
|
||||
@@ -241,7 +241,7 @@ private fun CirValueParameter.serializeValueParameter(
|
||||
): KmValueParameter = KmValueParameter(
|
||||
name = name.name
|
||||
).also { parameter ->
|
||||
parameter.flags = valueParameterFlags()
|
||||
parameter.modifiersFrom(this)
|
||||
annotations.mapTo(parameter.annotations) { it.serializeAnnotation() }
|
||||
parameter.type = returnType.serializeType(context)
|
||||
varargElementType?.let { varargElementType ->
|
||||
@@ -259,7 +259,7 @@ private fun List<CirTypeParameter>.serializeTypeParameters(
|
||||
id = context.typeParameterIndexOffset + index,
|
||||
variance = cirTypeParameter.variance.serializeVariance()
|
||||
).also { parameter ->
|
||||
parameter.flags = cirTypeParameter.typeParameterFlags()
|
||||
parameter.isReified = cirTypeParameter.isReified
|
||||
cirTypeParameter.upperBounds.mapTo(parameter.upperBounds) { it.serializeType(context) }
|
||||
cirTypeParameter.annotations.mapTo(parameter.annotations) { it.serializeAnnotation() }
|
||||
}
|
||||
|
||||
@@ -220,15 +220,15 @@ private class CirTreeSerializationVisitor(
|
||||
clazz: KmClass,
|
||||
classContext: CirTreeSerializationContext
|
||||
) = logDeclaration(classContext.targetIndex) {
|
||||
val declarationType = when {
|
||||
Flag.Class.IS_ENUM_CLASS(clazz.flags) -> DeclarationType.ENUM_CLASS
|
||||
Flag.Class.IS_ENUM_ENTRY(clazz.flags) -> DeclarationType.ENUM_ENTRY
|
||||
Flag.Class.IS_INTERFACE(clazz.flags) -> when {
|
||||
val declarationType = when (clazz.kind) {
|
||||
ClassKind.ENUM_CLASS -> DeclarationType.ENUM_CLASS
|
||||
ClassKind.ENUM_ENTRY -> DeclarationType.ENUM_ENTRY
|
||||
ClassKind.INTERFACE -> when {
|
||||
(classContext.currentPath as Path.Classifier).classifierId.isNestedEntity -> DeclarationType.NESTED_INTERFACE
|
||||
else -> DeclarationType.TOP_LEVEL_INTERFACE
|
||||
}
|
||||
else -> when {
|
||||
Flag.Class.IS_COMPANION_OBJECT(clazz.flags) -> DeclarationType.COMPANION_OBJECT
|
||||
clazz.kind == ClassKind.COMPANION_OBJECT -> DeclarationType.COMPANION_OBJECT
|
||||
(classContext.currentPath as Path.Classifier).classifierId.isNestedEntity -> DeclarationType.NESTED_CLASS
|
||||
else -> DeclarationType.TOP_LEVEL_CLASS
|
||||
}
|
||||
@@ -435,7 +435,7 @@ internal class ClassConsumer {
|
||||
|
||||
fun consume(clazz: KmClass) {
|
||||
_allClasses += clazz
|
||||
if (Flag.Common.IS_SEALED(clazz.flags)) _sealedClasses += clazz
|
||||
if (clazz.modality == Modality.SEALED) _sealedClasses += clazz
|
||||
}
|
||||
|
||||
fun reset() {
|
||||
|
||||
@@ -6,56 +6,59 @@
|
||||
package org.jetbrains.kotlin.commonizer.metadata
|
||||
|
||||
import kotlinx.metadata.*
|
||||
import kotlinx.metadata.Modality as KmModality
|
||||
import kotlinx.metadata.ClassKind as KmClassKind
|
||||
import org.jetbrains.kotlin.commonizer.cir.*
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
|
||||
internal const val NO_FLAGS: Flags = 0
|
||||
|
||||
internal fun CirFunction.functionFlags(isExpect: Boolean): Flags =
|
||||
flagsOfNotNull(
|
||||
hasAnnotationsFlag,
|
||||
visibilityFlag,
|
||||
modalityFlag,
|
||||
memberKindFlag,
|
||||
Flag.Function.HAS_NON_STABLE_PARAMETER_NAMES.takeIf { !hasStableParameterNames },
|
||||
Flag.Function.IS_EXPECT.takeIf { isExpect }
|
||||
) or modifiers.modifiersFlags
|
||||
|
||||
internal fun CirProperty.propertyFlags(isExpect: Boolean): Flags =
|
||||
flagsOfNotNull(
|
||||
hasAnnotationsFlag,
|
||||
visibilityFlag,
|
||||
modalityFlag,
|
||||
memberKindFlag,
|
||||
Flag.Property.HAS_GETTER.takeIf { getter != null },
|
||||
Flag.Property.HAS_SETTER.takeIf { setter != null },
|
||||
Flag.Property.IS_DELEGATED.takeIf { isDelegate },
|
||||
Flag.Property.IS_EXPECT.takeIf { isExpect }
|
||||
) or modifiersFlags
|
||||
|
||||
internal fun CirPropertyAccessor.propertyAccessorFlags(
|
||||
visibilityHolder: CirHasVisibility,
|
||||
modalityHolder: CirHasModality
|
||||
): Flags {
|
||||
return flagsOfNotNull(
|
||||
hasAnnotationsFlag,
|
||||
visibilityHolder.visibilityFlag,
|
||||
modalityHolder.modalityFlag,
|
||||
Flag.PropertyAccessor.IS_NOT_DEFAULT.takeIf { !isDefault },
|
||||
Flag.PropertyAccessor.IS_INLINE.takeIf { isInline }
|
||||
)
|
||||
internal fun KmFunction.modifiersFrom(cf: CirFunction, isExpect: Boolean) {
|
||||
hasAnnotations = cf.hasAnnotations
|
||||
visibility = cf.kmVisibility
|
||||
modality = cf.kmModality
|
||||
kind = cf.kind.kmMemberKind
|
||||
hasNonStableParameterNames = !cf.hasStableParameterNames
|
||||
this.isExpect = isExpect
|
||||
isOperator = cf.modifiers.isOperator
|
||||
isInfix = cf.modifiers.isInfix
|
||||
isInline = cf.modifiers.isInline
|
||||
isSuspend = cf.modifiers.isSuspend
|
||||
}
|
||||
|
||||
internal fun CirClassConstructor.classConstructorFlags(): Flags =
|
||||
flagsOfNotNull(
|
||||
hasAnnotationsFlag,
|
||||
visibilityFlag,
|
||||
Flag.Constructor.IS_SECONDARY.takeIf { !isPrimary },
|
||||
Flag.Constructor.HAS_NON_STABLE_PARAMETER_NAMES.takeIf { !hasStableParameterNames }
|
||||
)
|
||||
internal fun KmProperty.modifiersFrom(cp: CirProperty, isExpect: Boolean) {
|
||||
hasAnnotations = cp.hasAnnotations
|
||||
visibility = cp.kmVisibility
|
||||
modality = cp.kmModality
|
||||
kind = cp.kind.kmMemberKind
|
||||
hasGetter = cp.getter != null
|
||||
hasSetter = cp.setter != null
|
||||
isDelegated = cp.isDelegate
|
||||
this.isExpect = isExpect
|
||||
isVar = cp.isVar
|
||||
isConst = cp.isConst
|
||||
hasConstant = cp.compileTimeInitializer.takeIf { it !is CirConstantValue.NullValue } != null
|
||||
isLateinit = cp.isLateInit
|
||||
}
|
||||
|
||||
internal fun KmPropertyAccessorAttributes.modifiersFrom(
|
||||
cp: CirPropertyAccessor, visibilityHolder: CirHasVisibility,
|
||||
modalityHolder: CirHasModality,
|
||||
) {
|
||||
hasAnnotations = cp.hasAnnotations
|
||||
visibility = visibilityHolder.kmVisibility
|
||||
modality = modalityHolder.kmModality
|
||||
isNotDefault = !cp.isDefault
|
||||
isInline = cp.isInline
|
||||
}
|
||||
|
||||
internal fun KmConstructor.modifiersFrom(cc: CirClassConstructor) {
|
||||
hasAnnotations = cc.hasAnnotations
|
||||
visibility = cc.kmVisibility
|
||||
isSecondary = !cc.isPrimary
|
||||
hasNonStableParameterNames = !cc.hasStableParameterNames
|
||||
}
|
||||
|
||||
internal fun CirType.applyTypeFlagsTo(type: KmType) {
|
||||
type.isNullable = when (this) {
|
||||
@@ -65,111 +68,79 @@ internal fun CirType.applyTypeFlagsTo(type: KmType) {
|
||||
//Flag.Type.IS_SUSPEND.takeIf { false }
|
||||
}
|
||||
|
||||
internal fun CirTypeParameter.typeParameterFlags(): Flags =
|
||||
flagsOfNotNull(
|
||||
Flag.TypeParameter.IS_REIFIED.takeIf { isReified }
|
||||
)
|
||||
internal fun KmValueParameter.modifiersFrom(cv: CirValueParameter) {
|
||||
hasAnnotations = cv.hasAnnotations
|
||||
declaresDefaultValue = cv.declaresDefaultValue
|
||||
isCrossinline = cv.isCrossinline
|
||||
isNoinline = cv.isNoinline
|
||||
}
|
||||
|
||||
internal fun CirValueParameter.valueParameterFlags(): Flags =
|
||||
flagsOfNotNull(
|
||||
hasAnnotationsFlag,
|
||||
Flag.ValueParameter.DECLARES_DEFAULT_VALUE.takeIf { declaresDefaultValue },
|
||||
Flag.ValueParameter.IS_CROSSINLINE.takeIf { isCrossinline },
|
||||
Flag.ValueParameter.IS_NOINLINE.takeIf { isNoinline }
|
||||
)
|
||||
internal fun KmClass.modifiersFrom(cc: CirClass, isExpect: Boolean) {
|
||||
hasAnnotations = cc.hasAnnotations
|
||||
visibility = cc.kmVisibility
|
||||
modality = cc.kmModality
|
||||
kind = cc.kmClassKind
|
||||
isInner = cc.isInner
|
||||
isData = cc.isData
|
||||
this.isExpect = isExpect
|
||||
isValue = cc.isValue
|
||||
hasEnumEntries = cc.hasEnumEntries
|
||||
//Flag.Class.IS_FUN.takeIf { false }
|
||||
}
|
||||
|
||||
internal fun CirClass.classFlags(isExpect: Boolean): Flags =
|
||||
flagsOfNotNull(
|
||||
hasAnnotationsFlag,
|
||||
visibilityFlag,
|
||||
modalityFlag,
|
||||
classKindFlag,
|
||||
Flag.Class.IS_COMPANION_OBJECT.takeIf { isCompanion },
|
||||
Flag.Class.IS_INNER.takeIf { isInner },
|
||||
Flag.Class.IS_DATA.takeIf { isData },
|
||||
Flag.Class.IS_EXPECT.takeIf { isExpect },
|
||||
Flag.Class.IS_VALUE.takeIf { isValue },
|
||||
Flag.Class.HAS_ENUM_ENTRIES.takeIf { hasEnumEntries }
|
||||
//Flag.Class.IS_FUN.takeIf { false }
|
||||
)
|
||||
internal fun KmTypeAlias.modifiersFrom(ct: CirTypeAlias) {
|
||||
hasAnnotations = ct.hasAnnotations
|
||||
visibility = ct.kmVisibility
|
||||
}
|
||||
|
||||
internal fun CirTypeAlias.typeAliasFlags(): Flags =
|
||||
flagsOfNotNull(
|
||||
hasAnnotationsFlag,
|
||||
visibilityFlag
|
||||
)
|
||||
|
||||
private inline val CirHasAnnotations.hasAnnotationsFlag: Flag?
|
||||
get() = if (annotations.isNotEmpty()) Flag.Common.HAS_ANNOTATIONS else null
|
||||
private inline val CirHasAnnotations.hasAnnotations: Boolean
|
||||
get() = annotations.isNotEmpty()
|
||||
|
||||
// Since 1.4.30 a special @JvmInline annotation is generated to distinguish JVM-inline from value classes.
|
||||
// This has an effect on class serialization: Every class with isValue == true automatically gets HAS_ANNOTATIONS flag.
|
||||
private inline val CirClass.hasAnnotationsFlag: Flag?
|
||||
get() = if (annotations.isNotEmpty() || isValue) Flag.Common.HAS_ANNOTATIONS else null
|
||||
private inline val CirClass.hasAnnotations: Boolean
|
||||
get() = annotations.isNotEmpty() || isValue
|
||||
|
||||
private inline val CirProperty.hasAnnotationsFlag: Flag?
|
||||
get() = if (annotations.isNotEmpty() || !backingFieldAnnotations.isNullOrEmpty() || !delegateFieldAnnotations.isNullOrEmpty())
|
||||
Flag.Common.HAS_ANNOTATIONS
|
||||
else
|
||||
null
|
||||
private inline val CirProperty.hasAnnotations: Boolean
|
||||
get() = annotations.isNotEmpty() || backingFieldAnnotations.isNotEmpty() || delegateFieldAnnotations.isNotEmpty()
|
||||
|
||||
private inline val CirHasVisibility.visibilityFlag: Flag
|
||||
private inline val CirHasVisibility.kmVisibility: Visibility
|
||||
get() = when (visibility) {
|
||||
Visibilities.Public -> Flag.Common.IS_PUBLIC
|
||||
Visibilities.Protected -> Flag.Common.IS_PROTECTED
|
||||
Visibilities.Internal -> Flag.Common.IS_INTERNAL
|
||||
Visibilities.Private -> Flag.Common.IS_PRIVATE
|
||||
Visibilities.Public -> Visibility.PUBLIC
|
||||
Visibilities.Protected -> Visibility.PROTECTED
|
||||
Visibilities.Internal -> Visibility.INTERNAL
|
||||
Visibilities.Private -> Visibility.PRIVATE
|
||||
else -> error("Unexpected visibility: $this")
|
||||
}
|
||||
|
||||
private inline val CirHasModality.modalityFlag: Flag
|
||||
private inline val CirHasModality.kmModality: KmModality
|
||||
get() = when (modality) {
|
||||
Modality.FINAL -> Flag.Common.IS_FINAL
|
||||
Modality.ABSTRACT -> Flag.Common.IS_ABSTRACT
|
||||
Modality.OPEN -> Flag.Common.IS_OPEN
|
||||
Modality.SEALED -> Flag.Common.IS_SEALED
|
||||
Modality.FINAL -> KmModality.FINAL
|
||||
Modality.ABSTRACT -> KmModality.ABSTRACT
|
||||
Modality.OPEN -> KmModality.OPEN
|
||||
Modality.SEALED -> KmModality.SEALED
|
||||
}
|
||||
|
||||
private inline val CirFunction.memberKindFlag: Flag
|
||||
get() = when (kind) {
|
||||
CallableMemberDescriptor.Kind.DECLARATION -> Flag.Function.IS_DECLARATION
|
||||
CallableMemberDescriptor.Kind.FAKE_OVERRIDE -> Flag.Function.IS_FAKE_OVERRIDE
|
||||
CallableMemberDescriptor.Kind.DELEGATION -> Flag.Function.IS_DELEGATION
|
||||
CallableMemberDescriptor.Kind.SYNTHESIZED -> Flag.Function.IS_SYNTHESIZED
|
||||
private inline val CallableMemberDescriptor.Kind.kmMemberKind: MemberKind
|
||||
get() = when (this) {
|
||||
CallableMemberDescriptor.Kind.DECLARATION -> MemberKind.DECLARATION
|
||||
CallableMemberDescriptor.Kind.FAKE_OVERRIDE -> MemberKind.FAKE_OVERRIDE
|
||||
CallableMemberDescriptor.Kind.DELEGATION -> MemberKind.DELEGATION
|
||||
CallableMemberDescriptor.Kind.SYNTHESIZED -> MemberKind.SYNTHESIZED
|
||||
}
|
||||
|
||||
private inline val CirProperty.memberKindFlag: Flag
|
||||
get() = when (kind) {
|
||||
CallableMemberDescriptor.Kind.DECLARATION -> Flag.Property.IS_DECLARATION
|
||||
CallableMemberDescriptor.Kind.FAKE_OVERRIDE -> Flag.Property.IS_FAKE_OVERRIDE
|
||||
CallableMemberDescriptor.Kind.DELEGATION -> Flag.Property.IS_DELEGATION
|
||||
CallableMemberDescriptor.Kind.SYNTHESIZED -> Flag.Property.IS_SYNTHESIZED
|
||||
private inline val CirClass.kmClassKind: KmClassKind
|
||||
get() {
|
||||
if (isCompanion) return KmClassKind.COMPANION_OBJECT
|
||||
return when (kind) {
|
||||
ClassKind.CLASS -> KmClassKind.CLASS
|
||||
ClassKind.INTERFACE -> KmClassKind.INTERFACE
|
||||
ClassKind.ENUM_CLASS -> KmClassKind.ENUM_CLASS
|
||||
ClassKind.ENUM_ENTRY -> KmClassKind.ENUM_ENTRY
|
||||
ClassKind.ANNOTATION_CLASS -> KmClassKind.ANNOTATION_CLASS
|
||||
ClassKind.OBJECT -> KmClassKind.OBJECT
|
||||
}
|
||||
}
|
||||
|
||||
private inline val CirClass.classKindFlag: Flag
|
||||
get() = when (kind) {
|
||||
ClassKind.CLASS -> Flag.Class.IS_CLASS
|
||||
ClassKind.INTERFACE -> Flag.Class.IS_INTERFACE
|
||||
ClassKind.ENUM_CLASS -> Flag.Class.IS_ENUM_CLASS
|
||||
ClassKind.ENUM_ENTRY -> Flag.Class.IS_ENUM_ENTRY
|
||||
ClassKind.ANNOTATION_CLASS -> Flag.Class.IS_ANNOTATION_CLASS
|
||||
ClassKind.OBJECT -> Flag.Class.IS_OBJECT
|
||||
}
|
||||
|
||||
private inline val CirFunctionModifiers.modifiersFlags: Flags
|
||||
get() = flagsOfNotNull(
|
||||
Flag.Function.IS_OPERATOR.takeIf { isOperator },
|
||||
Flag.Function.IS_INFIX.takeIf { isInfix },
|
||||
Flag.Function.IS_INLINE.takeIf { isInline },
|
||||
Flag.Function.IS_SUSPEND.takeIf { isSuspend },
|
||||
)
|
||||
|
||||
private inline val CirProperty.modifiersFlags: Flags
|
||||
get() = flagsOfNotNull(
|
||||
Flag.Property.IS_VAR.takeIf { isVar },
|
||||
Flag.Property.IS_CONST.takeIf { isConst },
|
||||
Flag.Property.HAS_CONSTANT.takeIf { compileTimeInitializer.takeIf { it !is CirConstantValue.NullValue } != null },
|
||||
Flag.Property.IS_LATEINIT.takeIf { isLateInit },
|
||||
)
|
||||
|
||||
private fun flagsOfNotNull(vararg flags: Flag?): Flags = flagsOf(*listOfNotNull(*flags).toTypedArray())
|
||||
|
||||
+4
-2
@@ -3,6 +3,8 @@
|
||||
* 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") // TODO: kotlinx.metadata Flags API. Usage here is too big.
|
||||
|
||||
package org.jetbrains.kotlin.commonizer.metadata.utils
|
||||
|
||||
import com.intellij.util.containers.FactoryMap
|
||||
@@ -972,8 +974,8 @@ class MetadataDeclarationsComparator private constructor(private val config: Con
|
||||
|
||||
private fun compareFlags(
|
||||
containerContext: Context,
|
||||
flagsA: Flags,
|
||||
flagsB: Flags,
|
||||
flagsA: Int,
|
||||
flagsB: Int,
|
||||
flagsToCompare: Array<KProperty0<Flag>>,
|
||||
flagKind: FlagKind = FlagKind.REGULAR
|
||||
) {
|
||||
|
||||
+3
-4
@@ -5,8 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.commonizer.tree.deserializer
|
||||
|
||||
import kotlinx.metadata.Flag
|
||||
import kotlinx.metadata.KmClass
|
||||
import kotlinx.metadata.*
|
||||
import org.jetbrains.kotlin.commonizer.metadata.CirDeserializers
|
||||
import org.jetbrains.kotlin.commonizer.metadata.CirTypeResolver
|
||||
import org.jetbrains.kotlin.commonizer.tree.CirTreeClass
|
||||
@@ -29,7 +28,7 @@ internal class CirTreeClassDeserializer(
|
||||
val cirClass = when (classEntry) {
|
||||
is ClassesToProcess.ClassEntry.RegularClassEntry -> {
|
||||
clazz = classEntry.clazz
|
||||
isEnumEntry = Flag.Class.IS_ENUM_ENTRY(clazz.flags)
|
||||
isEnumEntry = clazz.kind == ClassKind.ENUM_ENTRY
|
||||
CirDeserializers.clazz(className, clazz, classTypeResolver)
|
||||
}
|
||||
is ClassesToProcess.ClassEntry.EnumEntry -> {
|
||||
@@ -40,7 +39,7 @@ internal class CirTreeClassDeserializer(
|
||||
name = className,
|
||||
annotations = classEntry.annotations,
|
||||
enumClassId = classEntry.enumClassId,
|
||||
hasEnumEntries = Flag.Class.HAS_ENUM_ENTRIES(classEntry.enumClass.flags),
|
||||
hasEnumEntries = classEntry.enumClass.hasEnumEntries,
|
||||
typeResolver = classTypeResolver
|
||||
)
|
||||
}
|
||||
|
||||
+2
-4
@@ -6,9 +6,7 @@
|
||||
package org.jetbrains.kotlin.commonizer.tree.deserializer
|
||||
|
||||
import com.intellij.util.containers.FactoryMap
|
||||
import kotlinx.metadata.Flag
|
||||
import kotlinx.metadata.KmAnnotation
|
||||
import kotlinx.metadata.KmClass
|
||||
import kotlinx.metadata.*
|
||||
import kotlinx.metadata.internal.common.KmModuleFragment
|
||||
import kotlinx.metadata.klib.klibEnumEntries
|
||||
import org.jetbrains.kotlin.commonizer.cir.CirEntityId
|
||||
@@ -44,7 +42,7 @@ internal class ClassesToProcess {
|
||||
val classId: CirEntityId = CirEntityId.create(clazz.name)
|
||||
val parentClassId: CirEntityId = classId.getParentEntityId() ?: NON_EXISTING_CLASSIFIER_ID
|
||||
|
||||
if (Flag.Class.IS_ENUM_CLASS(clazz.flags)) {
|
||||
if (clazz.kind == ClassKind.ENUM_CLASS) {
|
||||
clazz.klibEnumEntries.forEach { entry ->
|
||||
val enumEntryId = classId.createNestedEntityId(CirName.create(entry.name))
|
||||
klibEnumEntries[enumEntryId] = ClassEntry.EnumEntry(enumEntryId, entry.annotations, classId, clazz)
|
||||
|
||||
@@ -5,9 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.commonizer.utils
|
||||
|
||||
import kotlinx.metadata.Flag
|
||||
import kotlinx.metadata.KmFunction
|
||||
import kotlinx.metadata.KmProperty
|
||||
import kotlinx.metadata.*
|
||||
import kotlinx.metadata.klib.annotations
|
||||
|
||||
internal const val KNI_BRIDGE_FUNCTION_PREFIX = "kniBridge"
|
||||
@@ -21,9 +19,7 @@ internal inline fun KmFunction.isTopLevelDeprecatedFunction(isTopLevel: Boolean)
|
||||
isTopLevel && annotations.any { it.className == DEPRECATED_ANNOTATION_FULL_NAME }
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
internal inline fun KmProperty.isFakeOverride() =
|
||||
Flag.Property.IS_FAKE_OVERRIDE(flags)
|
||||
internal inline fun KmProperty.isFakeOverride() = this.kind == MemberKind.FAKE_OVERRIDE
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
internal inline fun KmFunction.isFakeOverride() =
|
||||
Flag.Function.IS_FAKE_OVERRIDE(flags)
|
||||
internal inline fun KmFunction.isFakeOverride() = this.kind == MemberKind.FAKE_OVERRIDE
|
||||
|
||||
@@ -14,10 +14,10 @@ internal inline val KmClass.filteredSupertypes: List<KmType>
|
||||
get() = supertypes.takeUnless { it.singleOrNull()?.isAny == true } ?: emptyList()
|
||||
|
||||
private inline val KmType.isNullableAny: Boolean
|
||||
get() = (classifier as? KmClassifier.Class)?.name == ANY_CLASS_FULL_NAME && Flag.Type.IS_NULLABLE(flags)
|
||||
get() = (classifier as? KmClassifier.Class)?.name == ANY_CLASS_FULL_NAME && this.isNullable
|
||||
|
||||
private inline val KmType.isAny: Boolean
|
||||
get() = (classifier as? KmClassifier.Class)?.name == ANY_CLASS_FULL_NAME && !Flag.Type.IS_NULLABLE(flags)
|
||||
get() = (classifier as? KmClassifier.Class)?.name == ANY_CLASS_FULL_NAME && !this.isNullable
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -5,13 +5,13 @@
|
||||
|
||||
package org.jetbrains.kotlin.jvm.abi
|
||||
|
||||
import kotlinx.metadata.Flag
|
||||
import kotlinx.metadata.Flags
|
||||
import kotlinx.metadata.KmClass
|
||||
import kotlinx.metadata.KmPackage
|
||||
import kotlinx.metadata.Visibility
|
||||
import kotlinx.metadata.jvm.KotlinClassMetadata
|
||||
import kotlinx.metadata.jvm.Metadata
|
||||
import kotlinx.metadata.jvm.localDelegatedProperties
|
||||
import kotlinx.metadata.visibility
|
||||
import org.jetbrains.kotlin.load.java.JvmAnnotationNames.*
|
||||
import org.jetbrains.org.objectweb.asm.AnnotationVisitor
|
||||
import org.jetbrains.org.objectweb.asm.Opcodes
|
||||
@@ -154,19 +154,19 @@ private fun AnnotationVisitor.visitKotlinMetadata(header: Metadata) {
|
||||
}
|
||||
|
||||
private fun KmClass.removePrivateDeclarations() {
|
||||
constructors.removeIf { isPrivateDeclaration(it.flags) }
|
||||
functions.removeIf { isPrivateDeclaration(it.flags) }
|
||||
properties.removeIf { isPrivateDeclaration(it.flags) }
|
||||
constructors.removeIf { it.visibility.isPrivate }
|
||||
functions.removeIf { it.visibility.isPrivate }
|
||||
properties.removeIf { it.visibility.isPrivate }
|
||||
localDelegatedProperties.clear()
|
||||
// TODO: do not serialize private type aliases once KT-17229 is fixed.
|
||||
}
|
||||
|
||||
private fun KmPackage.removePrivateDeclarations() {
|
||||
functions.removeIf { isPrivateDeclaration(it.flags) }
|
||||
properties.removeIf { isPrivateDeclaration(it.flags) }
|
||||
functions.removeIf { it.visibility.isPrivate }
|
||||
properties.removeIf { it.visibility.isPrivate }
|
||||
localDelegatedProperties.clear()
|
||||
// TODO: do not serialize private type aliases once KT-17229 is fixed.
|
||||
}
|
||||
|
||||
private fun isPrivateDeclaration(flags: Flags): Boolean =
|
||||
Flag.IS_PRIVATE(flags) || Flag.IS_PRIVATE_TO_THIS(flags) || Flag.IS_LOCAL(flags)
|
||||
private val Visibility.isPrivate: Boolean
|
||||
get() = this == Visibility.PRIVATE || this == Visibility.PRIVATE_TO_THIS || this == Visibility.LOCAL
|
||||
|
||||
Reference in New Issue
Block a user