diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/Dce.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/Dce.kt index c4b6a7be7bf..754e9120d7d 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/Dce.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/Dce.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ @@ -94,29 +94,6 @@ private fun removeUselessDeclarations(module: IrModuleFragment, usefulDeclaratio } } -private fun Iterable.withNested(): Iterable { - val result = mutableListOf() - - this.forEach { - it.acceptVoid(object : IrElementVisitorVoid { - override fun visitElement(element: IrElement) { - element.acceptChildrenVoid(this) - } - - override fun visitBody(body: IrBody) { - // Skip - } - - override fun visitDeclaration(declaration: IrDeclaration) { - super.visitDeclaration(declaration) - result += declaration - } - }) - } - - return result -} - fun usefulDeclarations(roots: Iterable, context: JsIrBackendContext): Set { val queue = ArrayDeque() val result = hashSetOf() @@ -129,6 +106,29 @@ fun usefulDeclarations(roots: Iterable, context: JsIrBackendConte } } + fun Iterable.withNested(): Iterable { + val result = mutableListOf() + + this.forEach { + it.acceptVoid(object : IrElementVisitorVoid { + override fun visitElement(element: IrElement) { + element.acceptChildrenVoid(this) + } + + override fun visitBody(body: IrBody) { + // Skip + } + + override fun visitDeclaration(declaration: IrDeclaration) { + super.visitDeclaration(declaration) + result += declaration + } + }) + } + + return result + } + // Add roots, including nested declarations stageController.withInitialIr { roots.withNested().forEach { it.enqueue() }