[FIR] Properly deserialize annotations on typealias and underlying type

This commit is contained in:
Dmitriy Novozhilov
2020-09-16 14:19:51 +03:00
parent 748049daa3
commit a666eee67b
4 changed files with 12 additions and 9 deletions
@@ -58,6 +58,11 @@ abstract class AbstractAnnotationDeserializer(
return annotations.map { deserializeAnnotation(it, nameResolver) }
}
fun loadTypeAliasAnnotations(aliasProto: ProtoBuf.TypeAlias, nameResolver: NameResolver): List<FirAnnotationCall> {
if (!Flags.HAS_ANNOTATIONS.get(aliasProto.flags)) return emptyList()
return aliasProto.annotationList.map { deserializeAnnotation(it, nameResolver) }
}
open fun loadFunctionAnnotations(
containerSource: DeserializedContainerSource?,
functionProto: ProtoBuf.Function,
@@ -15,10 +15,8 @@ import org.jetbrains.kotlin.fir.expressions.builder.buildExpressionStub
import org.jetbrains.kotlin.fir.symbols.CallableId
import org.jetbrains.kotlin.fir.symbols.StandardClassIds
import org.jetbrains.kotlin.fir.symbols.impl.*
import org.jetbrains.kotlin.fir.types.ConeAttributes
import org.jetbrains.kotlin.fir.types.FirTypeRef
import org.jetbrains.kotlin.fir.types.*
import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef
import org.jetbrains.kotlin.fir.types.computeTypeAttributes
import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl
import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl
import org.jetbrains.kotlin.fir.types.impl.FirImplicitUnitTypeRef
@@ -168,10 +166,10 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
isExpect = Flags.IS_EXPECT_CLASS.get(flags)
isActual = false
}
annotations += c.annotationDeserializer.loadTypeAliasAnnotations(proto, local.nameResolver)
symbol = FirTypeAliasSymbol(classId)
expandedTypeRef = buildResolvedTypeRef {
type = local.typeDeserializer.type(proto.underlyingType(c.typeTable), ConeAttributes.Empty)
}
expandedTypeRef = proto.underlyingType(c.typeTable).toTypeRef(local)
resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
typeParameters += local.typeDeserializer.ownTypeParameters.map { it.fir }
}.apply {