From 019836e9c797e082f1478ccb73ac5acca7338314 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Thu, 14 Sep 2023 19:12:19 +0200 Subject: [PATCH] IR: use origin DEFINED for value parameters of fake overrides Fake overrides created by K1, as well as fir2ir in K2, use DEFINED. So this gets rid of a lot of differences in IR text dumps between the K2 normal mode and K2 with IR fake overrides, and will ultimately help in implementing and testing KT-61360. The change in AddContinuationLowering is needed to fix tests like kt47549. When creating anonymous classes for SAM implementations, we're reusing the same fake override building machinery. And since we can't extract any meaningful information from the fake override parameter's origin anymore, we have to get the parameter from the original symbol. --- .../kotlin/backend/jvm/lower/AddContinuationLowering.kt | 2 +- .../src/org/jetbrains/kotlin/ir/overrides/FakeOverrideCopier.kt | 2 +- .../codegen/box/annotations/javaAnnotationArrayValueDefault.kt | 1 - .../codegen/box/annotations/javaTargetOnPrimaryCtorParameter.kt | 1 - .../codegen/box/delegation/delegationToIntersectionType.kt | 1 - .../codegen/box/delegation/delegationToIntersectionType2.kt | 1 - compiler/testData/codegen/box/smartCasts/kt44814.kt | 1 - 7 files changed, 2 insertions(+), 7 deletions(-) diff --git a/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/AddContinuationLowering.kt b/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/AddContinuationLowering.kt index b067439dbae..007516287f7 100644 --- a/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/AddContinuationLowering.kt +++ b/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/AddContinuationLowering.kt @@ -403,7 +403,7 @@ private fun IrSimpleFunction.suspendFunctionViewOrStub(context: JvmBackendContex // If superinterface is in another file, the bridge to default method will already have continuation parameter, // so skip it. See KT-47549. if (origin == JvmLoweredDeclarationOrigin.SUPER_INTERFACE_METHOD_BRIDGE && - valueParameters.lastOrNull()?.origin == JvmLoweredDeclarationOrigin.CONTINUATION_CLASS + overriddenSymbols.singleOrNull()?.owner?.valueParameters?.lastOrNull()?.origin == JvmLoweredDeclarationOrigin.CONTINUATION_CLASS ) return this // We need to use suspend function originals here, since if we use 'this' here, // turing FlowCollector into 'fun interface' leads to AbstractMethodError. See KT-49294. diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/overrides/FakeOverrideCopier.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/overrides/FakeOverrideCopier.kt index b06a09efe38..0e6b93c4df2 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/overrides/FakeOverrideCopier.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/overrides/FakeOverrideCopier.kt @@ -94,7 +94,7 @@ class FakeOverrideCopier( declaration.factory.createValueParameter( startOffset = declaration.startOffset, endOffset = declaration.endOffset, - origin = mapDeclarationOrigin(declaration.origin), + origin = IrDeclarationOrigin.DEFINED, name = symbolRenamer.getValueParameterName(declaration.symbol), type = declaration.type.remapType(), isAssignable = declaration.isAssignable, diff --git a/compiler/testData/codegen/box/annotations/javaAnnotationArrayValueDefault.kt b/compiler/testData/codegen/box/annotations/javaAnnotationArrayValueDefault.kt index 4489db40d7c..9bc529c469a 100644 --- a/compiler/testData/codegen/box/annotations/javaAnnotationArrayValueDefault.kt +++ b/compiler/testData/codegen/box/annotations/javaAnnotationArrayValueDefault.kt @@ -1,7 +1,6 @@ // TARGET_BACKEND: JVM // WITH_STDLIB // DUMP_IR -// IGNORE_CODEGEN_WITH_IR_FAKE_OVERRIDE_GENERATION: KT-61386 // MODULE: lib // FILE: JavaAnn.java diff --git a/compiler/testData/codegen/box/annotations/javaTargetOnPrimaryCtorParameter.kt b/compiler/testData/codegen/box/annotations/javaTargetOnPrimaryCtorParameter.kt index 0fe73dbba58..f93029e1aad 100644 --- a/compiler/testData/codegen/box/annotations/javaTargetOnPrimaryCtorParameter.kt +++ b/compiler/testData/codegen/box/annotations/javaTargetOnPrimaryCtorParameter.kt @@ -1,6 +1,5 @@ // WITH_STDLIB // WITH_REFLECT -// IGNORE_CODEGEN_WITH_IR_FAKE_OVERRIDE_GENERATION: KT-61386 // TARGET_BACKEND: JVM_IR // FIR_DUMP // DUMP_IR diff --git a/compiler/testData/codegen/box/delegation/delegationToIntersectionType.kt b/compiler/testData/codegen/box/delegation/delegationToIntersectionType.kt index 80deb1def63..f2b58c35c75 100644 --- a/compiler/testData/codegen/box/delegation/delegationToIntersectionType.kt +++ b/compiler/testData/codegen/box/delegation/delegationToIntersectionType.kt @@ -1,5 +1,4 @@ // DUMP_IR -// IGNORE_CODEGEN_WITH_IR_FAKE_OVERRIDE_GENERATION: KT-61386 fun select(a: T, b: T) : T = a diff --git a/compiler/testData/codegen/box/delegation/delegationToIntersectionType2.kt b/compiler/testData/codegen/box/delegation/delegationToIntersectionType2.kt index 5cc40c09bc8..287c3039b72 100644 --- a/compiler/testData/codegen/box/delegation/delegationToIntersectionType2.kt +++ b/compiler/testData/codegen/box/delegation/delegationToIntersectionType2.kt @@ -1,7 +1,6 @@ // TARGET_BACKEND: JVM // IGNORE_BACKEND_K1: ANY // DUMP_IR -// IGNORE_CODEGEN_WITH_IR_FAKE_OVERRIDE_GENERATION: KT-61386 // K1_STATUS: java.lang.AssertionError: There is still an unbound symbol after generation of IR module
fun select(a: T, b: T) : T = a diff --git a/compiler/testData/codegen/box/smartCasts/kt44814.kt b/compiler/testData/codegen/box/smartCasts/kt44814.kt index 82d7de4aaad..efab025c5a8 100644 --- a/compiler/testData/codegen/box/smartCasts/kt44814.kt +++ b/compiler/testData/codegen/box/smartCasts/kt44814.kt @@ -2,7 +2,6 @@ // WITH_STDLIB // DUMP_IR // DUMP_CFG -// IGNORE_CODEGEN_WITH_IR_FAKE_OVERRIDE_GENERATION: KT-61386 // RENDERER_CFG_LEVELS class FlyweightCapableTreeStructure