Fix translation to JS of call to top-level fun with vararg and @JsModule
See KT-17871
This commit is contained in:
@@ -5278,6 +5278,12 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/jsModule/importCountUmd.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("topLevelVarargFun.kt")
|
||||
public void testTopLevelVarargFun() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/jsModule/topLevelVarargFun.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/box/jsName")
|
||||
|
||||
+2
-2
@@ -73,12 +73,12 @@ object DefaultFunctionCallCase : FunctionCallCase() {
|
||||
callableDescriptor: CallableDescriptor,
|
||||
isNative: Boolean,
|
||||
hasSpreadOperator: Boolean): JsExpression {
|
||||
val functionRef = ReferenceTranslator.translateAsValueReference(callableDescriptor, context)
|
||||
if (isNative && hasSpreadOperator) {
|
||||
val functionCallRef = Namer.getFunctionApplyRef(JsNameRef(context.getNameForDescriptor(callableDescriptor)))
|
||||
val functionCallRef = Namer.getFunctionApplyRef(functionRef)
|
||||
return JsInvocation(functionCallRef, argumentsInfo.translateArguments)
|
||||
}
|
||||
|
||||
val functionRef = ReferenceTranslator.translateAsValueReference(callableDescriptor, context)
|
||||
return JsInvocation(functionRef, argumentsInfo.translateArguments)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
define("bar", [], function() {
|
||||
return function() {
|
||||
return "(" + Array.prototype.join.call(arguments, "") + ")";
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,15 @@
|
||||
// EXPECTED_REACHABLE_NODES: 490
|
||||
// MODULE_KIND: AMD
|
||||
@JsModule("bar")
|
||||
external fun foo(vararg arg: String): String
|
||||
|
||||
fun box(): String {
|
||||
val x = arrayOf("a", "b")
|
||||
var r = foo(*x)
|
||||
if (r != "(ab)") return "fail1: $r"
|
||||
|
||||
r = foo("c", "d")
|
||||
if (r != "(cd)") return "fail2: $r"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user