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.
This commit is contained in:
Alexander Udalov
2023-09-14 19:12:19 +02:00
committed by Space Team
parent 23ceb5d08a
commit 019836e9c7
7 changed files with 2 additions and 7 deletions
@@ -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.
@@ -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,
@@ -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
@@ -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
@@ -1,5 +1,4 @@
// DUMP_IR
// IGNORE_CODEGEN_WITH_IR_FAKE_OVERRIDE_GENERATION: KT-61386
fun <T> select(a: T, b: T) : T = a
@@ -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 <main>
fun <T> select(a: T, b: T) : T = a
-1
View File
@@ -2,7 +2,6 @@
// WITH_STDLIB
// DUMP_IR
// DUMP_CFG
// IGNORE_CODEGEN_WITH_IR_FAKE_OVERRIDE_GENERATION: KT-61386
// RENDERER_CFG_LEVELS
class FlyweightCapableTreeStructure