IR: move CompilationErrorException to frontend.common

This commit is contained in:
Alexander Udalov
2021-02-21 13:33:13 +01:00
parent 1ae46b529f
commit 837eb739ea
5 changed files with 14 additions and 8 deletions
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.cli.common
import com.intellij.openapi.Disposable import com.intellij.openapi.Disposable
import com.intellij.openapi.util.Disposer import com.intellij.openapi.util.Disposer
import org.jetbrains.kotlin.analyzer.AnalysisResult import org.jetbrains.kotlin.analyzer.CompilationErrorException
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY
import org.jetbrains.kotlin.cli.common.ExitCode.COMPILATION_ERROR import org.jetbrains.kotlin.cli.common.ExitCode.COMPILATION_ERROR
import org.jetbrains.kotlin.cli.common.ExitCode.INTERNAL_ERROR import org.jetbrains.kotlin.cli.common.ExitCode.INTERNAL_ERROR
@@ -40,7 +40,6 @@ import org.jetbrains.kotlin.utils.KotlinPaths
import org.jetbrains.kotlin.utils.PathUtil import org.jetbrains.kotlin.utils.PathUtil
import java.io.File import java.io.File
import java.io.PrintStream import java.io.PrintStream
import java.util.*
abstract class CLICompiler<A : CommonCompilerArguments> : CLITool<A>() { abstract class CLICompiler<A : CommonCompilerArguments> : CLITool<A>() {
@@ -117,7 +116,7 @@ abstract class CLICompiler<A : CommonCompilerArguments> : CLITool<A>() {
} finally { } finally {
Disposer.dispose(rootDisposable) Disposer.dispose(rootDisposable)
} }
} catch (e: AnalysisResult.CompilationErrorException) { } catch (e: CompilationErrorException) {
return COMPILATION_ERROR return COMPILATION_ERROR
} catch (t: Throwable) { } catch (t: Throwable) {
MessageCollectorUtil.reportException(collector, t) MessageCollectorUtil.reportException(collector, t)
@@ -0,0 +1,8 @@
/*
* Copyright 2010-2021 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.analyzer
class CompilationErrorException : RuntimeException()
@@ -58,8 +58,6 @@ open class AnalysisResult protected constructor(
} }
} }
class CompilationErrorException : RuntimeException()
private class CompilationError(bindingContext: BindingContext) : AnalysisResult(bindingContext, ErrorUtils.getErrorModule()) private class CompilationError(bindingContext: BindingContext) : AnalysisResult(bindingContext, ErrorUtils.getErrorModule())
private class InternalError( private class InternalError(
@@ -16,7 +16,7 @@
package org.jetbrains.kotlin.ir.util package org.jetbrains.kotlin.ir.util
import org.jetbrains.kotlin.analyzer.AnalysisResult import org.jetbrains.kotlin.analyzer.CompilationErrorException
import org.jetbrains.kotlin.descriptors.ModuleDescriptor import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.ir.declarations.IrDeclaration import org.jetbrains.kotlin.ir.declarations.IrDeclaration
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
@@ -54,7 +54,7 @@ class ExternalDependenciesGenerator(
// We wait for the unbound to stabilize on fake overrides. // We wait for the unbound to stabilize on fake overrides.
} while (unbound != prevUnbound) } while (unbound != prevUnbound)
} catch (ex: KotlinIrLinkerInternalException) { } catch (ex: KotlinIrLinkerInternalException) {
throw AnalysisResult.CompilationErrorException() throw CompilationErrorException()
} }
} }
} }
@@ -10,6 +10,7 @@ import com.intellij.openapi.vfs.VfsUtilCore
import com.intellij.psi.PsiElement import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.analyzer.AbstractAnalyzerWithCompilerReport import org.jetbrains.kotlin.analyzer.AbstractAnalyzerWithCompilerReport
import org.jetbrains.kotlin.analyzer.AnalysisResult import org.jetbrains.kotlin.analyzer.AnalysisResult
import org.jetbrains.kotlin.analyzer.CompilationErrorException
import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension
import org.jetbrains.kotlin.backend.common.extensions.IrPluginContextImpl import org.jetbrains.kotlin.backend.common.extensions.IrPluginContextImpl
import org.jetbrains.kotlin.backend.common.lower.ExpectDeclarationRemover import org.jetbrains.kotlin.backend.common.lower.ExpectDeclarationRemover
@@ -414,7 +415,7 @@ private class ModulesStructure(
var hasErrors = false var hasErrors = false
if (analyzer.hasErrors() || analysisResult !is JsAnalysisResult) { if (analyzer.hasErrors() || analysisResult !is JsAnalysisResult) {
if (!errorPolicy.allowErrors) if (!errorPolicy.allowErrors)
throw AnalysisResult.CompilationErrorException() throw CompilationErrorException()
else hasErrors = true else hasErrors = true
} }