diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/linkage/KotlinIrLinkerInternalException.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/linkage/KotlinIrLinkerInternalException.kt new file mode 100644 index 00000000000..39948d0416d --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/linkage/KotlinIrLinkerInternalException.kt @@ -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.ir.linkage + +object KotlinIrLinkerInternalException : Exception("Kotlin IR Linker exception") \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/ExternalDependenciesGenerator.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/ExternalDependenciesGenerator.kt index 3511affde97..ff4ee5d322c 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/ExternalDependenciesGenerator.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/ExternalDependenciesGenerator.kt @@ -16,11 +16,13 @@ package org.jetbrains.kotlin.ir.util +import org.jetbrains.kotlin.analyzer.AnalysisResult import org.jetbrains.kotlin.descriptors.ModuleDescriptor import org.jetbrains.kotlin.ir.declarations.IrDeclaration import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns import org.jetbrains.kotlin.ir.linkage.IrDeserializer import org.jetbrains.kotlin.ir.linkage.IrProvider +import org.jetbrains.kotlin.ir.linkage.KotlinIrLinkerInternalException import org.jetbrains.kotlin.ir.symbols.IrSymbol import org.jetbrains.kotlin.utils.addToStdlib.firstNotNullResult @@ -38,18 +40,22 @@ class ExternalDependenciesGenerator( */ var unbound = setOf() lateinit var prevUnbound: Set - do { - prevUnbound = unbound - unbound = symbolTable.allUnbound + try { + do { + prevUnbound = unbound + unbound = symbolTable.allUnbound - for (symbol in unbound) { - // Symbol could get bound as a side effect of deserializing other symbols. - if (!symbol.isBound) { - irProviders.getDeclaration(symbol) + for (symbol in unbound) { + // Symbol could get bound as a side effect of deserializing other symbols. + if (!symbol.isBound) { + irProviders.getDeclaration(symbol) + } } - } - // We wait for the unbound to stabilize on fake overrides. - } while (unbound != prevUnbound) + // We wait for the unbound to stabilize on fake overrides. + } while (unbound != prevUnbound) + } catch (ex: KotlinIrLinkerInternalException) { + throw AnalysisResult.CompilationErrorException() + } } }