[K/JS] Allow declare inline functions inside external declarations with a million suppresses ^KT-48154 Fixed
This commit is contained in:
+2
-1
@@ -90,6 +90,7 @@ class FunctionInlining(
|
||||
private val inlinePureArguments: Boolean = true,
|
||||
private val regenerateInlinedAnonymousObjects: Boolean = false,
|
||||
private val inlineArgumentsWithTheirOriginalTypeAndOffset: Boolean = false,
|
||||
private val allowExternalInlining: Boolean = false
|
||||
) : IrElementTransformerVoidWithContext(), BodyLoweringPass {
|
||||
private var containerScope: ScopeWithIr? = null
|
||||
|
||||
@@ -153,7 +154,7 @@ class FunctionInlining(
|
||||
return this
|
||||
}
|
||||
|
||||
private val IrFunction.needsInlining get() = this.isInline && !this.isExternal
|
||||
private val IrFunction.needsInlining get() = this.isInline && (allowExternalInlining || !this.isExternal)
|
||||
|
||||
private inner class Inliner(
|
||||
val callSite: IrFunctionAccessExpression,
|
||||
|
||||
@@ -20,7 +20,9 @@ import org.jetbrains.kotlin.ir.backend.js.codegen.JsGenerationGranularity
|
||||
import org.jetbrains.kotlin.ir.backend.js.lower.*
|
||||
import org.jetbrains.kotlin.ir.backend.js.lower.calls.CallsLowering
|
||||
import org.jetbrains.kotlin.ir.backend.js.lower.cleanup.CleanupLowering
|
||||
import org.jetbrains.kotlin.ir.backend.js.lower.coroutines.*
|
||||
import org.jetbrains.kotlin.ir.backend.js.lower.coroutines.AddContinuationToFunctionCallsLowering
|
||||
import org.jetbrains.kotlin.ir.backend.js.lower.coroutines.JsSuspendArityStoreLowering
|
||||
import org.jetbrains.kotlin.ir.backend.js.lower.coroutines.JsSuspendFunctionsLowering
|
||||
import org.jetbrains.kotlin.ir.backend.js.lower.inline.*
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFile
|
||||
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
|
||||
@@ -278,7 +280,7 @@ private val saveInlineFunctionsBeforeInlining = makeDeclarationTransformerPhase(
|
||||
)
|
||||
|
||||
private val functionInliningPhase = makeBodyLoweringPhase(
|
||||
{ FunctionInlining(it, JsInlineFunctionResolver(it), it.innerClassesSupport) },
|
||||
{ FunctionInlining(it, JsInlineFunctionResolver(it), it.innerClassesSupport, allowExternalInlining = true) },
|
||||
name = "FunctionInliningPhase",
|
||||
description = "Perform function inlining",
|
||||
prerequisite = setOf(saveInlineFunctionsBeforeInlining)
|
||||
|
||||
@@ -4756,6 +4756,12 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
|
||||
runTest("js/js.translator/testData/box/inline/extensionWithManyArguments.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("externalInlineWithSuppress.kt")
|
||||
public void testExternalInlineWithSuppress() throws Exception {
|
||||
runTest("js/js.translator/testData/box/inline/externalInlineWithSuppress.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("fakeOverrideInlining.kt")
|
||||
public void testFakeOverrideInlining() throws Exception {
|
||||
|
||||
+6
@@ -5372,6 +5372,12 @@ public class FirJsBoxTestGenerated extends AbstractFirJsBoxTest {
|
||||
runTest("js/js.translator/testData/box/inline/extensionWithManyArguments.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("externalInlineWithSuppress.kt")
|
||||
public void testExternalInlineWithSuppress() throws Exception {
|
||||
runTest("js/js.translator/testData/box/inline/externalInlineWithSuppress.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("fakeOverrideInlining.kt")
|
||||
public void testFakeOverrideInlining() throws Exception {
|
||||
|
||||
+6
@@ -5478,6 +5478,12 @@ public class IrBoxJsES6TestGenerated extends AbstractIrBoxJsES6Test {
|
||||
runTest("js/js.translator/testData/box/inline/extensionWithManyArguments.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("externalInlineWithSuppress.kt")
|
||||
public void testExternalInlineWithSuppress() throws Exception {
|
||||
runTest("js/js.translator/testData/box/inline/externalInlineWithSuppress.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("fakeOverrideInlining.kt")
|
||||
public void testFakeOverrideInlining() throws Exception {
|
||||
|
||||
+6
@@ -5372,6 +5372,12 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
|
||||
runTest("js/js.translator/testData/box/inline/extensionWithManyArguments.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("externalInlineWithSuppress.kt")
|
||||
public void testExternalInlineWithSuppress() throws Exception {
|
||||
runTest("js/js.translator/testData/box/inline/externalInlineWithSuppress.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("fakeOverrideInlining.kt")
|
||||
public void testFakeOverrideInlining() throws Exception {
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
// EXPECTED_REACHABLE_NODES: 1284
|
||||
// IGNORE_BACKEND: JS
|
||||
// FILE: main.kt
|
||||
@file:Suppress(
|
||||
"NESTED_CLASS_IN_EXTERNAL_INTERFACE",
|
||||
"WRONG_BODY_OF_EXTERNAL_DECLARATION",
|
||||
"INLINE_EXTERNAL_DECLARATION",
|
||||
"NON_ABSTRACT_MEMBER_OF_EXTERNAL_INTERFACE",
|
||||
"DECLARATION_CANT_BE_INLINED",
|
||||
)
|
||||
package foo
|
||||
|
||||
|
||||
@JsName("null")
|
||||
external interface Foo {
|
||||
companion object {
|
||||
inline fun test(): String = "OK"
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return Foo.test()
|
||||
}
|
||||
|
||||
// FILE: lib.js
|
||||
function Foo() {}
|
||||
Reference in New Issue
Block a user