From 1fcf0991047712d5212342042facd2029ce452cb Mon Sep 17 00:00:00 2001 From: pyos Date: Mon, 17 Oct 2022 15:04:24 +0200 Subject: [PATCH] FIR: serialize both expanded and abbreviated type to metadata --- .../fir/serialization/FirElementSerializer.kt | 20 +++++++++++++++++++ .../annotationOnTypeUseInTypeAlias.kt | 2 -- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/FirElementSerializer.kt b/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/FirElementSerializer.kt index 2dd27bf9048..88c8dc5885f 100644 --- a/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/FirElementSerializer.kt +++ b/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/FirElementSerializer.kt @@ -627,6 +627,26 @@ class FirElementSerializer private constructor( toSuper: Boolean = false, correspondingTypeRef: FirTypeRef? = null, isDefinitelyNotNullType: Boolean = false, + ): ProtoBuf.Type.Builder { + val typeProto = typeOrTypealiasProto(type, toSuper, correspondingTypeRef, isDefinitelyNotNullType) + val expanded = if (type is ConeClassLikeType) type.fullyExpandedType(session) else type + if (expanded === type) { + return typeProto + } + val expandedProto = typeOrTypealiasProto(expanded, toSuper, correspondingTypeRef, isDefinitelyNotNullType) + if (useTypeTable()) { + expandedProto.abbreviatedTypeId = typeTable[typeProto] + } else { + expandedProto.setAbbreviatedType(typeProto) + } + return expandedProto + } + + private fun typeOrTypealiasProto( + type: ConeKotlinType, + toSuper: Boolean, + correspondingTypeRef: FirTypeRef?, + isDefinitelyNotNullType: Boolean, ): ProtoBuf.Type.Builder { val builder = ProtoBuf.Type.newBuilder() when (type) { diff --git a/compiler/testData/codegen/box/compileKotlinAgainstKotlin/annotationOnTypeUseInTypeAlias.kt b/compiler/testData/codegen/box/compileKotlinAgainstKotlin/annotationOnTypeUseInTypeAlias.kt index 06b146ad92d..e32e1f0736f 100644 --- a/compiler/testData/codegen/box/compileKotlinAgainstKotlin/annotationOnTypeUseInTypeAlias.kt +++ b/compiler/testData/codegen/box/compileKotlinAgainstKotlin/annotationOnTypeUseInTypeAlias.kt @@ -1,5 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR -// FIR status: List is empty for val argumentType = mycType.arguments.single().type!! // TARGET_BACKEND: JVM // WITH_REFLECT // MODULE: lib