From 731eeb020dc75844f740d87dde29b1f909ae62c8 Mon Sep 17 00:00:00 2001 From: Sergej Jaskiewicz Date: Tue, 16 Jan 2024 14:28:32 +0100 Subject: [PATCH] [JVM] Don't rely on presence of signatures in JVM IR serialization tests This patch should not change any reasonable testing behavior. The only case when the behavior could be changed is when two different functions have the same IdSignature, which is a problem on its own. Required for KT-64809 --- .../test/backend/handlers/IrInlineBodiesHandler.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrInlineBodiesHandler.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrInlineBodiesHandler.kt index 2cb5d8e8f40..ef2ce74860c 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrInlineBodiesHandler.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrInlineBodiesHandler.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.test.model.TestModule import org.jetbrains.kotlin.test.services.TestServices class IrInlineBodiesHandler(testServices: TestServices) : AbstractIrHandler(testServices) { - val declaredInlineFunctionSignatures = mutableSetOf() + val declaredInlineFunctions = hashSetOf() @OptIn(ObsoleteDescriptorBasedAPI::class) override fun processModule(module: TestModule, info: IrBackendInput) { @@ -33,7 +33,7 @@ class IrInlineBodiesHandler(testServices: TestServices) : AbstractIrHandler(test } override fun processAfterAllModules(someAssertionWasFailed: Boolean) { - assertions.assertTrue(declaredInlineFunctionSignatures.isNotEmpty()) + assertions.assertTrue(declaredInlineFunctions.isNotEmpty()) } inner class InlineFunctionsCollector : IrElementVisitorVoid { @@ -42,7 +42,7 @@ class IrInlineBodiesHandler(testServices: TestServices) : AbstractIrHandler(test } override fun visitSimpleFunction(declaration: IrSimpleFunction) { - if (declaration.isInline) declaration.symbol.signature?.let { declaredInlineFunctionSignatures.add(it) } + if (declaration.isInline) declaredInlineFunctions.add(declaration) super.visitSimpleFunction(declaration) } } @@ -56,8 +56,8 @@ class IrInlineBodiesHandler(testServices: TestServices) : AbstractIrHandler(test val symbol = expression.symbol assertions.assertTrue(symbol.isBound) val callee = symbol.owner - if (callee.symbol.signature in declaredInlineFunctionSignatures) { - val trueCallee = (callee as IrSimpleFunction).resolveFakeOverrideOrFail() + if (callee is IrSimpleFunction && callee in declaredInlineFunctions) { + val trueCallee = callee.resolveFakeOverrideOrFail() assertions.assertTrue(trueCallee.hasBody()) { "IrInlineBodiesHandler: function with body expected" }