From 39349abd39d34e6383ee138d02c420a376e0ec41 Mon Sep 17 00:00:00 2001 From: Mikhail Zarechenskiy Date: Tue, 27 Jun 2017 19:23:11 +0300 Subject: [PATCH] [NI] Preserve name of parameters for functional types --- .../kotlin/resolve/calls/components/ResolutionParts.kt | 2 +- .../controlStructures/parameterWithNameForFunctionType.kt | 8 ++++++++ .../kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java | 6 ++++++ .../kotlin/codegen/BlackBoxCodegenTestGenerated.java | 6 ++++++ .../kotlin/codegen/LightAnalysisModeTestGenerated.java | 6 ++++++ .../js/test/semantics/JsCodegenBoxTestGenerated.java | 6 ++++++ 6 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 compiler/testData/codegen/box/controlStructures/parameterWithNameForFunctionType.kt diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/ResolutionParts.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/ResolutionParts.kt index 9f7b38b5fdf..3d1f957e0e5 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/ResolutionParts.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/ResolutionParts.kt @@ -84,7 +84,7 @@ internal object NoTypeArguments : ResolutionPart { internal object MapArguments : ResolutionPart { override fun SimpleKotlinResolutionCandidate.process(): List { - val mapping = callContext.argumentsToParametersMapper.mapArguments(kotlinCall, candidateDescriptor.original) + val mapping = callContext.argumentsToParametersMapper.mapArguments(kotlinCall, candidateDescriptor) argumentMappingByOriginal = mapping.parameterToCallArgumentMap return mapping.diagnostics } diff --git a/compiler/testData/codegen/box/controlStructures/parameterWithNameForFunctionType.kt b/compiler/testData/codegen/box/controlStructures/parameterWithNameForFunctionType.kt new file mode 100644 index 00000000000..3796119d725 --- /dev/null +++ b/compiler/testData/codegen/box/controlStructures/parameterWithNameForFunctionType.kt @@ -0,0 +1,8 @@ +fun test(a: T, b: T, operation: (x: T) -> T) { + operation(if (3 > 2) a else b) +} + +fun box(): String { + test(1, 1, { it }) + return "OK" +} \ No newline at end of file diff --git a/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index c6f13e89307..d5fd252dc3b 100644 --- a/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -4631,6 +4631,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes doTest(fileName); } + @TestMetadata("parameterWithNameForFunctionType.kt") + public void testParameterWithNameForFunctionType() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/controlStructures/parameterWithNameForFunctionType.kt"); + doTest(fileName); + } + @TestMetadata("quicksort.kt") public void testQuicksort() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/controlStructures/quicksort.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index d89900a2dda..b4309dd8d18 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -4631,6 +4631,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { doTest(fileName); } + @TestMetadata("parameterWithNameForFunctionType.kt") + public void testParameterWithNameForFunctionType() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/controlStructures/parameterWithNameForFunctionType.kt"); + doTest(fileName); + } + @TestMetadata("quicksort.kt") public void testQuicksort() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/controlStructures/quicksort.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 96fbe90a391..a83130a0531 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -4631,6 +4631,12 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes doTest(fileName); } + @TestMetadata("parameterWithNameForFunctionType.kt") + public void testParameterWithNameForFunctionType() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/controlStructures/parameterWithNameForFunctionType.kt"); + doTest(fileName); + } + @TestMetadata("quicksort.kt") public void testQuicksort() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/controlStructures/quicksort.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index 9bc6a5bb6ef..12e30b61877 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -5327,6 +5327,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { doTest(fileName); } + @TestMetadata("parameterWithNameForFunctionType.kt") + public void testParameterWithNameForFunctionType() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/controlStructures/parameterWithNameForFunctionType.kt"); + doTest(fileName); + } + @TestMetadata("quicksort.kt") public void testQuicksort() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/controlStructures/quicksort.kt");