[JS IR] Take into account the declaration annotations in IC hash
So the annotation modifications invalidate the caller.
This commit is contained in:
committed by
Space Team
parent
0a35d84193
commit
d21cbfe02e
+21
-10
@@ -9,7 +9,9 @@ import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.config.languageVersionSettings
|
||||
import org.jetbrains.kotlin.ir.backend.js.transformers.irToJs.CrossModuleReferences
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.declarations.IrAnnotationContainer
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFunction
|
||||
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
|
||||
import org.jetbrains.kotlin.ir.declarations.IrTypeParametersContainer
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||
import org.jetbrains.kotlin.ir.util.DumpIrTreeVisitor
|
||||
@@ -45,6 +47,18 @@ private class HashCalculatorForIC {
|
||||
update(data.toByteArray())
|
||||
}
|
||||
|
||||
fun update(irElement: IrElement) {
|
||||
irElement.accept(
|
||||
visitor = DumpIrTreeVisitor(
|
||||
out = object : Appendable {
|
||||
override fun append(csq: CharSequence) = this.apply { update(csq.toString().toByteArray()) }
|
||||
override fun append(csq: CharSequence, start: Int, end: Int) = append(csq.subSequence(start, end))
|
||||
override fun append(c: Char) = append(c.toString())
|
||||
}
|
||||
), data = ""
|
||||
)
|
||||
}
|
||||
|
||||
inline fun <T> updateForEach(collection: Collection<T>, f: (T) -> Unit) {
|
||||
update(collection.size)
|
||||
collection.forEach { f(it) }
|
||||
@@ -90,16 +104,8 @@ internal fun CompilerConfiguration.configHashForIC() = HashCalculatorForIC().app
|
||||
update(languageVersionSettings.toString())
|
||||
}.finalize()
|
||||
|
||||
internal fun IrElement.irElementHashForIC() = HashCalculatorForIC().also {
|
||||
accept(
|
||||
visitor = DumpIrTreeVisitor(
|
||||
out = object : Appendable {
|
||||
override fun append(csq: CharSequence) = this.apply { it.update(csq.toString().toByteArray()) }
|
||||
override fun append(csq: CharSequence, start: Int, end: Int) = append(csq.subSequence(start, end))
|
||||
override fun append(c: Char) = append(c.toString())
|
||||
}
|
||||
), data = ""
|
||||
)
|
||||
internal fun IrSimpleFunction.irSimpleFunctionHashForIC() = HashCalculatorForIC().also {
|
||||
it.update(this)
|
||||
}.finalize()
|
||||
|
||||
internal fun IrSymbol.irSymbolHashForIC() = HashCalculatorForIC().also {
|
||||
@@ -118,6 +124,11 @@ internal fun IrSymbol.irSymbolHashForIC() = HashCalculatorForIC().also {
|
||||
it.update(functionParam.defaultValue?.let { 1 } ?: 0)
|
||||
}
|
||||
}
|
||||
(owner as? IrAnnotationContainer)?.let { annotationContainer ->
|
||||
it.updateForEach(annotationContainer.annotations) { annotation ->
|
||||
it.update(annotation)
|
||||
}
|
||||
}
|
||||
}.finalize()
|
||||
|
||||
internal fun String.stringHashForIC() = HashCalculatorForIC().also { it.update(this) }.finalize()
|
||||
|
||||
+2
-2
@@ -41,10 +41,10 @@ internal class IdSignatureHashCalculator {
|
||||
}
|
||||
|
||||
flatHashes[declaration] = if (declaration.isFakeOverride) {
|
||||
declaration.resolveFakeOverride()?.irElementHashForIC()
|
||||
declaration.resolveFakeOverride()?.irSimpleFunctionHashForIC()
|
||||
?: icError("can not resolve fake override for ${declaration.render()}")
|
||||
} else {
|
||||
declaration.irElementHashForIC()
|
||||
declaration.irSimpleFunctionHashForIC()
|
||||
}
|
||||
}
|
||||
// go deeper since local inline special declarations (like a reference adaptor) may appear
|
||||
|
||||
Reference in New Issue
Block a user