[KLIB] Handle linkage error
Do not crash compiler with ugly stacktrace in case of misconfiguration. Report relatively friendly diagnostic message instead
This commit is contained in:
+8
@@ -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")
|
||||
+16
-10
@@ -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<IrSymbol>()
|
||||
lateinit var prevUnbound: Set<IrSymbol>
|
||||
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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user