Provide more accurate clash check in JsDeclarationTable

This commit is contained in:
Mikhail Glukhikh
2020-06-16 15:33:19 +03:00
parent aaacbaaaec
commit 6f957c7b31
@@ -8,8 +8,8 @@ package org.jetbrains.kotlin.ir.backend.js.lower.serialization.ir
import org.jetbrains.kotlin.backend.common.serialization.GlobalDeclarationTable
import org.jetbrains.kotlin.backend.common.serialization.IdSignatureClashTracker
import org.jetbrains.kotlin.backend.common.serialization.signature.IdSignatureSerializer
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
import org.jetbrains.kotlin.ir.declarations.IrDeclaration
import org.jetbrains.kotlin.ir.declarations.IrProperty
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
import org.jetbrains.kotlin.ir.declarations.IrTypeParameter
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
@@ -24,19 +24,15 @@ class JsUniqIdClashTracker : IdSignatureClashTracker {
if (signature in committedIdSignatures) {
val clashedDeclaration = committedIdSignatures[signature]!!
if (declaration !is IrTypeParameter &&
(declaration.parent !is IrSimpleFunction || declaration.parent === clashedDeclaration.parent)
) {
val parent = declaration.parent
val clashedParent = clashedDeclaration.parent
if (declaration is IrTypeParameter && parent is IrSimpleFunction && parent.parent is IrProperty && parent !== clashedParent) {
// Check whether they are type parameters of the same extension property but different accessors
require(clashedParent is IrSimpleFunction)
require(clashedParent.correspondingPropertySymbol === parent.correspondingPropertySymbol)
} else {
// TODO: handle clashes properly
error("IdSignature clash: $signature; Existed declaration ${clashedDeclaration.render()} clashed with new ${declaration.render()}")
} else {
// Check whether they are type parameters of the same extension property but different accessors
val parent = declaration.parent
val clashedParent = clashedDeclaration.parent
require(parent is IrSimpleFunction)
require(clashedParent is IrSimpleFunction)
require(clashedDeclaration !== parent)
require(clashedParent.correspondingPropertySymbol === parent.correspondingPropertySymbol)
}
}