JS: fix module aliasing for inline imports (KT-26466 fixed)
Consider an import from an inline function invocation. If it is being called from another inline function, it should be defined in a special way (e.g. `$$importsForInline$$.foo`) so that the compiler knows where to load transitive dependencies from. What's more, the declaration itself should be inside the inline function wrapper. Otherwise it should be defined in a regular way (e.g. `$module$bar.foo` among other top-level imports). By default the imports are loaded in the first form, and transformed into the second one when needed. To check whether this transformation the following predicate is used: `inlineFunctionDepth == 0`. At the moment the mentioned variable is increased upon visiting an inline function declaration (`defineInlineFunction`), and upon visiting an unknown (not visited before) inline function invocation. It seems that instead the variable should be increased when processing an existing inline function wrapper. At that point a new place to put import definitions (`statementContextForInline`) is set. Due to way JS code is generated (lambda's come before their call sites) this issue seems to have been masked. Primary class constructors are a special case - they come before any other declaration within. Hence a lambda invocation inside a constructor leads to incorrect import definition.
This commit is contained in:
+10
@@ -3875,6 +3875,11 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
|
||||
runTest("js/js.translator/testData/box/inline/inlineChain.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inlineChainCrossModule.kt")
|
||||
public void testInlineChainCrossModule() throws Exception {
|
||||
runTest("js/js.translator/testData/box/inline/inlineChainCrossModule.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inlineChainWithFewStatements.kt")
|
||||
public void testInlineChainWithFewStatements() throws Exception {
|
||||
runTest("js/js.translator/testData/box/inline/inlineChainWithFewStatements.kt");
|
||||
@@ -3985,6 +3990,11 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
|
||||
runTest("js/js.translator/testData/box/inline/kt26117.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt26466.kt")
|
||||
public void testKt26466() throws Exception {
|
||||
runTest("js/js.translator/testData/box/inline/kt26466.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lambdaInLambda.kt")
|
||||
public void testLambdaInLambda() throws Exception {
|
||||
runTest("js/js.translator/testData/box/inline/lambdaInLambda.kt");
|
||||
|
||||
+10
@@ -3875,6 +3875,11 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
|
||||
runTest("js/js.translator/testData/box/inline/inlineChain.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inlineChainCrossModule.kt")
|
||||
public void testInlineChainCrossModule() throws Exception {
|
||||
runTest("js/js.translator/testData/box/inline/inlineChainCrossModule.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inlineChainWithFewStatements.kt")
|
||||
public void testInlineChainWithFewStatements() throws Exception {
|
||||
runTest("js/js.translator/testData/box/inline/inlineChainWithFewStatements.kt");
|
||||
@@ -3985,6 +3990,11 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
|
||||
runTest("js/js.translator/testData/box/inline/kt26117.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt26466.kt")
|
||||
public void testKt26466() throws Exception {
|
||||
runTest("js/js.translator/testData/box/inline/kt26466.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lambdaInLambda.kt")
|
||||
public void testLambdaInLambda() throws Exception {
|
||||
runTest("js/js.translator/testData/box/inline/lambdaInLambda.kt");
|
||||
|
||||
Reference in New Issue
Block a user