Add new metadata flag for class files compiled with FIR
Report a separate error when class files compiled with FIR are in dependencies, in addition to the one for class files compiled with FE 1.0 + JVM IR. #KT-43592
This commit is contained in:
@@ -46,6 +46,7 @@ public final class JvmAnnotationNames {
|
||||
public static final int METADATA_STRICT_VERSION_SEMANTICS_FLAG = 1 << 3;
|
||||
public static final int METADATA_JVM_IR_FLAG = 1 << 4;
|
||||
public static final int METADATA_JVM_IR_STABLE_ABI_FLAG = 1 << 5;
|
||||
public static final int METADATA_FIR_FLAG = 1 << 6;
|
||||
|
||||
public static final Name DEFAULT_ANNOTATION_MEMBER_NAME = Name.identifier("value");
|
||||
|
||||
|
||||
+3
@@ -27,6 +27,9 @@ enum class DeserializedContainerAbiStability {
|
||||
// Either the container is stable, or this compiler is configured to ignore ABI stability of dependencies.
|
||||
STABLE,
|
||||
|
||||
// The container is unstable because it is compiled with FIR, and this compiler is _not_ configured to ignore that.
|
||||
FIR_UNSTABLE,
|
||||
|
||||
// The container is unstable because it is compiled with unstable JVM IR backend, and this compiler is _not_ configured to ignore that.
|
||||
IR_UNSTABLE,
|
||||
}
|
||||
|
||||
+1
@@ -101,6 +101,7 @@ class DeserializedDescriptorResolver {
|
||||
private val KotlinJvmBinaryClass.abiStability: DeserializedContainerAbiStability
|
||||
get() = when {
|
||||
components.configuration.allowUnstableDependencies -> DeserializedContainerAbiStability.STABLE
|
||||
classHeader.isUnstableFirBinary -> DeserializedContainerAbiStability.FIR_UNSTABLE
|
||||
classHeader.isUnstableJvmIrBinary -> DeserializedContainerAbiStability.IR_UNSTABLE
|
||||
else -> DeserializedContainerAbiStability.STABLE
|
||||
}
|
||||
|
||||
+10
-6
@@ -5,7 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.load.kotlin.header
|
||||
|
||||
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
|
||||
import org.jetbrains.kotlin.load.java.JvmAnnotationNames.*
|
||||
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader.MultifileClassKind.DELEGATING
|
||||
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader.MultifileClassKind.INHERITING
|
||||
import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmBytecodeBinaryVersion
|
||||
@@ -54,21 +54,25 @@ class KotlinClassHeader(
|
||||
@Suppress("unused")
|
||||
val multifileClassKind: MultifileClassKind?
|
||||
get() = if (kind == Kind.MULTIFILE_CLASS || kind == Kind.MULTIFILE_CLASS_PART) {
|
||||
if ((extraInt and JvmAnnotationNames.METADATA_MULTIFILE_PARTS_INHERIT_FLAG) != 0)
|
||||
if (extraInt.has(METADATA_MULTIFILE_PARTS_INHERIT_FLAG))
|
||||
INHERITING
|
||||
else
|
||||
DELEGATING
|
||||
} else null
|
||||
|
||||
val isUnstableJvmIrBinary: Boolean
|
||||
get() = (extraInt and JvmAnnotationNames.METADATA_JVM_IR_FLAG) != 0 &&
|
||||
(extraInt and JvmAnnotationNames.METADATA_JVM_IR_STABLE_ABI_FLAG == 0)
|
||||
get() = extraInt.has(METADATA_JVM_IR_FLAG) && !extraInt.has(METADATA_JVM_IR_STABLE_ABI_FLAG)
|
||||
|
||||
val isUnstableFirBinary: Boolean
|
||||
get() = extraInt.has(METADATA_FIR_FLAG) && !extraInt.has(METADATA_JVM_IR_STABLE_ABI_FLAG)
|
||||
|
||||
val isPreRelease: Boolean
|
||||
get() = (extraInt and JvmAnnotationNames.METADATA_PRE_RELEASE_FLAG) != 0
|
||||
get() = extraInt.has(METADATA_PRE_RELEASE_FLAG)
|
||||
|
||||
val isScript: Boolean
|
||||
get() = (extraInt and JvmAnnotationNames.METADATA_SCRIPT_FLAG) != 0
|
||||
get() = extraInt.has(METADATA_SCRIPT_FLAG)
|
||||
|
||||
override fun toString() = "$kind version=$metadataVersion"
|
||||
|
||||
private fun Int.has(flag: Int): Boolean = (this and flag) != 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user