[JS] Remove error-tolerance-related stuff
^KT-67327
diff --git a/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt b/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt
index 096e9f3..62adc60 100644
--- a/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt
+++ b/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt
@@ -819,13 +819,6 @@
configuration.putIfNotNull(CommonConfigurationKeys.LOOKUP_TRACKER, services[LookupTracker::class.java])
configuration.putIfNotNull(CommonConfigurationKeys.EXPECT_ACTUAL_TRACKER, services[ExpectActualTracker::class.java])
- val errorTolerancePolicy = arguments.errorTolerancePolicy?.let { ErrorTolerancePolicy.resolvePolicy(it) }
- configuration.putIfNotNull(JSConfigurationKeys.ERROR_TOLERANCE_POLICY, errorTolerancePolicy)
-
- if (errorTolerancePolicy?.allowErrors == true) {
- configuration.put(JSConfigurationKeys.DEVELOPER_MODE, true)
- }
-
val sourceMapEmbedContentString = arguments.sourceMapEmbedSources
var sourceMapContentEmbedding: SourceMapSourceEmbedding? = if (sourceMapEmbedContentString != null)
sourceMapContentEmbeddingMap[sourceMapEmbedContentString]
diff --git a/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/klib/irForKlib.kt b/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/klib/irForKlib.kt
index b877196..3af8448 100644
--- a/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/klib/irForKlib.kt
+++ b/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/klib/irForKlib.kt
@@ -37,7 +37,6 @@
import org.jetbrains.kotlin.ir.linkage.partial.partialLinkageConfig
import org.jetbrains.kotlin.ir.util.SymbolTable
import org.jetbrains.kotlin.ir.visitors.acceptVoid
-import org.jetbrains.kotlin.js.config.ErrorTolerancePolicy
import org.jetbrains.kotlin.js.config.JSConfigurationKeys
import org.jetbrains.kotlin.library.KotlinLibrary
import org.jetbrains.kotlin.psi.KtFile
@@ -59,12 +58,11 @@
val performanceManager = configuration[CLIConfigurationKeys.PERF_MANAGER]
performanceManager?.notifyIRTranslationStarted()
- val errorPolicy = configuration.get(JSConfigurationKeys.ERROR_TOLERANCE_POLICY) ?: ErrorTolerancePolicy.DEFAULT
val messageCollector = configuration.messageCollector
val symbolTable = SymbolTable(IdSignatureDescriptor(JsManglerDesc), irFactory)
val psi2Ir = Psi2IrTranslator(
configuration.languageVersionSettings,
- Psi2IrConfiguration(errorPolicy.allowErrors, configuration.partialLinkageConfig.isEnabled),
+ Psi2IrConfiguration(ignoreErrors = false, configuration.partialLinkageConfig.isEnabled),
messageCollector::checkNoUnboundSymbols
)
val psi2IrContext = psi2Ir.createGeneratorContext(analysisResult.moduleDescriptor, analysisResult.bindingContext, symbolTable)
@@ -86,12 +84,12 @@
psi2IrContext.symbolTable,
partialLinkageSupport = createPartialLinkageSupportForLinker(
partialLinkageConfig = configuration.partialLinkageConfig,
- allowErrorTypes = errorPolicy.allowErrors,
+ allowErrorTypes = false,
builtIns = psi2IrContext.irBuiltIns,
messageCollector = messageCollector
),
feContext,
- ICData(icData.map { it.irData!! }, errorPolicy.allowErrors),
+ ICData(icData.map { it.irData!! }, containsErrorCode = false),
stubGenerator = stubGenerator
)
diff --git a/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/klib/jsCompilerPipeline.kt b/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/klib/jsCompilerPipeline.kt
index 6dce768..a9215d7 100644
--- a/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/klib/jsCompilerPipeline.kt
+++ b/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/klib/jsCompilerPipeline.kt
@@ -266,6 +266,8 @@
)
val icData = moduleStructure.compilerConfiguration.incrementalDataProvider?.getSerializedData(fir2KlibMetadataSerializer.sourceFiles)
+ val containsErrorCode = messageCollector.hasErrors() || diagnosticsReporter.hasErrors
+ require(!containsErrorCode)
serializeModuleIntoKlib(
moduleStructure.compilerConfiguration[CommonConfigurationKeys.MODULE_NAME]!!,
moduleStructure.compilerConfiguration,
@@ -277,7 +279,7 @@
cleanFiles = icData ?: emptyList(),
nopack = nopack,
perFile = false,
- containsErrorCode = messageCollector.hasErrors() || diagnosticsReporter.hasErrors,
+ containsErrorCode = containsErrorCode,
abiVersion = KotlinAbiVersion.CURRENT, // TODO get from test file data
jsOutputName = jsOutputName,
builtInsPlatform = if (useWasmPlatform) BuiltInsPlatform.WASM else BuiltInsPlatform.JS,
diff --git a/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/klib/prepareAnalyzedSourceModule.kt b/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/klib/prepareAnalyzedSourceModule.kt
index 9f0061c..1ea2351 100644
--- a/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/klib/prepareAnalyzedSourceModule.kt
+++ b/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/klib/prepareAnalyzedSourceModule.kt
@@ -10,8 +10,6 @@
import org.jetbrains.kotlin.cli.js.klib.TopDownAnalyzerFacadeForJSIR
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.js.analyze.AbstractTopDownAnalyzerFacadeForWeb
-import org.jetbrains.kotlin.js.config.ErrorTolerancePolicy
-import org.jetbrains.kotlin.js.config.JSConfigurationKeys
import org.jetbrains.kotlin.psi.KtFile
fun prepareAnalyzedSourceModule(
@@ -21,12 +19,11 @@
dependencies: List<String>,
friendDependencies: List<String>,
analyzer: AbstractAnalyzerWithCompilerReport,
- errorPolicy: ErrorTolerancePolicy = configuration.get(JSConfigurationKeys.ERROR_TOLERANCE_POLICY) ?: ErrorTolerancePolicy.DEFAULT,
analyzerFacade: AbstractTopDownAnalyzerFacadeForWeb = TopDownAnalyzerFacadeForJSIR,
): ModulesStructure {
val mainModule = MainModule.SourceFiles(files)
val sourceModule = ModulesStructure(project, mainModule, configuration, dependencies, friendDependencies)
return sourceModule.apply {
- runAnalysis(errorPolicy, analyzer, analyzerFacade)
+ runAnalysis(analyzer, analyzerFacade)
}
}
\ No newline at end of file
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIrBackendContext.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIrBackendContext.kt
index 65c57a2..c43fa6d 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIrBackendContext.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIrBackendContext.kt
@@ -42,7 +42,6 @@
import org.jetbrains.kotlin.ir.util.*
import org.jetbrains.kotlin.js.backend.ast.JsExpressionStatement
import org.jetbrains.kotlin.js.backend.ast.JsFunction
-import org.jetbrains.kotlin.js.config.ErrorTolerancePolicy
import org.jetbrains.kotlin.js.config.JSConfigurationKeys
import org.jetbrains.kotlin.js.config.RuntimeDiagnostic
import org.jetbrains.kotlin.name.FqName
@@ -104,7 +103,6 @@
call.symbol == intrinsics.jsUnboxIntrinsic
val devMode = configuration[JSConfigurationKeys.DEVELOPER_MODE] ?: false
- val errorPolicy = configuration[JSConfigurationKeys.ERROR_TOLERANCE_POLICY] ?: ErrorTolerancePolicy.DEFAULT
override val es6mode = configuration[JSConfigurationKeys.USE_ES6_CLASSES] ?: false
val platformArgumentsProviderJsExpression = configuration[JSConfigurationKeys.DEFINE_PLATFORM_MAIN_FUNCTION_ARGUMENTS]
@@ -311,10 +309,6 @@
}
// classes forced to be loaded
-
- val errorCodeSymbol: IrSimpleFunctionSymbol? =
- if (errorPolicy.allowErrors) symbolTable.descriptorExtension.referenceSimpleFunction(getJsInternalFunction("errorCode")) else null
-
val throwableClass = getIrClass(JsIrBackendContext.KOTLIN_PACKAGE_FQN.child(Name.identifier("Throwable")))
val primitiveCompanionObjects = primitivesWithImplicitCompanionObject().associateWith {
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/ic/HashCalculatorForIC.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/ic/HashCalculatorForIC.kt
index 58b5cf8..bba0497 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/ic/HashCalculatorForIC.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/ic/HashCalculatorForIC.kt
@@ -11,8 +11,8 @@
import org.jetbrains.kotlin.config.KotlinCompilerVersion
import org.jetbrains.kotlin.config.languageVersionSettings
import org.jetbrains.kotlin.descriptors.Modality
-import org.jetbrains.kotlin.ir.backend.js.transformers.irToJs.CrossModuleReferences
import org.jetbrains.kotlin.ir.IrElement
+import org.jetbrains.kotlin.ir.backend.js.transformers.irToJs.CrossModuleReferences
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.linkage.partial.PartialLinkageConfig
import org.jetbrains.kotlin.ir.symbols.IrSymbol
@@ -174,7 +174,6 @@
JSConfigurationKeys.SOURCE_MAP_EMBED_SOURCES,
JSConfigurationKeys.SOURCEMAP_NAMES_POLICY,
JSConfigurationKeys.MODULE_KIND,
- JSConfigurationKeys.ERROR_TOLERANCE_POLICY
)
hashCalculator.updateConfigKeys(config, enumKeys) { value: Enum<*> ->
hashCalculator.update(value.ordinal)
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/ic/JsIrLinkerLoader.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/ic/JsIrLinkerLoader.kt
index 9a967a8..b3b80d0 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/ic/JsIrLinkerLoader.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/ic/JsIrLinkerLoader.kt
@@ -31,8 +31,6 @@
import org.jetbrains.kotlin.ir.util.ExternalDependenciesGenerator
import org.jetbrains.kotlin.ir.util.IdSignature
import org.jetbrains.kotlin.ir.util.SymbolTable
-import org.jetbrains.kotlin.js.config.ErrorTolerancePolicy
-import org.jetbrains.kotlin.js.config.JSConfigurationKeys
import org.jetbrains.kotlin.library.KotlinLibrary
import org.jetbrains.kotlin.library.uniqueName
import org.jetbrains.kotlin.library.unresolvedDependencies
@@ -134,7 +132,6 @@
val symbolTable = SymbolTable(signaturer, irFactory)
val moduleDescriptor = loadedModules.keys.last()
val typeTranslator = TypeTranslatorImpl(symbolTable, compilerConfiguration.languageVersionSettings, moduleDescriptor)
- val errorPolicy = compilerConfiguration[JSConfigurationKeys.ERROR_TOLERANCE_POLICY] ?: ErrorTolerancePolicy.DEFAULT
val irBuiltIns = IrBuiltInsOverDescriptors(moduleDescriptor.builtIns, typeTranslator, symbolTable)
val messageCollector = compilerConfiguration.messageCollector
val linker = JsIrLinker(
@@ -144,7 +141,7 @@
symbolTable = symbolTable,
partialLinkageSupport = createPartialLinkageSupportForLinker(
partialLinkageConfig = compilerConfiguration.partialLinkageConfig,
- allowErrorTypes = errorPolicy.allowErrors,
+ allowErrorTypes = false,
builtIns = irBuiltIns,
messageCollector = messageCollector
),
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/JsErrorExpressionLowering.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/JsErrorExpressionLowering.kt
index 62507f9..afff4af 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/JsErrorExpressionLowering.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/JsErrorExpressionLowering.kt
@@ -7,58 +7,52 @@
import org.jetbrains.kotlin.backend.common.lower.ErrorDeclarationLowering
import org.jetbrains.kotlin.backend.common.lower.ErrorExpressionLowering
-import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.backend.js.JsIrBackendContext
-import org.jetbrains.kotlin.ir.builders.declarations.buildFun
import org.jetbrains.kotlin.ir.declarations.IrDeclaration
import org.jetbrains.kotlin.ir.declarations.IrErrorDeclaration
-import org.jetbrains.kotlin.ir.declarations.createBlockBody
-import org.jetbrains.kotlin.ir.expressions.IrErrorExpression
import org.jetbrains.kotlin.ir.expressions.IrExpression
-import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl
-import org.jetbrains.kotlin.ir.expressions.impl.IrConstImpl
-import org.jetbrains.kotlin.name.Name
class JsErrorDeclarationLowering(context: JsIrBackendContext) : ErrorDeclarationLowering() {
private val nothingType = context.irBuiltIns.nothingType
private val stringType = context.irBuiltIns.stringType
- private val errorSymbol = context.errorCodeSymbol
+ private val errorSymbol = null//context.errorCodeSymbol
private val irFactory = context.irFactory
override fun transformErrorDeclaration(declaration: IrErrorDeclaration): IrDeclaration {
- require(errorSymbol != null) { "Should be non-null if errors are allowed" }
- return irFactory.buildFun {
- updateFrom(declaration)
- returnType = nothingType
- name = Name.identifier("\$errorDeclaration")
- }.also {
- it.parent = declaration.parent
- it.body = irFactory.createBlockBody(it.startOffset, it.endOffset) {
- statements += IrCallImpl(startOffset, endOffset, nothingType, errorSymbol, 0, 1, null, null).apply {
- putValueArgument(0, IrConstImpl.string(startOffset, endOffset, stringType, "ERROR DECLARATION"))
- }
- }
- }
+ error("No IrErrorDeclarations are allowed")
+// return irFactory.buildFun {
+// updateFrom(declaration)
+// returnType = nothingType
+// name = Name.identifier("\$errorDeclaration")
+// }.also {
+// it.parent = declaration.parent
+// it.body = irFactory.createBlockBody(it.startOffset, it.endOffset) {
+// statements += IrCallImpl(startOffset, endOffset, nothingType, errorSymbol, 0, 1, null, null).apply {
+// putValueArgument(0, IrConstImpl.string(startOffset, endOffset, stringType, "ERROR DECLARATION"))
+// }
+// }
+// }
}
}
class JsErrorExpressionLowering(context: JsIrBackendContext) : ErrorExpressionLowering(context) {
private val stringType = context.irBuiltIns.nothingType
- private val errorSymbol = context.errorCodeSymbol
+ private val errorSymbol = null//context.errorCodeSymbol
override fun transformErrorExpression(expression: IrExpression, nodeKind: String): IrExpression {
- val errorExpression = expression as? IrErrorExpression
- val description = errorExpression?.let { "$nodeKind: ${it.description}" } ?: nodeKind
- return buildThrowError(expression, description)
+ error("Error expressions are not allowed")
+// val errorExpression = expression as? IrErrorExpression
+// val description = errorExpression?.let { "$nodeKind: ${it.description}" } ?: nodeKind
+// return buildThrowError(expression, description)
}
- private fun buildThrowError(element: IrExpression, description: String): IrExpression {
- require(errorSymbol != null) { "Should be non-null if errors are allowed" }
- return element.run {
- IrCallImpl(startOffset, endOffset, nothingType, errorSymbol, 0, 1, null, null).apply {
- putValueArgument(0, IrConstImpl.string(startOffset, endOffset, stringType, description))
- }
- }
- }
+// private fun buildThrowError(element: IrExpression, description: String): IrExpression {
+// require(errorSymbol != null) { "Should be non-null if errors are allowed" }
+// return element.run {
+// IrCallImpl(startOffset, endOffset, nothingType, errorSymbol, 0, 1, null, null).apply {
+// putValueArgument(0, IrConstImpl.string(startOffset, endOffset, stringType, description))
+// }
+// }
+// }
}
\ No newline at end of file
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/CallsLowering.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/CallsLowering.kt
index 20d3ff41..345d5a5 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/CallsLowering.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/CallsLowering.kt
@@ -30,7 +30,6 @@
BuiltInConstructorCalls(context),
JsonIntrinsics(context),
NativeGetterSetterTransformer(context),
- ReplaceCallsWithInvalidTypeArgumentForReifiedParameters(context),
)
override fun lower(irBody: IrBody, container: IrDeclaration) {
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/ReplaceCallsWithInvalidTypeArgumentForReifiedParameters.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/ReplaceCallsWithInvalidTypeArgumentForReifiedParameters.kt
deleted file mode 100644
index 35637c6..0000000
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/ReplaceCallsWithInvalidTypeArgumentForReifiedParameters.kt
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2010-2020 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 org.jetbrains.kotlin.ir.backend.js.lower.calls
-
-import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
-import org.jetbrains.kotlin.ir.backend.js.JsIrBackendContext
-import org.jetbrains.kotlin.ir.backend.js.ir.JsIrBuilder
-import org.jetbrains.kotlin.ir.expressions.IrExpression
-import org.jetbrains.kotlin.ir.expressions.IrFunctionAccessExpression
-import org.jetbrains.kotlin.ir.expressions.impl.IrCompositeImpl
-import org.jetbrains.kotlin.ir.expressions.impl.IrConstImpl
-import org.jetbrains.kotlin.ir.types.classOrNull
-import org.jetbrains.kotlin.ir.util.getArgumentsWithIr
-import org.jetbrains.kotlin.ir.util.render
-
-
-class ReplaceCallsWithInvalidTypeArgumentForReifiedParameters(val context: JsIrBackendContext) : CallsTransformer {
- override fun transformFunctionAccess(call: IrFunctionAccessExpression, doNotIntrinsify: Boolean): IrExpression {
- if (!context.errorPolicy.allowErrors) return call
-
- val function = call.symbol.owner
-
- for (typeParameter in function.typeParameters) {
- if (!typeParameter.isReified) continue
- val typeArgument = call.getTypeArgument(typeParameter.index)
-
- if (typeArgument?.classOrNull == null) {
- val args = call.getArgumentsWithIr().map { it.second }
-
- val callErrorCode = JsIrBuilder.buildCall(context.errorCodeSymbol!!).apply {
- putValueArgument(
- 0,
- IrConstImpl.string(
- UNDEFINED_OFFSET,
- UNDEFINED_OFFSET,
- context.irBuiltIns.stringType,
- "Invalid type argument (${typeArgument?.render()}) for reified type parameter (${typeParameter.render()})"
- )
- )
- }
-
- if (args.isEmpty()) return callErrorCode
-
- return IrCompositeImpl(-1, -1, call.type, call.origin, args + listOf(callErrorCode))
- }
- }
-
- return call
- }
-}
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrFactory.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrFactory.kt
index 5b36128..a99099c 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrFactory.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrFactory.kt
@@ -149,6 +149,7 @@
origin = IrDeclarationOrigin.DEFINED,
).declarationCreated().apply {
this.descriptor = descriptor ?: this.toIrBasedDescriptor()
+ error("Error declarations are not allowed")
}
fun createField(
diff --git a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/linkage/partial/ClassifierExplorer.kt b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/linkage/partial/ClassifierExplorer.kt
index 858ba4e..16e30ab 100644
--- a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/linkage/partial/ClassifierExplorer.kt
+++ b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/linkage/partial/ClassifierExplorer.kt
@@ -16,7 +16,10 @@
import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.declarations.lazy.IrLazyClass
-import org.jetbrains.kotlin.ir.expressions.*
+import org.jetbrains.kotlin.ir.expressions.IrClassReference
+import org.jetbrains.kotlin.ir.expressions.IrConstantObject
+import org.jetbrains.kotlin.ir.expressions.IrExpression
+import org.jetbrains.kotlin.ir.expressions.IrTypeOperatorCall
import org.jetbrains.kotlin.ir.linkage.partial.ExploredClassifier
import org.jetbrains.kotlin.ir.linkage.partial.ExploredClassifier.Unusable
import org.jetbrains.kotlin.ir.linkage.partial.ExploredClassifier.Unusable.*
@@ -35,6 +38,9 @@
private val stubGenerator: MissingDeclarationStubGenerator,
private val allowErrorTypes: Boolean
) {
+ init {
+ require(!allowErrorTypes)
+ }
private val exploredSymbols = ExploredClassifiers()
private val permittedAnnotationArrayParameterSymbols: Set<IrClassSymbol> by lazy {
diff --git a/compiler/ir/serialization.js/src/org/jetbrains/kotlin/ir/backend/js/klib.kt b/compiler/ir/serialization.js/src/org/jetbrains/kotlin/ir/backend/js/klib.kt
index 0f20744..17ee06a 100644
--- a/compiler/ir/serialization.js/src/org/jetbrains/kotlin/ir/backend/js/klib.kt
+++ b/compiler/ir/serialization.js/src/org/jetbrains/kotlin/ir/backend/js/klib.kt
@@ -42,11 +42,12 @@
import org.jetbrains.kotlin.ir.descriptors.IrDescriptorBasedFunctionFactory
import org.jetbrains.kotlin.ir.linkage.IrDeserializer
import org.jetbrains.kotlin.ir.linkage.partial.partialLinkageConfig
-import org.jetbrains.kotlin.ir.util.*
+import org.jetbrains.kotlin.ir.util.DeclarationStubGenerator
+import org.jetbrains.kotlin.ir.util.ExternalDependenciesGenerator
+import org.jetbrains.kotlin.ir.util.SymbolTable
import org.jetbrains.kotlin.ir.visitors.acceptVoid
import org.jetbrains.kotlin.js.analyze.AbstractTopDownAnalyzerFacadeForWeb
import org.jetbrains.kotlin.js.analyzer.JsAnalysisResult
-import org.jetbrains.kotlin.js.config.ErrorTolerancePolicy
import org.jetbrains.kotlin.js.config.JSConfigurationKeys
import org.jetbrains.kotlin.konan.properties.Properties
import org.jetbrains.kotlin.konan.properties.propertyList
@@ -174,7 +175,6 @@
val mainModule = depsDescriptors.mainModule
val configuration = depsDescriptors.compilerConfiguration
val allDependencies = depsDescriptors.allDependencies
- val errorPolicy = configuration.get(JSConfigurationKeys.ERROR_TOLERANCE_POLICY) ?: ErrorTolerancePolicy.DEFAULT
val messageLogger = configuration.messageCollector
val partialLinkageEnabled = configuration.partialLinkageConfig.isEnabled
@@ -184,7 +184,7 @@
when (mainModule) {
is MainModule.SourceFiles -> {
assert(filesToLoad == null)
- val psi2IrContext = preparePsi2Ir(depsDescriptors, errorPolicy, symbolTable, partialLinkageEnabled)
+ val psi2IrContext = preparePsi2Ir(depsDescriptors, symbolTable, partialLinkageEnabled)
val friendModules =
mapOf(psi2IrContext.moduleDescriptor.name.asString() to depsDescriptors.friendDependencies.map { it.uniqueName })
@@ -238,7 +238,6 @@
val mainModuleLib = sortedDependencies.last()
val typeTranslator = TypeTranslatorImpl(symbolTable, configuration.languageVersionSettings, moduleDescriptor)
val irBuiltIns = IrBuiltInsOverDescriptors(moduleDescriptor.builtIns, typeTranslator, symbolTable)
- val errorPolicy = configuration[JSConfigurationKeys.ERROR_TOLERANCE_POLICY] ?: ErrorTolerancePolicy.DEFAULT
val irLinker = JsIrLinker(
currentModule = null,
@@ -247,7 +246,7 @@
symbolTable = symbolTable,
partialLinkageSupport = createPartialLinkageSupportForLinker(
partialLinkageConfig = configuration.partialLinkageConfig,
- allowErrorTypes = errorPolicy.allowErrors,
+ allowErrorTypes = false,
builtIns = irBuiltIns,
messageCollector = messageCollector
),
@@ -302,7 +301,6 @@
val feContext = psi2IrContext.run {
JsIrLinker.JsFePluginContext(moduleDescriptor, symbolTable, typeTranslator, irBuiltIns)
}
- val errorPolicy = configuration[JSConfigurationKeys.ERROR_TOLERANCE_POLICY] ?: ErrorTolerancePolicy.DEFAULT
val irLinker = JsIrLinker(
currentModule = psi2IrContext.moduleDescriptor,
@@ -311,7 +309,7 @@
symbolTable = symbolTable,
partialLinkageSupport = createPartialLinkageSupportForLinker(
partialLinkageConfig = configuration.partialLinkageConfig,
- allowErrorTypes = errorPolicy.allowErrors,
+ allowErrorTypes = false,
builtIns = irBuiltIns,
messageCollector = messageCollector
),
@@ -361,14 +359,13 @@
private fun preparePsi2Ir(
depsDescriptors: ModulesStructure,
- errorIgnorancePolicy: ErrorTolerancePolicy,
symbolTable: SymbolTable,
partialLinkageEnabled: Boolean
): GeneratorContext {
val analysisResult = depsDescriptors.jsFrontEndResult
val psi2Ir = Psi2IrTranslator(
depsDescriptors.compilerConfiguration.languageVersionSettings,
- Psi2IrConfiguration(errorIgnorancePolicy.allowErrors, partialLinkageEnabled),
+ Psi2IrConfiguration(ignoreErrors = false, partialLinkageEnabled),
depsDescriptors.compilerConfiguration::checkNoUnboundSymbols
)
return psi2Ir.createGeneratorContext(
@@ -491,7 +488,6 @@
lateinit var jsFrontEndResult: JsFrontEndResult
fun runAnalysis(
- errorPolicy: ErrorTolerancePolicy,
analyzer: AbstractAnalyzerWithCompilerReport,
analyzerFacade: AbstractTopDownAnalyzerFacadeForWeb
) {
@@ -522,7 +518,7 @@
project,
analysisResult.bindingContext,
analysisResult.moduleDescriptor,
- errorPolicy.allowErrors,
+ allowErrorTypes = false,
)
}
if (shouldGoToNextIcRound) {
@@ -532,12 +528,10 @@
var hasErrors = false
if (analyzer.hasErrors() || analysisResult !is JsAnalysisResult) {
- if (!errorPolicy.allowErrors)
- throw CompilationErrorException()
- else hasErrors = true
+ throw CompilationErrorException()
}
- hasErrors = analyzerFacade.checkForErrors(files, analysisResult.bindingContext, errorPolicy) || hasErrors
+ hasErrors = analyzerFacade.checkForErrors(files, analysisResult.bindingContext) || hasErrors
jsFrontEndResult = JsFrontEndResult(analysisResult, hasErrors)
}
diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/JsEnvironmentConfigurationDirectives.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/JsEnvironmentConfigurationDirectives.kt
index 79adc226..6edb6b3 100644
--- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/JsEnvironmentConfigurationDirectives.kt
+++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/JsEnvironmentConfigurationDirectives.kt
@@ -6,7 +6,6 @@
package org.jetbrains.kotlin.test.directives
import org.jetbrains.kotlin.cli.common.arguments.K2JsArgumentConstants
-import org.jetbrains.kotlin.js.config.ErrorTolerancePolicy
import org.jetbrains.kotlin.js.config.RuntimeDiagnostic
import org.jetbrains.kotlin.js.config.SourceMapSourceEmbedding
import org.jetbrains.kotlin.serialization.js.ModuleKind
diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/classic/ClassicFrontend2IrConverter.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/classic/ClassicFrontend2IrConverter.kt
index 7ee83c6..e462bda 100644
--- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/classic/ClassicFrontend2IrConverter.kt
+++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/classic/ClassicFrontend2IrConverter.kt
@@ -23,8 +23,6 @@
import org.jetbrains.kotlin.ir.backend.jvm.serialization.JvmIrMangler
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl
import org.jetbrains.kotlin.ir.util.SymbolTable
-import org.jetbrains.kotlin.js.config.ErrorTolerancePolicy
-import org.jetbrains.kotlin.js.config.JSConfigurationKeys
import org.jetbrains.kotlin.test.TargetBackend
import org.jetbrains.kotlin.test.backend.ir.IrBackendInput
import org.jetbrains.kotlin.test.directives.CodegenTestDirectives
@@ -106,8 +104,7 @@
testServices.libraryProvider.getDescriptorByCompiledLibrary(it)
}
- val errorPolicy = configuration.get(JSConfigurationKeys.ERROR_TOLERANCE_POLICY) ?: ErrorTolerancePolicy.DEFAULT
- val hasErrors = TopDownAnalyzerFacadeForJSIR.checkForErrors(sourceFiles, analysisResult.bindingContext, errorPolicy)
+ val hasErrors = TopDownAnalyzerFacadeForJSIR.checkForErrors(sourceFiles, analysisResult.bindingContext)
val metadataSerializer = KlibMetadataIncrementalSerializer(
sourceFiles,
configuration,
@@ -152,9 +149,8 @@
testServices.libraryProvider.getDescriptorByCompiledLibrary(it)
}
- val errorPolicy = configuration.get(JSConfigurationKeys.ERROR_TOLERANCE_POLICY) ?: ErrorTolerancePolicy.DEFAULT
val analyzerFacade = TopDownAnalyzerFacadeForWasm.facadeFor(configuration.get(WasmConfigurationKeys.WASM_TARGET))
- val hasErrors = analyzerFacade.checkForErrors(sourceFiles, analysisResult.bindingContext, errorPolicy)
+ val hasErrors = analyzerFacade.checkForErrors(sourceFiles, analysisResult.bindingContext)
val metadataSerializer = KlibMetadataIncrementalSerializer(
sourceFiles,
configuration,
diff --git a/js/js.frontend/src/org/jetbrains/kotlin/js/analyze/TopDownAnalyzerFacadeForJS.kt b/js/js.frontend/src/org/jetbrains/kotlin/js/analyze/TopDownAnalyzerFacadeForJS.kt
index b510e4a..a5c914c 100644
--- a/js/js.frontend/src/org/jetbrains/kotlin/js/analyze/TopDownAnalyzerFacadeForJS.kt
+++ b/js/js.frontend/src/org/jetbrains/kotlin/js/analyze/TopDownAnalyzerFacadeForJS.kt
@@ -27,7 +27,6 @@
import org.jetbrains.kotlin.incremental.components.LookupTracker
import org.jetbrains.kotlin.incremental.js.IncrementalDataProvider
import org.jetbrains.kotlin.js.analyzer.JsAnalysisResult
-import org.jetbrains.kotlin.js.config.ErrorTolerancePolicy
import org.jetbrains.kotlin.js.config.JSConfigurationKeys
import org.jetbrains.kotlin.js.config.JsConfig
import org.jetbrains.kotlin.js.resolve.JsPlatformAnalyzerServices
@@ -166,31 +165,14 @@
}
}
- fun checkForErrors(allFiles: Collection<KtFile>, bindingContext: BindingContext, errorPolicy: ErrorTolerancePolicy): Boolean {
- var hasErrors = false
- try {
- AnalyzingUtils.throwExceptionOnErrors(bindingContext)
- } catch (ex: Exception) {
- if (!errorPolicy.allowSemanticErrors) {
- throw ex
- } else {
- hasErrors = true
- }
+ fun checkForErrors(allFiles: Collection<KtFile>, bindingContext: BindingContext): Boolean {
+ AnalyzingUtils.throwExceptionOnErrors(bindingContext)
+
+ for (file in allFiles) {
+ AnalyzingUtils.checkForSyntacticErrors(file)
}
- try {
- for (file in allFiles) {
- AnalyzingUtils.checkForSyntacticErrors(file)
- }
- } catch (ex: Exception) {
- if (!errorPolicy.allowSyntaxErrors) {
- throw ex
- } else {
- hasErrors = true
- }
- }
-
- return hasErrors
+ return false
}
}
diff --git a/js/js.frontend/src/org/jetbrains/kotlin/js/config/ErrorTolerancePolicy.kt b/js/js.frontend/src/org/jetbrains/kotlin/js/config/ErrorTolerancePolicy.kt
deleted file mode 100644
index 1355c0c..0000000
--- a/js/js.frontend/src/org/jetbrains/kotlin/js/config/ErrorTolerancePolicy.kt
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright 2010-2020 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 org.jetbrains.kotlin.js.config
-
-enum class ErrorTolerancePolicy {
- NONE;
-
- val allowSemanticErrors = false
- val allowSyntaxErrors = false
- val allowErrors = false
-
- companion object {
- val DEFAULT = NONE
-
- fun resolvePolicy(key: String): ErrorTolerancePolicy {
- return when (key.uppercase()) {
- "NONE" -> NONE
- else -> error("KT-65018: -Xerror-tolerance-policy is deprecated and will be removed in next compiler version. " +
- "Only `NONE` value is allowed now.")
- }
- }
- }
-}
diff --git a/js/js.frontend/src/org/jetbrains/kotlin/js/config/JSConfigurationKeys.java b/js/js.frontend/src/org/jetbrains/kotlin/js/config/JSConfigurationKeys.java
index c7d19e3..78efb10 100644
--- a/js/js.frontend/src/org/jetbrains/kotlin/js/config/JSConfigurationKeys.java
+++ b/js/js.frontend/src/org/jetbrains/kotlin/js/config/JSConfigurationKeys.java
@@ -106,9 +106,6 @@
public static final CompilerConfigurationKey<Boolean> FAKE_OVERRIDE_VALIDATOR =
CompilerConfigurationKey.create("IR fake override validator");
- public static final CompilerConfigurationKey<ErrorTolerancePolicy> ERROR_TOLERANCE_POLICY =
- CompilerConfigurationKey.create("set up policy to ignore compilation errors");
-
public static final CompilerConfigurationKey<Boolean> PROPERTY_LAZY_INITIALIZATION =
CompilerConfigurationKey.create("perform lazy initialization for properties");
diff --git a/js/js.tests/test/org/jetbrains/kotlin/benchmarks/GenerateIrRuntime.kt b/js/js.tests/test/org/jetbrains/kotlin/benchmarks/GenerateIrRuntime.kt
index 8afd096..920cba8 100644
--- a/js/js.tests/test/org/jetbrains/kotlin/benchmarks/GenerateIrRuntime.kt
+++ b/js/js.tests/test/org/jetbrains/kotlin/benchmarks/GenerateIrRuntime.kt
@@ -11,7 +11,6 @@
import com.intellij.openapi.vfs.VfsUtilCore
import com.intellij.openapi.vfs.VirtualFileManager
import com.intellij.psi.PsiManager
-import org.jetbrains.kotlin.ir.KtDiagnosticReporterWithImplicitIrBasedContext
import org.jetbrains.kotlin.analyzer.AnalysisResult
import org.jetbrains.kotlin.backend.common.linkage.issues.checkNoUnboundSymbols
import org.jetbrains.kotlin.backend.common.linkage.partial.PartialLinkageSupportForLinker
@@ -32,6 +31,7 @@
import org.jetbrains.kotlin.incremental.multiproject.EmptyModulesApiHistory
import org.jetbrains.kotlin.incremental.withJsIC
import org.jetbrains.kotlin.ir.IrBuiltIns
+import org.jetbrains.kotlin.ir.KtDiagnosticReporterWithImplicitIrBasedContext
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
import org.jetbrains.kotlin.ir.backend.js.*
import org.jetbrains.kotlin.ir.backend.js.lower.serialization.ir.JsIrLinker
@@ -45,7 +45,6 @@
import org.jetbrains.kotlin.ir.util.SymbolTable
import org.jetbrains.kotlin.ir.util.patchDeclarationParents
import org.jetbrains.kotlin.js.analyze.TopDownAnalyzerFacadeForJS
-import org.jetbrains.kotlin.js.config.ErrorTolerancePolicy
import org.jetbrains.kotlin.js.config.JSConfigurationKeys
import org.jetbrains.kotlin.library.*
import org.jetbrains.kotlin.library.impl.BuiltInsPlatform
@@ -453,7 +452,7 @@
)
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled()
- TopDownAnalyzerFacadeForJS.checkForErrors(files, analysisResult.bindingContext, ErrorTolerancePolicy.NONE)
+ TopDownAnalyzerFacadeForJS.checkForErrors(files, analysisResult.bindingContext)
return analysisResult
}
diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/facade/K2JSTranslator.kt b/js/js.translator/src/org/jetbrains/kotlin/js/facade/K2JSTranslator.kt
index e76469b..7763b66 100644
--- a/js/js.translator/src/org/jetbrains/kotlin/js/facade/K2JSTranslator.kt
+++ b/js/js.translator/src/org/jetbrains/kotlin/js/facade/K2JSTranslator.kt
@@ -28,7 +28,6 @@
import org.jetbrains.kotlin.js.backend.ast.JsName
import org.jetbrains.kotlin.js.backend.ast.JsProgramFragment
import org.jetbrains.kotlin.js.backend.ast.JsStatement
-import org.jetbrains.kotlin.js.config.ErrorTolerancePolicy
import org.jetbrains.kotlin.js.config.JSConfigurationKeys
import org.jetbrains.kotlin.js.config.JsConfig
import org.jetbrains.kotlin.js.coroutine.transformCoroutines
@@ -115,7 +114,7 @@
packageMetadata: MutableMap<FqName, ByteArray>
): TranslationResult {
val bindingTrace = analysisResult.bindingTrace
- TopDownAnalyzerFacadeForJS.checkForErrors(files, bindingTrace.bindingContext, ErrorTolerancePolicy.NONE)
+ TopDownAnalyzerFacadeForJS.checkForErrors(files, bindingTrace.bindingContext)
val moduleDescriptor = analysisResult.moduleDescriptor
val diagnostics = bindingTrace.bindingContext.diagnostics
val pathResolver = SourceFilePathResolver.create(config)
@@ -155,7 +154,7 @@
packageMetadata: MutableMap<FqName, ByteArray>
): TranslationResult {
val bindingTrace = analysisResult.bindingTrace
- TopDownAnalyzerFacadeForJS.checkForErrors(files, bindingTrace.bindingContext, ErrorTolerancePolicy.NONE)
+ TopDownAnalyzerFacadeForJS.checkForErrors(files, bindingTrace.bindingContext)
val moduleDescriptor = analysisResult.moduleDescriptor
val diagnostics = bindingTrace.bindingContext.diagnostics
val pathResolver = SourceFilePathResolver.create(config)