FIR serializer: distinguish typealias classifier

This commit is contained in:
Jinseong Jeon
2020-09-29 15:12:02 -07:00
committed by Mikhail Glukhikh
parent b4ac2f5b55
commit d09ccdbe3c
@@ -650,17 +650,16 @@ class FirElementSerializer private constructor(
private fun fillFromPossiblyInnerType(builder: ProtoBuf.Type.Builder, type: ConeClassLikeType) { private fun fillFromPossiblyInnerType(builder: ProtoBuf.Type.Builder, type: ConeClassLikeType) {
val classifierSymbol = type.lookupTag.toSymbol(session) val classifierSymbol = type.lookupTag.toSymbol(session)
when { if (classifierSymbol != null) {
classifierSymbol != null -> { val classifier = classifierSymbol.fir
val classifier = classifierSymbol.fir val classifierId = getClassifierId(classifier)
val classifierId = getClassifierId(classifier) if (classifier is FirTypeAlias) {
builder.typeAliasName = classifierId
} else {
builder.className = classifierId builder.className = classifierId
} }
// Special case: `Continuation` can be added via [transformSuspendFunctionToRuntimeFunctionType] } else {
type.lookupTag.classId == CONTINUATION_INTERFACE_CLASS_ID -> { builder.className = getClassifierId(type.lookupTag.classId)
builder.className = stringTable.getQualifiedClassNameIndex(type.lookupTag.classId.asString(), isLocal = false)
}
else -> error("Can't lookup $type")
} }
for (projection in type.typeArguments) { for (projection in type.typeArguments) {
@@ -839,6 +838,9 @@ class FirElementSerializer private constructor(
private fun getClassifierId(declaration: FirClassLikeDeclaration<*>): Int = private fun getClassifierId(declaration: FirClassLikeDeclaration<*>): Int =
stringTable.getFqNameIndex(declaration) stringTable.getFqNameIndex(declaration)
private fun getClassifierId(classId: ClassId): Int =
stringTable.getQualifiedClassNameIndex(classId)
private fun getSimpleNameIndex(name: Name): Int = private fun getSimpleNameIndex(name: Name): Int =
stringTable.getStringIndex(name.asString()) stringTable.getStringIndex(name.asString())