From 78493395c34b5f501a13ba1c6697f7f6cf16697f Mon Sep 17 00:00:00 2001 From: cketti Date: Thu, 3 Sep 2020 19:45:32 +0200 Subject: [PATCH] Don't mark signature as inapplicable when argument is empty/incomplete This will improve the usability when using named arguments where incomplete arguments can't be mapped to a parameter simply by position. ^KT-24172 Fixed --- .../KotlinFunctionParameterInfoHandler.kt | 33 +++++++++++++++++-- .../functionCall/NamedParameter3.kt | 10 ++++++ .../parameterInfo/functionCall/TooManyArgs.kt | 1 + .../functionCall/TooManyArgs2.kt | 8 +++++ .../functionCall/TrailingComma.kt | 10 ++++++ .../functionCall/TwoSmartCasts.kt | 1 + .../ParameterInfoTestGenerated.java | 15 +++++++++ 7 files changed, 75 insertions(+), 3 deletions(-) create mode 100644 idea/testData/parameterInfo/functionCall/NamedParameter3.kt create mode 100644 idea/testData/parameterInfo/functionCall/TooManyArgs2.kt create mode 100644 idea/testData/parameterInfo/functionCall/TrailingComma.kt diff --git a/idea/src/org/jetbrains/kotlin/idea/parameterInfo/KotlinFunctionParameterInfoHandler.kt b/idea/src/org/jetbrains/kotlin/idea/parameterInfo/KotlinFunctionParameterInfoHandler.kt index c0a02ce642f..b86462cd698 100644 --- a/idea/src/org/jetbrains/kotlin/idea/parameterInfo/KotlinFunctionParameterInfoHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/parameterInfo/KotlinFunctionParameterInfoHandler.kt @@ -519,14 +519,41 @@ abstract class KotlinParameterInfoWithCallHandlerBase) + } +} +/* +Text: ([y: Boolean], [x: Int]), Disabled: false, Strikeout: false, Green: true +*/ \ No newline at end of file diff --git a/idea/testData/parameterInfo/functionCall/TooManyArgs.kt b/idea/testData/parameterInfo/functionCall/TooManyArgs.kt index 78727df3b12..b94d7ecf520 100644 --- a/idea/testData/parameterInfo/functionCall/TooManyArgs.kt +++ b/idea/testData/parameterInfo/functionCall/TooManyArgs.kt @@ -1,3 +1,4 @@ +// COMPILER_ARGUMENTS: -XXLanguage:-TrailingCommas open class A(x: Int) { fun m(x: Int, y: Boolean) = 2 diff --git a/idea/testData/parameterInfo/functionCall/TooManyArgs2.kt b/idea/testData/parameterInfo/functionCall/TooManyArgs2.kt new file mode 100644 index 00000000000..2b0692e5d97 --- /dev/null +++ b/idea/testData/parameterInfo/functionCall/TooManyArgs2.kt @@ -0,0 +1,8 @@ +open class A(x: Int) { + fun m(x: Int, y: Int) = 2 + + fun d(x: Int) { + m(1, 2, 3) + } +} +//Text: (x: Int, y: Int), Disabled: true, Strikeout: false, Green: true \ No newline at end of file diff --git a/idea/testData/parameterInfo/functionCall/TrailingComma.kt b/idea/testData/parameterInfo/functionCall/TrailingComma.kt new file mode 100644 index 00000000000..9d7d8fb76ef --- /dev/null +++ b/idea/testData/parameterInfo/functionCall/TrailingComma.kt @@ -0,0 +1,10 @@ +open class A(x: Int) { + fun m(x: Int, y: Boolean) = 1 + + fun d(x: Int) { + m(1, false,) + } +} +/* +Text: (x: Int, y: Boolean), Disabled: false, Strikeout: false, Green: true +*/ \ No newline at end of file diff --git a/idea/testData/parameterInfo/functionCall/TwoSmartCasts.kt b/idea/testData/parameterInfo/functionCall/TwoSmartCasts.kt index 99c79e49de8..5138f499a9f 100644 --- a/idea/testData/parameterInfo/functionCall/TwoSmartCasts.kt +++ b/idea/testData/parameterInfo/functionCall/TwoSmartCasts.kt @@ -1,3 +1,4 @@ +// COMPILER_ARGUMENTS: -XXLanguage:-TrailingCommas // See KT-14484 class C { diff --git a/idea/tests/org/jetbrains/kotlin/idea/parameterInfo/ParameterInfoTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/parameterInfo/ParameterInfoTestGenerated.java index 747b8a461be..74e73cf4176 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/parameterInfo/ParameterInfoTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/parameterInfo/ParameterInfoTestGenerated.java @@ -221,6 +221,11 @@ public class ParameterInfoTestGenerated extends AbstractParameterInfoTest { runTest("idea/testData/parameterInfo/functionCall/NamedParameter2.kt"); } + @TestMetadata("NamedParameter3.kt") + public void testNamedParameter3() throws Exception { + runTest("idea/testData/parameterInfo/functionCall/NamedParameter3.kt"); + } + @TestMetadata("NoAnnotations.kt") public void testNoAnnotations() throws Exception { runTest("idea/testData/parameterInfo/functionCall/NoAnnotations.kt"); @@ -346,6 +351,16 @@ public class ParameterInfoTestGenerated extends AbstractParameterInfoTest { runTest("idea/testData/parameterInfo/functionCall/TooManyArgs.kt"); } + @TestMetadata("TooManyArgs2.kt") + public void testTooManyArgs2() throws Exception { + runTest("idea/testData/parameterInfo/functionCall/TooManyArgs2.kt"); + } + + @TestMetadata("TrailingComma.kt") + public void testTrailingComma() throws Exception { + runTest("idea/testData/parameterInfo/functionCall/TrailingComma.kt"); + } + @TestMetadata("TwoFunctions.kt") public void testTwoFunctions() throws Exception { runTest("idea/testData/parameterInfo/functionCall/TwoFunctions.kt");