From 3f517d7e8d7dc7ceedd65678791df01101feab8d Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Mon, 7 Dec 2020 21:26:23 +0100 Subject: [PATCH] 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 --- .../messages/AnalyzerWithCompilerReport.kt | 8 +++++++ .../kotlin/config/JVMConfigurationKeys.java | 2 +- .../fir/backend/jvm/FirJvmBackendExtension.kt | 7 ++++++ .../jetbrains/kotlin/diagnostics/Errors.java | 1 + .../rendering/DefaultErrorMessages.java | 1 + .../checkers/MissingDependencyClassChecker.kt | 3 +++ .../kotlin/backend/jvm/JvmBackendExtension.kt | 8 +++++++ .../backend/jvm/codegen/ClassCodegen.kt | 6 +---- .../backend/jvm/codegen/ClassCodegen.kt.201 | 6 +---- .../kotlin/load/java/JvmAnnotationNames.java | 1 + .../DeserializedContainerSource.kt | 3 +++ .../kotlin/DeserializedDescriptorResolver.kt | 1 + .../load/kotlin/header/KotlinClassHeader.kt | 16 ++++++++----- .../idea/highlighter/KotlinPsiChecker.kt | 14 ++++++----- .../evaluate/KotlinEvaluatorBuilder.kt | 23 +++++++++++-------- .../stdlib/jvm/runtime/kotlin/Metadata.kt | 11 +++++---- 16 files changed, 74 insertions(+), 37 deletions(-) diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/common/messages/AnalyzerWithCompilerReport.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/common/messages/AnalyzerWithCompilerReport.kt index 0c749ba5708..50ce24605f3 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/common/messages/AnalyzerWithCompilerReport.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/common/messages/AnalyzerWithCompilerReport.kt @@ -190,6 +190,14 @@ class AnalyzerWithCompilerReport( ) } + if (diagnostics.any { it.factory == Errors.FIR_COMPILED_CLASS }) { + messageCollector.report( + ERROR, + "Classes compiled by the new Kotlin compiler frontend were found in dependencies. " + + "Remove them from the classpath or use '-Xallow-jvm-ir-dependencies' to suppress errors" + ) + } + return hasErrors } diff --git a/compiler/config.jvm/src/org/jetbrains/kotlin/config/JVMConfigurationKeys.java b/compiler/config.jvm/src/org/jetbrains/kotlin/config/JVMConfigurationKeys.java index 41baa5d8707..b8e6870b0a6 100644 --- a/compiler/config.jvm/src/org/jetbrains/kotlin/config/JVMConfigurationKeys.java +++ b/compiler/config.jvm/src/org/jetbrains/kotlin/config/JVMConfigurationKeys.java @@ -118,7 +118,7 @@ public class JVMConfigurationKeys { CompilerConfigurationKey.create("Paths to .klib libraries"); public static final CompilerConfigurationKey ABI_STABILITY = - CompilerConfigurationKey.create("ABI stability of class files produced by the JVM IR backend"); + CompilerConfigurationKey.create("ABI stability of class files produced by JVM IR and/or FIR"); public static final CompilerConfigurationKey DO_NOT_CLEAR_BINDING_CONTEXT = CompilerConfigurationKey.create("When using the IR backend, do not clear BindingContext between psi2ir and lowerings"); diff --git a/compiler/fir/fir2ir/jvm-backend/src/org/jetbrains/kotlin/fir/backend/jvm/FirJvmBackendExtension.kt b/compiler/fir/fir2ir/jvm-backend/src/org/jetbrains/kotlin/fir/backend/jvm/FirJvmBackendExtension.kt index 98c7eed96d0..058449161fa 100644 --- a/compiler/fir/fir2ir/jvm-backend/src/org/jetbrains/kotlin/fir/backend/jvm/FirJvmBackendExtension.kt +++ b/compiler/fir/fir2ir/jvm-backend/src/org/jetbrains/kotlin/fir/backend/jvm/FirJvmBackendExtension.kt @@ -9,9 +9,11 @@ import org.jetbrains.kotlin.backend.jvm.JvmBackendContext import org.jetbrains.kotlin.backend.jvm.JvmBackendExtension import org.jetbrains.kotlin.backend.jvm.codegen.MetadataSerializer import org.jetbrains.kotlin.codegen.serialization.JvmSerializationBindings +import org.jetbrains.kotlin.config.JvmAbiStability import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.backend.Fir2IrComponents import org.jetbrains.kotlin.ir.declarations.IrClass +import org.jetbrains.kotlin.load.java.JvmAnnotationNames import org.jetbrains.org.objectweb.asm.Type class FirJvmBackendExtension(private val session: FirSession, private val components: Fir2IrComponents) : JvmBackendExtension { @@ -24,4 +26,9 @@ class FirJvmBackendExtension(private val session: FirSession, private val compon ): MetadataSerializer { return FirMetadataSerializer(session, context, klass, bindings, components, parentSerializer) } + + override fun generateMetadataExtraFlags(abiStability: JvmAbiStability?): Int = + JvmAnnotationNames.METADATA_JVM_IR_FLAG or + JvmAnnotationNames.METADATA_FIR_FLAG or + (if (abiStability == JvmAbiStability.STABLE) JvmAnnotationNames.METADATA_JVM_IR_STABLE_ABI_FLAG else 0) } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index f0f38f9ac6f..ded6d7b0b80 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -119,6 +119,7 @@ public interface Errors { DiagnosticFactory1 MISSING_SCRIPT_PROVIDED_PROPERTY_CLASS = DiagnosticFactory1.create(ERROR); DiagnosticFactory1 PRE_RELEASE_CLASS = DiagnosticFactory1.create(ERROR); DiagnosticFactory1 IR_COMPILED_CLASS = DiagnosticFactory1.create(ERROR); + DiagnosticFactory1 FIR_COMPILED_CLASS = DiagnosticFactory1.create(ERROR); DiagnosticFactory2> INCOMPATIBLE_CLASS = DiagnosticFactory2.create(ERROR); //Elements with "INVISIBLE_REFERENCE" error are marked as unresolved, unlike elements with "INVISIBLE_MEMBER" error diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java index 75f9a22e5b8..3a06a25353e 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java @@ -402,6 +402,7 @@ public class DefaultErrorMessages { MAP.put(MISSING_SCRIPT_PROVIDED_PROPERTY_CLASS, "Cannot access script provided property class ''{0}''. Check your module classpath for missing or conflicting dependencies", TO_STRING); MAP.put(PRE_RELEASE_CLASS, "{0} is compiled by a pre-release version of Kotlin and cannot be loaded by this version of the compiler", TO_STRING); MAP.put(IR_COMPILED_CLASS, "{0} is compiled by a new Kotlin compiler backend and cannot be loaded by the old compiler", TO_STRING); + MAP.put(FIR_COMPILED_CLASS, "{0} is compiled by the new Kotlin compiler frontend and cannot be loaded by the old compiler", TO_STRING); MAP.put(INCOMPATIBLE_CLASS, "{0} was compiled with an incompatible version of Kotlin. {1}", TO_STRING, diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/MissingDependencyClassChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/MissingDependencyClassChecker.kt index 6bd2e0562be..400650958cd 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/MissingDependencyClassChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/MissingDependencyClassChecker.kt @@ -59,6 +59,9 @@ object MissingDependencyClassChecker : CallChecker { if (source.isPreReleaseInvisible) { return PRE_RELEASE_CLASS.on(reportOn, source.presentableString) } + if (source.abiStability == DeserializedContainerAbiStability.FIR_UNSTABLE) { + return FIR_COMPILED_CLASS.on(reportOn, source.presentableString) + } if (source.abiStability == DeserializedContainerAbiStability.IR_UNSTABLE) { return IR_COMPILED_CLASS.on(reportOn, source.presentableString) } diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmBackendExtension.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmBackendExtension.kt index 98f6f16eedb..a1f0e3cef0a 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmBackendExtension.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmBackendExtension.kt @@ -8,7 +8,9 @@ package org.jetbrains.kotlin.backend.jvm import org.jetbrains.kotlin.backend.jvm.codegen.DescriptorMetadataSerializer import org.jetbrains.kotlin.backend.jvm.codegen.MetadataSerializer import org.jetbrains.kotlin.codegen.serialization.JvmSerializationBindings +import org.jetbrains.kotlin.config.JvmAbiStability import org.jetbrains.kotlin.ir.declarations.IrClass +import org.jetbrains.kotlin.load.java.JvmAnnotationNames import org.jetbrains.org.objectweb.asm.Type interface JvmBackendExtension { @@ -16,6 +18,8 @@ interface JvmBackendExtension { context: JvmBackendContext, klass: IrClass, type: Type, bindings: JvmSerializationBindings, parentSerializer: MetadataSerializer? ): MetadataSerializer + fun generateMetadataExtraFlags(abiStability: JvmAbiStability?): Int + object Default : JvmBackendExtension { override fun createSerializer( context: JvmBackendContext, @@ -26,5 +30,9 @@ interface JvmBackendExtension { ): MetadataSerializer { return DescriptorMetadataSerializer(context, klass, type, bindings, parentSerializer) } + + override fun generateMetadataExtraFlags(abiStability: JvmAbiStability?): Int = + JvmAnnotationNames.METADATA_JVM_IR_FLAG or + (if (abiStability == JvmAbiStability.STABLE) JvmAnnotationNames.METADATA_JVM_IR_STABLE_ABI_FLAG else 0) } } diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ClassCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ClassCodegen.kt index e5b0042e391..2fbfafdef6c 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ClassCodegen.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ClassCodegen.kt @@ -13,7 +13,6 @@ import org.jetbrains.kotlin.backend.jvm.lower.hasAssertionsDisabledField import org.jetbrains.kotlin.codegen.DescriptorAsmUtil import org.jetbrains.kotlin.codegen.inline.* import org.jetbrains.kotlin.codegen.writeKotlinMetadata -import org.jetbrains.kotlin.config.JvmAbiStability import org.jetbrains.kotlin.config.LanguageFeature import org.jetbrains.kotlin.config.LanguageVersionSettings import org.jetbrains.kotlin.descriptors.DescriptorVisibilities @@ -197,10 +196,7 @@ class ClassCodegen private constructor( private fun generateKotlinMetadataAnnotation() { // TODO: if `-Xmultifile-parts-inherit` is enabled, write the corresponding flag for parts and facades to [Metadata.extraInt]. - var extraFlags = JvmAnnotationNames.METADATA_JVM_IR_FLAG - if (state.abiStability != JvmAbiStability.UNSTABLE) { - extraFlags += JvmAnnotationNames.METADATA_JVM_IR_STABLE_ABI_FLAG - } + val extraFlags = context.backendExtension.generateMetadataExtraFlags(state.abiStability) val facadeClassName = context.multifileFacadeForPart[irClass.attributeOwnerId] val metadata = irClass.metadata diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ClassCodegen.kt.201 b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ClassCodegen.kt.201 index 70b0eb0d719..8681265cd40 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ClassCodegen.kt.201 +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ClassCodegen.kt.201 @@ -13,7 +13,6 @@ import org.jetbrains.kotlin.backend.jvm.lower.hasAssertionsDisabledField import org.jetbrains.kotlin.codegen.DescriptorAsmUtil import org.jetbrains.kotlin.codegen.inline.* import org.jetbrains.kotlin.codegen.writeKotlinMetadata -import org.jetbrains.kotlin.config.JvmAbiStability import org.jetbrains.kotlin.config.LanguageFeature import org.jetbrains.kotlin.config.LanguageVersionSettings import org.jetbrains.kotlin.descriptors.DescriptorVisibilities @@ -197,10 +196,7 @@ class ClassCodegen private constructor( private fun generateKotlinMetadataAnnotation() { // TODO: if `-Xmultifile-parts-inherit` is enabled, write the corresponding flag for parts and facades to [Metadata.extraInt]. - var extraFlags = JvmAnnotationNames.METADATA_JVM_IR_FLAG - if (state.abiStability != JvmAbiStability.UNSTABLE) { - extraFlags += JvmAnnotationNames.METADATA_JVM_IR_STABLE_ABI_FLAG - } + val extraFlags = context.backendExtension.generateMetadataExtraFlags(state.abiStability) val facadeClassName = context.multifileFacadeForPart[irClass.attributeOwnerId] val metadata = irClass.metadata diff --git a/core/compiler.common.jvm/src/org/jetbrains/kotlin/load/java/JvmAnnotationNames.java b/core/compiler.common.jvm/src/org/jetbrains/kotlin/load/java/JvmAnnotationNames.java index fbd565b2b17..f5897f1ba1a 100644 --- a/core/compiler.common.jvm/src/org/jetbrains/kotlin/load/java/JvmAnnotationNames.java +++ b/core/compiler.common.jvm/src/org/jetbrains/kotlin/load/java/JvmAnnotationNames.java @@ -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"); diff --git a/core/compiler.common/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedContainerSource.kt b/core/compiler.common/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedContainerSource.kt index f00c58b2d23..8b7773005cd 100644 --- a/core/compiler.common/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedContainerSource.kt +++ b/core/compiler.common/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedContainerSource.kt @@ -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, } diff --git a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/kotlin/DeserializedDescriptorResolver.kt b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/kotlin/DeserializedDescriptorResolver.kt index 9a659433a4f..5195c89b22b 100644 --- a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/kotlin/DeserializedDescriptorResolver.kt +++ b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/kotlin/DeserializedDescriptorResolver.kt @@ -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 } diff --git a/core/deserialization.common.jvm/src/org/jetbrains/kotlin/load/kotlin/header/KotlinClassHeader.kt b/core/deserialization.common.jvm/src/org/jetbrains/kotlin/load/kotlin/header/KotlinClassHeader.kt index 9bd443d5d69..6a8bc7a8eaf 100644 --- a/core/deserialization.common.jvm/src/org/jetbrains/kotlin/load/kotlin/header/KotlinClassHeader.kt +++ b/core/deserialization.common.jvm/src/org/jetbrains/kotlin/load/kotlin/header/KotlinClassHeader.kt @@ -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 } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/KotlinPsiChecker.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/KotlinPsiChecker.kt index 593008c7296..830bbabfbeb 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/KotlinPsiChecker.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/KotlinPsiChecker.kt @@ -192,7 +192,7 @@ private class ElementAnnotator( val factory = diagnostic.factory // hack till the root cause #KT-21246 is fixed - if (isIrCompileClassDiagnosticForModulesWithEnabledIR(diagnostic)) return + if (isUnstableAbiClassDiagnosticForModulesWithEnabledUnstableAbi(diagnostic)) return assert(diagnostics.all { it.psiElement == element && it.factory == factory }) @@ -272,16 +272,18 @@ private class ElementAnnotator( data.processDiagnostics(holder, diagnostics, fixesMap) } - private fun isIrCompileClassDiagnosticForModulesWithEnabledIR(diagnostic: Diagnostic): Boolean { - if (diagnostic.factory != Errors.IR_COMPILED_CLASS) return false + private fun isUnstableAbiClassDiagnosticForModulesWithEnabledUnstableAbi(diagnostic: Diagnostic): Boolean { + val setting = when (diagnostic.factory) { + Errors.IR_COMPILED_CLASS -> K2JVMCompilerArguments::useIR + Errors.FIR_COMPILED_CLASS -> K2JVMCompilerArguments::useFir + else -> return false + } val module = element.module ?: return false val moduleFacetSettings = KotlinFacetSettingsProvider.getInstance(element.project)?.getSettings(module) ?: return false - return moduleFacetSettings.isCompilerSettingPresent(K2JVMCompilerArguments::useIR) - || moduleFacetSettings.isCompilerSettingPresent(K2JVMCompilerArguments::allowJvmIrDependencies) + return moduleFacetSettings.isCompilerSettingPresent(setting) } companion object { val LOG = Logger.getInstance(ElementAnnotator::class.java) } } - diff --git a/idea/jvm-debugger/jvm-debugger-evaluation/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluatorBuilder.kt b/idea/jvm-debugger/jvm-debugger-evaluation/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluatorBuilder.kt index 27e68cf27c1..921e915e31d 100644 --- a/idea/jvm-debugger/jvm-debugger-evaluation/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluatorBuilder.kt +++ b/idea/jvm-debugger/jvm-debugger-evaluation/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluatorBuilder.kt @@ -22,7 +22,6 @@ import com.intellij.debugger.engine.evaluation.EvaluateException import com.intellij.debugger.engine.evaluation.EvaluateExceptionUtil import com.intellij.debugger.engine.evaluation.EvaluationContextImpl import com.intellij.debugger.engine.evaluation.expression.* -import com.intellij.lang.java.JavaLanguage import com.intellij.openapi.diagnostic.Attachment import com.intellij.openapi.diagnostic.Logger import com.intellij.openapi.progress.ProcessCanceledException @@ -32,7 +31,6 @@ import com.intellij.testFramework.runInEdtAndWait import com.sun.jdi.* import com.sun.jdi.Value import org.jetbrains.eval4j.* -import org.jetbrains.eval4j.Value as Eval4JValue import org.jetbrains.eval4j.jdi.JDIEval import org.jetbrains.eval4j.jdi.asJdiValue import org.jetbrains.eval4j.jdi.asValue @@ -47,28 +45,32 @@ import org.jetbrains.kotlin.idea.KotlinLanguage import org.jetbrains.kotlin.idea.core.util.attachmentByPsiFile import org.jetbrains.kotlin.idea.core.util.mergeAttachments import org.jetbrains.kotlin.idea.core.util.runInReadActionWithWriteActionPriorityWithPCE -import org.jetbrains.kotlin.idea.debugger.* +import org.jetbrains.kotlin.idea.debugger.DebuggerUtils +import org.jetbrains.kotlin.idea.debugger.evaluate.EvaluationStatus.EvaluationContextLanguage import org.jetbrains.kotlin.idea.debugger.evaluate.KotlinDebuggerCaches.Companion.compileCodeFragmentCacheAware import org.jetbrains.kotlin.idea.debugger.evaluate.classLoading.GENERATED_CLASS_NAME import org.jetbrains.kotlin.idea.debugger.evaluate.classLoading.GENERATED_FUNCTION_NAME import org.jetbrains.kotlin.idea.debugger.evaluate.compilation.* +import org.jetbrains.kotlin.idea.debugger.evaluate.compilingEvaluator.ClassLoadingResult import org.jetbrains.kotlin.idea.debugger.evaluate.compilingEvaluator.loadClassesSafely import org.jetbrains.kotlin.idea.debugger.evaluate.variables.EvaluatorValueConverter import org.jetbrains.kotlin.idea.debugger.evaluate.variables.VariableFinder +import org.jetbrains.kotlin.idea.debugger.safeLocation +import org.jetbrains.kotlin.idea.debugger.safeMethod +import org.jetbrains.kotlin.idea.debugger.safeVisibleVariableByName +import org.jetbrains.kotlin.idea.resolve.ResolutionFacade import org.jetbrains.kotlin.idea.util.application.executeWriteCommand import org.jetbrains.kotlin.idea.util.application.runReadAction +import org.jetbrains.kotlin.platform.jvm.JvmPlatforms import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.resolve.AnalyzingUtils import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.isInlineClassType import org.jetbrains.kotlin.resolve.jvm.AsmTypes -import org.jetbrains.org.objectweb.asm.* +import org.jetbrains.org.objectweb.asm.ClassReader import org.jetbrains.org.objectweb.asm.tree.ClassNode -import org.jetbrains.kotlin.idea.debugger.evaluate.EvaluationStatus.EvaluationContextLanguage -import org.jetbrains.kotlin.idea.debugger.evaluate.compilingEvaluator.ClassLoadingResult -import org.jetbrains.kotlin.idea.resolve.ResolutionFacade -import org.jetbrains.kotlin.platform.jvm.JvmPlatforms import java.util.* +import org.jetbrains.eval4j.Value as Eval4JValue internal val LOG = Logger.getInstance(KotlinEvaluator::class.java) @@ -446,7 +448,10 @@ class KotlinEvaluator(val codeFragment: KtCodeFragment, private val sourcePositi companion object { private val IGNORED_DIAGNOSTICS: Set> = Errors.INVISIBLE_REFERENCE_DIAGNOSTICS + - setOf(Errors.EXPERIMENTAL_API_USAGE_ERROR, Errors.MISSING_DEPENDENCY_SUPERCLASS, Errors.IR_COMPILED_CLASS) + setOf( + Errors.EXPERIMENTAL_API_USAGE_ERROR, Errors.MISSING_DEPENDENCY_SUPERCLASS, Errors.IR_COMPILED_CLASS, + Errors.FIR_COMPILED_CLASS + ) private val DEFAULT_METHOD_MARKERS = listOf(AsmTypes.OBJECT_TYPE, AsmTypes.DEFAULT_CONSTRUCTOR_MARKER) diff --git a/libraries/stdlib/jvm/runtime/kotlin/Metadata.kt b/libraries/stdlib/jvm/runtime/kotlin/Metadata.kt index c39338e5612..ad9c1cb49bd 100644 --- a/libraries/stdlib/jvm/runtime/kotlin/Metadata.kt +++ b/libraries/stdlib/jvm/runtime/kotlin/Metadata.kt @@ -66,11 +66,12 @@ public annotation class Metadata( * * 0 - this is a multi-file class facade or part, compiled with `-Xmultifile-parts-inherit`. * * 1 - this class file is compiled by a pre-release version of Kotlin and is not visible to release versions. * * 2 - this class file is a compiled Kotlin script source file (.kts). - * * 3 - the metadata of this class file is not supposed to be read by the compiler, whose major.minor version is less than - * the major.minor version of this metadata ([metadataVersion]). - * * 4 - this class file is compiled with the new Kotlin compiler backend introduced in Kotlin 1.4. - * * 5 - if the class file is compiled with the new Kotlin compiler backend, the metadata has been verified by the author and - * no metadata incompatibility diagnostic should be reported at the call site. + * * 3 - "strict metadata version semantics". The metadata of this class file is not supposed to be read by the compiler, + * whose major.minor version is less than the major.minor version of this metadata ([metadataVersion]). + * * 4 - this class file is compiled with the new Kotlin compiler backend (JVM IR) introduced in Kotlin 1.4. + * * 5 - this class file has stable metadata and ABI. This is used only for class files compiled with JVM IR (see flag #4) or FIR (#6), + * and prevents metadata incompatibility diagnostics from being reported where the class is used. + * * 6 - this class file is compiled with the new Kotlin compiler frontend (FIR). */ @SinceKotlin("1.1") @get:JvmName("xi")