From 1f55dc73d2d0ffa2d7218ec890cef43958555857 Mon Sep 17 00:00:00 2001 From: Anton Bannykh Date: Thu, 21 Oct 2021 12:37:30 +0300 Subject: [PATCH] [JS IR] don't inline property accessors across files --- .../lower/JsPropertyAccessorInlineLowering.kt | 38 +++++++++++-------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/JsPropertyAccessorInlineLowering.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/JsPropertyAccessorInlineLowering.kt index acc48c4e325..dc1366cd8de 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/JsPropertyAccessorInlineLowering.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/JsPropertyAccessorInlineLowering.kt @@ -19,22 +19,28 @@ class JsPropertyAccessorInlineLowering( if (!isSafeToInlineInClosedWorld()) return false - if (isConst) - return true + // TODO: teach the deserializer to load constant property initializers + val accessFile = accessContainer.fileOrNull ?: return false + val file = fileOrNull ?: return false - return when (context.granularity) { - JsGenerationGranularity.WHOLE_PROGRAM -> - true - JsGenerationGranularity.PER_MODULE -> { - val accessModule = accessContainer.fileOrNull?.module ?: return false - val module = fileOrNull?.module ?: return false - accessModule == module - } - JsGenerationGranularity.PER_FILE -> - // Not inlining because - // 1. we need a way to distinguish per-file generation units - // 2. per-file mode intended for debug builds only at the moment - false - } + return accessFile == file + +// if (isConst) +// return true +// +// return when (context.granularity) { +// JsGenerationGranularity.WHOLE_PROGRAM -> +// true +// JsGenerationGranularity.PER_MODULE -> { +// val accessModule = accessContainer.fileOrNull?.module ?: return false +// val module = fileOrNull?.module ?: return false +// accessModule == module +// } +// JsGenerationGranularity.PER_FILE -> +// // Not inlining because +// // 1. we need a way to distinguish per-file generation units +// // 2. per-file mode intended for debug builds only at the moment +// false +// } } } \ No newline at end of file