From c5857904696bbce5bcea67870e2e784e271450c2 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Fri, 17 Feb 2023 11:52:10 +0100 Subject: [PATCH] IR (test infrastructure): don't load function body in assertion --- .../test/backend/handlers/IrInlineBodiesHandler.kt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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 f19699d5ae7..52e07c50fc6 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 @@ -7,7 +7,9 @@ package org.jetbrains.kotlin.test.backend.handlers import org.jetbrains.kotlin.ir.IrElement import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction +import org.jetbrains.kotlin.ir.declarations.lazy.AbstractIrLazyFunction import org.jetbrains.kotlin.ir.expressions.IrMemberAccessExpression +import org.jetbrains.kotlin.ir.util.DeserializableClass import org.jetbrains.kotlin.ir.util.IdSignature import org.jetbrains.kotlin.ir.util.allUnbound import org.jetbrains.kotlin.ir.util.resolveFakeOverride @@ -53,9 +55,18 @@ class IrInlineBodiesHandler(testServices: TestServices) : AbstractIrHandler(test val callee = symbol.owner if (callee.symbol.signature in declaredInlineFunctionSignatures) { val trueCallee = (callee as IrSimpleFunction).resolveFakeOverride()!! - assertions.assertNotNull(trueCallee.body) + assertions.assertTrue(trueCallee.hasBody()) { + "IrInlineBodiesHandler: function with body expected" + } } super.visitMemberAccess(expression) } + + private fun IrSimpleFunction.hasBody(): Boolean { + if (this !is AbstractIrLazyFunction) return body != null + if (!isDeserializationEnabled) return false + if (!isInline || isFakeOverride) return false + return getTopLevelDeclaration() is DeserializableClass + } } }