Move ignoreConstOptimizationErrors compiler key from jvm to common

#KT-56023
This commit is contained in:
Ivan Kylchik
2023-02-06 14:46:28 +01:00
committed by Space Team
parent b58de2f8da
commit 5d5582d201
11 changed files with 22 additions and 21 deletions
@@ -71,7 +71,6 @@ class JvmBuildMetaInfo : BuildMetaInfo() {
"allowNoSourceFiles",
"allowUnstableDependencies",
"enableJvmPreview",
"ignoreConstOptimizationErrors",
"suppressMissingBuiltinsError",
)
}
@@ -753,6 +753,16 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
field = value
}
@Argument(
value = "-Xignore-const-optimization-errors",
description = "Ignore all compilation exceptions while optimizing some constant expressions."
)
var ignoreConstOptimizationErrors = false
set(value) {
checkFrozen()
field = value
}
@OptIn(IDEAPluginsCompatibilityAPI::class)
open fun configureAnalysisFlags(collector: MessageCollector, languageVersion: LanguageVersion): MutableMap<AnalysisFlag<*>, Any> {
return HashMap<AnalysisFlag<*>, Any>().apply {
@@ -820,16 +820,6 @@ Also sets `-jvm-target` value equal to the selected JDK version"""
field = value
}
@Argument(
value = "-Xignore-const-optimization-errors",
description = "Ignore all compilation exceptions while optimizing some constant expressions."
)
var ignoreConstOptimizationErrors = false
set(value) {
checkFrozen()
field = value
}
@Argument(
value = "-Xno-new-java-annotation-targets",
description = "Do not generate Java 1.8+ targets for Kotlin annotation classes"
@@ -30,6 +30,7 @@ fun <A : CommonCompilerArguments> CompilerConfiguration.setupCommonArguments(
put(CommonConfigurationKeys.REPORT_OUTPUT_FILES, arguments.reportOutputFiles)
put(CommonConfigurationKeys.INCREMENTAL_COMPILATION, incrementalCompilationIsEnabled(arguments))
put(CommonConfigurationKeys.ALLOW_ANY_SCRIPTS_IN_SOURCE_ROOTS, arguments.allowAnyScriptsInSourceRoots)
put(CommonConfigurationKeys.IGNORE_CONST_OPTIMIZATION_ERRORS, arguments.ignoreConstOptimizationErrors)
val metadataVersionString = arguments.metadataVersion
if (metadataVersionString != null) {
@@ -305,7 +305,6 @@ fun CompilerConfiguration.configureAdvancedJvmOptions(arguments: K2JVMCompilerAr
put(JVMConfigurationKeys.LINK_VIA_SIGNATURES, arguments.linkViaSignatures)
put(JVMConfigurationKeys.ENABLE_DEBUG_MODE, arguments.enableDebugMode)
put(JVMConfigurationKeys.IGNORE_CONST_OPTIMIZATION_ERRORS, arguments.ignoreConstOptimizationErrors)
put(JVMConfigurationKeys.NO_NEW_JAVA_ANNOTATION_TARGETS, arguments.noNewJavaAnnotationTargets)
put(JVMConfigurationKeys.OLD_INNER_CLASSES_LOGIC, arguments.oldInnerClassesLogic)
put(JVMConfigurationKeys.ENABLE_IR_INLINER, arguments.enableIrInliner)
@@ -160,9 +160,6 @@ public class JVMConfigurationKeys {
public static final CompilerConfigurationKey<Boolean> ENABLE_DEBUG_MODE =
CompilerConfigurationKey.create("Enable debug mode");
public static final CompilerConfigurationKey<Boolean> IGNORE_CONST_OPTIMIZATION_ERRORS =
CompilerConfigurationKey.create("Ignore errors from IrConstTransformer");
public static final CompilerConfigurationKey<Boolean> NO_NEW_JAVA_ANNOTATION_TARGETS =
CompilerConfigurationKey.create("Do not generate Java 1.8+ targets for Kotlin annotation classes");
@@ -88,6 +88,9 @@ object CommonConfigurationKeys {
@JvmField
val ALLOW_ANY_SCRIPTS_IN_SOURCE_ROOTS =
CompilerConfigurationKey.create<Boolean>("Allow to compile any scripts along with regular Kotlin sources")
@JvmField
val IGNORE_CONST_OPTIMIZATION_ERRORS = CompilerConfigurationKey.create<Boolean>("Ignore errors from IrConstTransformer")
}
var CompilerConfiguration.languageVersionSettings: LanguageVersionSettings
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.backend.common.lower
import org.jetbrains.kotlin.backend.common.CommonBackendContext
import org.jetbrains.kotlin.backend.common.FileLoweringPass
import org.jetbrains.kotlin.config.CommonConfigurationKeys
import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.declarations.IrFile
import org.jetbrains.kotlin.ir.expressions.IrErrorExpression
@@ -18,7 +19,7 @@ import org.jetbrains.kotlin.ir.interpreter.checker.IrConstTransformer
class ConstEvaluationLowering(
val context: CommonBackendContext,
private val suppressErrors: Boolean = false,
private val suppressErrors: Boolean = context.configuration.getBoolean(CommonConfigurationKeys.IGNORE_CONST_OPTIMIZATION_ERRORS),
private val onWarning: (IrFile, IrElement, IrErrorExpression) -> Unit = { _, _, _ -> },
private val onError: (IrFile, IrElement, IrErrorExpression) -> Unit = { _, _, _ -> },
) : FileLoweringPass {
@@ -320,12 +320,11 @@ val constEvaluationPhase = makeIrModulePhase<JvmBackendContext>(
{
ConstEvaluationLowering(
it,
it.configuration.getBoolean(JVMConfigurationKeys.IGNORE_CONST_OPTIMIZATION_ERRORS),
{ irFile, element, warning ->
onWarning = { irFile, element, warning ->
it.ktDiagnosticReporter.at(element, irFile)
.report(JvmBackendErrors.EXCEPTION_IN_CONST_EXPRESSION, warning.description)
},
{ irFile, element, error ->
onError = { irFile, element, error ->
it.ktDiagnosticReporter.at(element, irFile)
.report(JvmBackendErrors.EXCEPTION_IN_CONST_VAL_INITIALIZER, error.description)
}
+2
View File
@@ -85,6 +85,8 @@ where advanced options include:
-Xfragment-sources=<fragment name>:<path>
Adds sources to a specific fragment of a multiplatform compilation
-Xfragments=<fragment name> Declares all known fragments of a multiplatform compilation
-Xignore-const-optimization-errors
Ignore all compilation exceptions while optimizing some constant expressions.
-Xenable-incremental-compilation
Enable incremental compilation
-Xinference-compatibility Enable compatibility changes for generic type inference algorithm
+2 -2
View File
@@ -36,8 +36,6 @@ where advanced options include:
-Xenhance-type-parameter-types-to-def-not-null
Enhance not null annotated type parameter's types to definitely not null types (@NotNull T => T & Any)
-Xfriend-paths=<path> Paths to output directories for friend modules (whose internals should be visible)
-Xignore-const-optimization-errors
Ignore all compilation exceptions while optimizing some constant expressions.
-Xmultifile-parts-inherit Compile multifile classes as a hierarchy of parts and facade
-Xmodule-path=<path> Paths where to find Java 9+ modules
-Xjava-package-prefix Package prefix for Java files
@@ -193,6 +191,8 @@ where advanced options include:
-Xfragment-sources=<fragment name>:<path>
Adds sources to a specific fragment of a multiplatform compilation
-Xfragments=<fragment name> Declares all known fragments of a multiplatform compilation
-Xignore-const-optimization-errors
Ignore all compilation exceptions while optimizing some constant expressions.
-Xenable-incremental-compilation
Enable incremental compilation
-Xinference-compatibility Enable compatibility changes for generic type inference algorithm