[Serializer] UniqId clashes handling

This commit is contained in:
Igor Chevdar
2019-06-24 16:32:18 +03:00
parent b62e9487d1
commit dff0ac8866
2 changed files with 24 additions and 5 deletions
@@ -9,6 +9,7 @@ import org.jetbrains.kotlin.backend.common.LoggingContext
import org.jetbrains.kotlin.backend.common.serialization.*
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.ir.backend.js.kotlinLibrary
import org.jetbrains.kotlin.ir.declarations.IrFile
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol
import org.jetbrains.kotlin.ir.util.SymbolTable
@@ -45,6 +46,16 @@ class JsIrLinker(
override fun readString(moduleDescriptor: ModuleDescriptor, stringIndex: Int) =
moduleDescriptor.kotlinLibrary.string(stringIndex)
override fun List<IrFile>.handleClashes(uniqIdKey: UniqIdKey): IrFile {
if (size == 1)
return this[0]
assert(size != 0)
error("UniqId clash: ${uniqIdKey.uniqId.index}. Found in the " +
"[${this.joinToString { it.packageFragmentDescriptor.containingDeclaration.userName }}]")
}
private val ModuleDescriptor.userName get() = kotlinLibrary.libraryFile.absolutePath
override fun declareForwardDeclarations() {
// since for `knownBuiltIns` such as FunctionN it is possible to have unbound symbols after deserialization
// reference them through out lazy symbol table