[klib] Serialized mangled names of declarations along with signatures
^KT-59486 Fixed
This commit is contained in:
committed by
Space Team
parent
10aa5fc7ef
commit
6142d75bb4
+7
-16
@@ -46,14 +46,9 @@ internal class IdSignatureSerialization(private val library: KotlinLibraryHeader
|
||||
out.writeInt32NoTag(IdSignatureProtoType.COMMON_SIGNATURE.id)
|
||||
out.writeStringNoTag(signature.packageFqName)
|
||||
out.writeStringNoTag(signature.declarationFqName)
|
||||
val id = signature.id
|
||||
if (id != null) {
|
||||
out.writeBoolNoTag(true)
|
||||
out.writeFixed64NoTag(id)
|
||||
} else {
|
||||
out.writeBoolNoTag(false)
|
||||
}
|
||||
out.ifNotNull(signature.id, out::writeFixed64NoTag)
|
||||
out.writeInt64NoTag(signature.mask)
|
||||
out.ifNotNull(signature.description, out::writeStringNoTag)
|
||||
}
|
||||
is IdSignature.CompositeSignature -> {
|
||||
out.writeInt32NoTag(IdSignatureProtoType.COMPOSITE_SIGNATURE.id)
|
||||
@@ -82,18 +77,15 @@ internal class IdSignatureSerialization(private val library: KotlinLibraryHeader
|
||||
IdSignatureProtoType.COMMON_SIGNATURE.id -> {
|
||||
val packageFqName = input.readString()
|
||||
val declarationFqName = input.readString()
|
||||
val id = if (input.readBool()) {
|
||||
input.readFixed64()
|
||||
} else {
|
||||
null
|
||||
}
|
||||
val id = input.ifTrue(input::readFixed64)
|
||||
val mask = input.readInt64()
|
||||
val description = input.ifTrue(input::readString)
|
||||
return IdSignature.CommonSignature(
|
||||
packageFqName = packageFqName,
|
||||
declarationFqName = declarationFqName,
|
||||
id = id,
|
||||
mask = mask,
|
||||
description = null, // TODO(KT-59486): Deserialize mangled name and save it here
|
||||
description = description,
|
||||
)
|
||||
}
|
||||
IdSignatureProtoType.COMPOSITE_SIGNATURE.id -> {
|
||||
@@ -123,10 +115,9 @@ internal class IdSignatureSerialization(private val library: KotlinLibraryHeader
|
||||
IdSignatureProtoType.COMMON_SIGNATURE.id -> {
|
||||
input.readString()
|
||||
input.readString()
|
||||
if (input.readBool()) {
|
||||
input.readFixed64()
|
||||
}
|
||||
input.ifTrue(input::readFixed64)
|
||||
input.readInt64()
|
||||
input.ifTrue(input::readString)
|
||||
}
|
||||
IdSignatureProtoType.COMPOSITE_SIGNATURE.id -> {
|
||||
skipIdSignature(input)
|
||||
|
||||
+9
-1
@@ -14,6 +14,7 @@ import org.jetbrains.kotlin.ir.backend.js.lower.StaticMembersLowering
|
||||
import org.jetbrains.kotlin.ir.backend.js.lower.isBuiltInClass
|
||||
import org.jetbrains.kotlin.ir.backend.js.utils.*
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.util.IdSignatureRenderer
|
||||
import org.jetbrains.kotlin.ir.util.isInterface
|
||||
import org.jetbrains.kotlin.ir.util.render
|
||||
import org.jetbrains.kotlin.js.backend.JsToStringGenerationVisitor
|
||||
@@ -418,7 +419,14 @@ class IrModuleToJsTransformer(
|
||||
}
|
||||
|
||||
private fun Set<IrDeclaration>.computeTag(declaration: IrDeclaration): String? {
|
||||
val tag = (backendContext.irFactory as IdSignatureRetriever).declarationSignature(declaration)?.render()
|
||||
// Use LEGACY here because the declaration may come from an old klib, in which its `IdSignature.CommonSignature`
|
||||
// doesn't have `description`, but only `id`. Hence, we always render the signature with `id` instead of `description`,
|
||||
// because otherwise there may be a mismatch when we're computing the tag first for the IrDeclaration deserialized from klib,
|
||||
// and then for the same declaration but constructed from a descriptor.
|
||||
//
|
||||
// The former won't have `description` in its `IdSignature`, the latter will have it,
|
||||
// which will result in different renders unless we use the LEGACY renderer.
|
||||
val tag = (backendContext.irFactory as IdSignatureRetriever).declarationSignature(declaration)?.render(IdSignatureRenderer.LEGACY)
|
||||
|
||||
if (tag == null && !contains(declaration)) {
|
||||
error("signature for ${declaration.render()} not found")
|
||||
|
||||
Reference in New Issue
Block a user