Verify mangled names against descriptions of signatures computed from IR

...instead of those computed from a frontend representation
(`symbol.signature`).

This is more robust; besides, we are going to turn off building
signatures from FIR, so `symbol.signature` is going to return null soon.
This commit is contained in:
Sergej Jaskiewicz
2024-01-12 15:52:53 +01:00
committed by Space Team
parent c8f8316e9b
commit a5031edd1a
2 changed files with 5 additions and 11 deletions
@@ -12,7 +12,6 @@ class C2 : C1 {
// CHECK JVM_IR:
// Mangled name: C2#f(){}kotlin.String
// Mangled name for the signature: f(){}kotlin.String
// Public signature: /C2.f|9098388873611041001[0]
// Public signature debug description: f(){}kotlin.String
// CHECK JS_IR NATIVE:
@@ -23,7 +22,6 @@ class C2 : C1 {
// CHECK JVM_IR:
// Mangled name: C2{}p
// Mangled name for the signature: {}p
// Public signature: /C2.p|6715504260787941082[0]
// Public signature debug description: {}p
// CHECK JS_IR NATIVE:
@@ -33,7 +31,6 @@ class C2 : C1 {
/* fake */ override val p: Int
// CHECK JVM_IR:
// Mangled name: C2#<get-p>(){}kotlin.Int
// Mangled name for the signature: <get-p>(){}kotlin.Int
// Public signature: /C2.p.<get-p>|5329635969197638839[0]
// Public signature debug description: <get-p>(){}kotlin.Int
// CHECK JS_IR NATIVE:
@@ -223,13 +223,10 @@ class IrMangledNameAndSignatureDumpHandler(
val fullMangledNames = mutableListOf<ComputedMangledName>()
val signatureMangledNames = mutableListOf<ComputedMangledName>()
signatureComposer.inFile(declaration.fileOrNull?.symbol) {
addSignatureTo(
signatures,
signatureComposer.computeSignature(declaration),
ComputedBy.IR,
isPublic = true
)
val signatureComputedFromIr = signatureComposer.inFile(declaration.fileOrNull?.symbol) {
signatureComposer.computeSignature(declaration).also {
addSignatureTo(signatures, it, ComputedBy.IR, isPublic = true)
}
}
irMangler.addFullMangledNameTo(fullMangledNames, declaration)
@@ -255,7 +252,7 @@ class IrMangledNameAndSignatureDumpHandler(
// Signature mangled names computed from descriptors, IR and FIR of declarations that are not
// effectively private must be all equal to the signature description, which we already print
// (see the printSignatures() function below). If this is not the case, print them separately.
if (signatureMangledNames.any { it.value != symbol.signature?.asPublic()?.description.orEmpty() }) {
if (signatureMangledNames.any { it.value != signatureComputedFromIr.asPublic()?.description.orEmpty() }) {
printMangledNames(signatureMangledNames, prefix = "Mangled name for the signature")
}
}