[IR] Add the description field to CommonIdSignature
This field shall be used for storing a human-readable representation of the declaration, that would be a mangled name for now. This field is not yet serialized. Serialization will be implemented in follow-up commits. See KT-59486
This commit is contained in:
committed by
teamcity
parent
668684ca13
commit
3a30d74096
@@ -45,14 +45,26 @@ object IdSignatureValues {
|
||||
@JvmField val iterable = getPublicSignature(StandardNames.COLLECTIONS_PACKAGE_FQ_NAME, "Iterable")
|
||||
@JvmField val continuation = getPublicSignature(StandardNames.COROUTINES_PACKAGE_FQ_NAME, "Continuation")
|
||||
@JvmField val result = getPublicSignature(StandardNames.BUILT_INS_PACKAGE_FQ_NAME, "Result")
|
||||
@JvmField val sequence = IdSignature.CommonSignature("kotlin.sequences", "Sequence", null, 0)
|
||||
@JvmField val sequence = IdSignature.CommonSignature(
|
||||
packageFqName = "kotlin.sequences",
|
||||
declarationFqName = "Sequence",
|
||||
id = null,
|
||||
mask = 0,
|
||||
description = "kotlin.sequences.Sequence",
|
||||
)
|
||||
}
|
||||
|
||||
private fun IrType.isNotNullClassType(signature: IdSignature.CommonSignature) = isClassType(signature, nullable = false)
|
||||
private fun IrType.isNullableClassType(signature: IdSignature.CommonSignature) = isClassType(signature, nullable = true)
|
||||
|
||||
fun getPublicSignature(packageFqName: FqName, name: String) =
|
||||
IdSignature.CommonSignature(packageFqName.asString(), name, null, 0)
|
||||
IdSignature.CommonSignature(
|
||||
packageFqName = packageFqName.asString(),
|
||||
declarationFqName = name,
|
||||
id = null,
|
||||
mask = 0,
|
||||
description = packageFqName.child(Name.identifier(name)).asString(),
|
||||
)
|
||||
|
||||
private fun IrType.isClassType(signature: IdSignature.CommonSignature, nullable: Boolean? = null): Boolean {
|
||||
if (this !is IrSimpleType) return false
|
||||
|
||||
@@ -266,8 +266,17 @@ sealed class IdSignature {
|
||||
|
||||
/**
|
||||
* This signature corresponds to a publicly accessible Kotlin declaration.
|
||||
*
|
||||
* @property description This property does not affect linkage and is used only for showing humnan-readable error messages.
|
||||
* Note: currently, we store here the mangled name from which [id] was computed. Later we can reconsider.
|
||||
*/
|
||||
class CommonSignature(val packageFqName: String, val declarationFqName: String, val id: Long?, val mask: Long) : IdSignature() {
|
||||
class CommonSignature(
|
||||
val packageFqName: String,
|
||||
val declarationFqName: String,
|
||||
val id: Long?,
|
||||
val mask: Long,
|
||||
val description: String?,
|
||||
) : IdSignature() {
|
||||
override val isPubliclyVisible: Boolean get() = true
|
||||
|
||||
override fun packageFqName(): FqName = FqName(packageFqName)
|
||||
@@ -295,7 +304,13 @@ sealed class IdSignature {
|
||||
val adaptedMask = adaptMask(mask)
|
||||
if (nameSegments.size == 1 && mask == adaptedMask) return this
|
||||
|
||||
return CommonSignature(packageFqName, nameSegments.first(), null, adaptedMask)
|
||||
return CommonSignature(
|
||||
packageFqName = packageFqName,
|
||||
declarationFqName = nameSegments.first(),
|
||||
id = null,
|
||||
mask = adaptedMask,
|
||||
description = null
|
||||
)
|
||||
}
|
||||
|
||||
override fun isPackageSignature(): Boolean = id == null && declarationFqName.isEmpty()
|
||||
|
||||
Reference in New Issue
Block a user