From f7036aa79c3bac7f13e0338fdd07fbfcb9484a10 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Thu, 16 Feb 2023 19:43:40 +0100 Subject: [PATCH] FIR2IR: don't generate default parameters for delegated members #KT-55465 Fixed --- .../jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt | 2 +- .../codegen/box/compileKotlinAgainstKotlin/delegatedDefault.kt | 2 -- .../codegen/box/delegation/withDefaultsMultipleFilesOrder.kt | 1 - .../inlineClasses/delegationByUnderlyingType/defaultArgument.kt | 1 - .../delegationByUnderlyingType/defaultArgumentGeneric.kt | 1 - .../ir/irText/firProblems/ErrorInDefaultValue.fir.ir.txt | 2 -- .../ir/irText/firProblems/ErrorInDefaultValue.fir.kt.txt | 2 +- 7 files changed, 2 insertions(+), 9 deletions(-) diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt index b76e564d819..2ded3b75a22 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt @@ -349,7 +349,7 @@ class Fir2IrDeclarationStorage( valueParameter, index + contextReceiverParametersCount, useStubForDefaultValueStub = function !is FirConstructor || containingClass?.name != Name.identifier("Enum"), typeContext, - skipDefaultParameter = isFakeOverride + skipDefaultParameter = isFakeOverride || origin == IrDeclarationOrigin.DELEGATED_MEMBER ).apply { this.parent = parent } diff --git a/compiler/testData/codegen/box/compileKotlinAgainstKotlin/delegatedDefault.kt b/compiler/testData/codegen/box/compileKotlinAgainstKotlin/delegatedDefault.kt index 7c9a03947b4..46edc4677e7 100644 --- a/compiler/testData/codegen/box/compileKotlinAgainstKotlin/delegatedDefault.kt +++ b/compiler/testData/codegen/box/compileKotlinAgainstKotlin/delegatedDefault.kt @@ -1,5 +1,3 @@ -// KT-55465 -// IGNORE_BACKEND_K2: NATIVE // MODULE: lib // FILE: A.kt package lib diff --git a/compiler/testData/codegen/box/delegation/withDefaultsMultipleFilesOrder.kt b/compiler/testData/codegen/box/delegation/withDefaultsMultipleFilesOrder.kt index b9e1f78168e..74834745753 100644 --- a/compiler/testData/codegen/box/delegation/withDefaultsMultipleFilesOrder.kt +++ b/compiler/testData/codegen/box/delegation/withDefaultsMultipleFilesOrder.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_K2: JS_IR, NATIVE // FILE: lib.kt interface ResolutionScope { fun getContributedDescriptors(s: String = "OK"): String diff --git a/compiler/testData/codegen/box/inlineClasses/delegationByUnderlyingType/defaultArgument.kt b/compiler/testData/codegen/box/inlineClasses/delegationByUnderlyingType/defaultArgument.kt index 99c4b93c65a..9f94a9a50fc 100644 --- a/compiler/testData/codegen/box/inlineClasses/delegationByUnderlyingType/defaultArgument.kt +++ b/compiler/testData/codegen/box/inlineClasses/delegationByUnderlyingType/defaultArgument.kt @@ -1,7 +1,6 @@ // WITH_STDLIB // IGNORE_LIGHT_ANALYSIS // IGNORE_BACKEND: JVM -// IGNORE_BACKEND_K2: JS_IR, NATIVE // LANGUAGE: +InlineClassImplementationByDelegation interface I { diff --git a/compiler/testData/codegen/box/inlineClasses/delegationByUnderlyingType/defaultArgumentGeneric.kt b/compiler/testData/codegen/box/inlineClasses/delegationByUnderlyingType/defaultArgumentGeneric.kt index 0a05bb236dc..eb3ad3810ef 100644 --- a/compiler/testData/codegen/box/inlineClasses/delegationByUnderlyingType/defaultArgumentGeneric.kt +++ b/compiler/testData/codegen/box/inlineClasses/delegationByUnderlyingType/defaultArgumentGeneric.kt @@ -1,7 +1,6 @@ // WITH_STDLIB // IGNORE_LIGHT_ANALYSIS // IGNORE_BACKEND: JVM -// IGNORE_BACKEND_K2: JS_IR, NATIVE // LANGUAGE: +InlineClassImplementationByDelegation, +GenericInlineClassParameter interface I { diff --git a/compiler/testData/ir/irText/firProblems/ErrorInDefaultValue.fir.ir.txt b/compiler/testData/ir/irText/firProblems/ErrorInDefaultValue.fir.ir.txt index 4592e4885bb..c9512844e76 100644 --- a/compiler/testData/ir/irText/firProblems/ErrorInDefaultValue.fir.ir.txt +++ b/compiler/testData/ir/irText/firProblems/ErrorInDefaultValue.fir.ir.txt @@ -58,8 +58,6 @@ FILE fqName: fileName:/ErrorInDefaultValue.kt public abstract fun f (x: kotlin.String): kotlin.String declared in .A $this: VALUE_PARAMETER name: type:.C VALUE_PARAMETER name:x index:0 type:kotlin.String - EXPRESSION_BODY - ERROR_EXPR 'Stub expression for default value of x' type=kotlin.String BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun f (x: kotlin.String): kotlin.String declared in .C' CALL 'public abstract fun f (x: kotlin.String): kotlin.String declared in .A' type=kotlin.String origin=null diff --git a/compiler/testData/ir/irText/firProblems/ErrorInDefaultValue.fir.kt.txt b/compiler/testData/ir/irText/firProblems/ErrorInDefaultValue.fir.kt.txt index 208c1b5ddda..c30c6e58fcd 100644 --- a/compiler/testData/ir/irText/firProblems/ErrorInDefaultValue.fir.kt.txt +++ b/compiler/testData/ir/irText/firProblems/ErrorInDefaultValue.fir.kt.txt @@ -23,7 +23,7 @@ class C : A { } - override fun f(x: String = error("") /* ErrorExpression */): String { + override fun f(x: String): String { return .#x.f(x = x) }