Provide more accurate clash check in JsDeclarationTable
This commit is contained in:
+8
-12
@@ -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.GlobalDeclarationTable
|
||||||
import org.jetbrains.kotlin.backend.common.serialization.IdSignatureClashTracker
|
import org.jetbrains.kotlin.backend.common.serialization.IdSignatureClashTracker
|
||||||
import org.jetbrains.kotlin.backend.common.serialization.signature.IdSignatureSerializer
|
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.IrDeclaration
|
||||||
|
import org.jetbrains.kotlin.ir.declarations.IrProperty
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
|
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrTypeParameter
|
import org.jetbrains.kotlin.ir.declarations.IrTypeParameter
|
||||||
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
||||||
@@ -24,19 +24,15 @@ class JsUniqIdClashTracker : IdSignatureClashTracker {
|
|||||||
|
|
||||||
if (signature in committedIdSignatures) {
|
if (signature in committedIdSignatures) {
|
||||||
val clashedDeclaration = committedIdSignatures[signature]!!
|
val clashedDeclaration = committedIdSignatures[signature]!!
|
||||||
if (declaration !is IrTypeParameter &&
|
val parent = declaration.parent
|
||||||
(declaration.parent !is IrSimpleFunction || declaration.parent === clashedDeclaration.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
|
// TODO: handle clashes properly
|
||||||
error("IdSignature clash: $signature; Existed declaration ${clashedDeclaration.render()} clashed with new ${declaration.render()}")
|
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)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user