FIR serializer: serialize annotations on FirTypeRef, not ConeKotlinType

This commit is contained in:
Jinseong Jeon
2020-08-02 23:50:24 -07:00
committed by Mikhail Glukhikh
parent 0a28e5e031
commit 47c47be3d3
3 changed files with 11 additions and 13 deletions
@@ -543,11 +543,13 @@ class FirElementSerializer private constructor(
fun typeId(type: ConeKotlinType): Int = typeTable[typeProto(type)]
internal fun typeProto(typeRef: FirTypeRef): ProtoBuf.Type.Builder {
return typeProto(typeRef.coneType)
private fun typeProto(typeRef: FirTypeRef): ProtoBuf.Type.Builder {
return typeProto(typeRef.coneType).also {
extension.serializeType(typeRef, it)
}
}
internal fun typeProto(type: ConeKotlinType): ProtoBuf.Type.Builder {
private fun typeProto(type: ConeKotlinType): ProtoBuf.Type.Builder {
val builder = ProtoBuf.Type.newBuilder()
when (type) {
@@ -602,8 +604,6 @@ class FirElementSerializer private constructor(
// }
// }
extension.serializeType(type, builder)
return builder
}
@@ -9,7 +9,7 @@ import org.jetbrains.kotlin.fir.FirSession
import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.fir.types.ConeFlexibleType
import org.jetbrains.kotlin.fir.types.ConeKotlinErrorType
import org.jetbrains.kotlin.fir.types.ConeKotlinType
import org.jetbrains.kotlin.fir.types.FirTypeRef
import org.jetbrains.kotlin.metadata.ProtoBuf
import org.jetbrains.kotlin.metadata.deserialization.BinaryVersion
import org.jetbrains.kotlin.metadata.serialization.MutableVersionRequirementTable
@@ -74,7 +74,7 @@ abstract class FirSerializerExtension {
open fun serializeFlexibleType(type: ConeFlexibleType, lowerProto: ProtoBuf.Type.Builder, upperProto: ProtoBuf.Type.Builder) {
}
open fun serializeType(type: ConeKotlinType, proto: ProtoBuf.Type.Builder) {
open fun serializeType(type: FirTypeRef, proto: ProtoBuf.Type.Builder) {
}
open fun serializeTypeParameter(typeParameter: FirTypeParameter, proto: ProtoBuf.TypeParameter.Builder) {
@@ -14,7 +14,6 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
import org.jetbrains.kotlin.descriptors.Visibilities
import org.jetbrains.kotlin.fir.FirEffectiveVisibilityImpl
import org.jetbrains.kotlin.fir.FirSession
import org.jetbrains.kotlin.fir.backend.FirMetadataSource
import org.jetbrains.kotlin.fir.declarations.*
@@ -183,12 +182,11 @@ class FirJvmSerializerExtension @JvmOverloads constructor(
}
}
override fun serializeType(type: ConeKotlinType, proto: ProtoBuf.Type.Builder) {
override fun serializeType(type: FirTypeRef, proto: ProtoBuf.Type.Builder) {
// TODO: don't store type annotations in our binary metadata on Java 8, use *TypeAnnotations attributes instead
// TODO: (FIR) ConeKotlinType does not store annotations, see KT-30066
// for (annotation in type.annotations) {
// proto.addExtension(JvmProtoBuf.typeAnnotation, annotationSerializer.serializeAnnotation(annotation))
// }
for (annotation in type.annotations) {
proto.addExtension(JvmProtoBuf.typeAnnotation, annotationSerializer.serializeAnnotation(annotation))
}
}
override fun serializeTypeParameter(typeParameter: FirTypeParameter, proto: ProtoBuf.TypeParameter.Builder) {