Support for named arguments in dynamic calls

This commit is contained in:
Andrey Breslav
2014-11-13 04:03:41 +02:00
parent 0ebc478d50
commit 645d931a9e
4 changed files with 22 additions and 4 deletions
@@ -109,15 +109,14 @@ object DynamicCallableDescriptors {
} }
private fun createValueParameters(owner: DeclarationDescriptor, call: Call): List<ValueParameterDescriptor> = private fun createValueParameters(owner: DeclarationDescriptor, call: Call): List<ValueParameterDescriptor> =
call.getValueArguments().indices.map { call.getValueArguments().withIndices().map { p ->
index val (index, arg) = p
->
ValueParameterDescriptorImpl( ValueParameterDescriptorImpl(
owner, owner,
null, null,
index, index,
Annotations.EMPTY, Annotations.EMPTY,
Name.identifier("p$index"), arg.getArgumentName()?.getReferenceExpression()?.getReferencedNameAsName() ?: Name.identifier("p$index"),
DynamicType, DynamicType,
false, false,
null, null,
@@ -0,0 +1,10 @@
// MODULE[js]: m1
// FILE: k.kt
fun test(d: dynamic) {
d.foo(name = "name")
d.foo(1, name = "name")
d.foo(1, duplicate = "", <!ARGUMENT_PASSED_TWICE!>duplicate<!> = ""<!NO_VALUE_FOR_PARAMETER!>)<!>
}
@@ -0,0 +1,3 @@
package
internal fun test(/*0*/ d: dynamic): kotlin.Unit
@@ -3746,6 +3746,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
doTest(fileName); doTest(fileName);
} }
@TestMetadata("namedArguments.kt")
public void testNamedArguments() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/dynamicTypes/namedArguments.kt");
doTest(fileName);
}
@TestMetadata("nullable.kt") @TestMetadata("nullable.kt")
public void testNullable() throws Exception { public void testNullable() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/dynamicTypes/nullable.kt"); String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/dynamicTypes/nullable.kt");