From d600d768a61490a342acdf13c9efaf6151a11317 Mon Sep 17 00:00:00 2001 From: "vladislav.grechko" Date: Fri, 9 Jun 2023 14:37:23 +0200 Subject: [PATCH] Do not assert existence of metadata for local delegated properties Local delegated property may origin from a body of inlined function. In that case, they contain no metatada - which is ok, as the original local delegated properties contain it and will be serialized. ^KT-58780: Fixed --- .../jetbrains/kotlin/fir/backend/jvm/FirMetadataSerializer.kt | 4 ++-- .../testData/codegen/boxInline/delegatedProperty/kt48498.kt | 1 - .../testData/codegen/boxInline/delegatedProperty/local.kt | 1 - .../boxInline/delegatedProperty/localDeclaredInLambda.kt | 1 - .../boxInline/delegatedProperty/localInAnonymousObject.kt | 1 - .../codegen/boxInline/delegatedProperty/localInLambda.kt | 1 - 6 files changed, 2 insertions(+), 7 deletions(-) diff --git a/compiler/fir/fir2ir/jvm-backend/src/org/jetbrains/kotlin/fir/backend/jvm/FirMetadataSerializer.kt b/compiler/fir/fir2ir/jvm-backend/src/org/jetbrains/kotlin/fir/backend/jvm/FirMetadataSerializer.kt index e7c81c5620a..2b7b70451d3 100644 --- a/compiler/fir/fir2ir/jvm-backend/src/org/jetbrains/kotlin/fir/backend/jvm/FirMetadataSerializer.kt +++ b/compiler/fir/fir2ir/jvm-backend/src/org/jetbrains/kotlin/fir/backend/jvm/FirMetadataSerializer.kt @@ -54,8 +54,8 @@ fun makeFirMetadataSerializerForIrClass( irActualizedResult: IrActualizedResult? ): FirMetadataSerializer { val approximator = TypeApproximatorForMetadataSerializer(session) - val localDelegatedProperties = context.localDelegatedProperties[irClass.attributeOwnerId]?.map { - (it.owner.metadata as FirMetadataSource.Property).fir.copyToFreeProperty(approximator) + val localDelegatedProperties = context.localDelegatedProperties[irClass.attributeOwnerId]?.mapNotNull { + (it.owner.metadata as? FirMetadataSource.Property)?.fir?.copyToFreeProperty(approximator) } ?: emptyList() val firSerializerExtension = FirJvmSerializerExtension( session, serializationBindings, context.state, irClass.metadata, localDelegatedProperties, diff --git a/compiler/testData/codegen/boxInline/delegatedProperty/kt48498.kt b/compiler/testData/codegen/boxInline/delegatedProperty/kt48498.kt index 5a2d2b81d29..ee801c9a74f 100644 --- a/compiler/testData/codegen/boxInline/delegatedProperty/kt48498.kt +++ b/compiler/testData/codegen/boxInline/delegatedProperty/kt48498.kt @@ -1,4 +1,3 @@ -// IGNORE_INLINER_K2: IR // FILE: 1.kt package x diff --git a/compiler/testData/codegen/boxInline/delegatedProperty/local.kt b/compiler/testData/codegen/boxInline/delegatedProperty/local.kt index 2f5647ca89f..36fc9fc367e 100644 --- a/compiler/testData/codegen/boxInline/delegatedProperty/local.kt +++ b/compiler/testData/codegen/boxInline/delegatedProperty/local.kt @@ -1,4 +1,3 @@ -// IGNORE_INLINER_K2: IR // FILE: 1.kt package test diff --git a/compiler/testData/codegen/boxInline/delegatedProperty/localDeclaredInLambda.kt b/compiler/testData/codegen/boxInline/delegatedProperty/localDeclaredInLambda.kt index b9e9ffc73c1..f5b26d2fcc1 100644 --- a/compiler/testData/codegen/boxInline/delegatedProperty/localDeclaredInLambda.kt +++ b/compiler/testData/codegen/boxInline/delegatedProperty/localDeclaredInLambda.kt @@ -1,4 +1,3 @@ -// IGNORE_INLINER_K2: IR // IGNORE_BACKEND_MULTI_MODULE: JVM, JVM_MULTI_MODULE_IR_AGAINST_OLD // FILE: test.kt package test diff --git a/compiler/testData/codegen/boxInline/delegatedProperty/localInAnonymousObject.kt b/compiler/testData/codegen/boxInline/delegatedProperty/localInAnonymousObject.kt index 539655ea862..c098619f778 100644 --- a/compiler/testData/codegen/boxInline/delegatedProperty/localInAnonymousObject.kt +++ b/compiler/testData/codegen/boxInline/delegatedProperty/localInAnonymousObject.kt @@ -1,4 +1,3 @@ -// IGNORE_INLINER_K2: IR // FILE: 1.kt package test diff --git a/compiler/testData/codegen/boxInline/delegatedProperty/localInLambda.kt b/compiler/testData/codegen/boxInline/delegatedProperty/localInLambda.kt index a37682be7e2..851a60fab73 100644 --- a/compiler/testData/codegen/boxInline/delegatedProperty/localInLambda.kt +++ b/compiler/testData/codegen/boxInline/delegatedProperty/localInLambda.kt @@ -1,4 +1,3 @@ -// IGNORE_INLINER_K2: IR // FILE: 1.kt package test