diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddFunctionParametersFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddFunctionParametersFix.kt index 5807027ac52..8fb8e94ec6b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddFunctionParametersFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddFunctionParametersFix.kt @@ -146,7 +146,8 @@ class AddFunctionParametersFix( argument, validator ) - descriptor.addParameter(argumentIndex, parameterInfo) + val receiverCount = if (descriptor.receiver != null) 1 else 0 + descriptor.addParameter(argumentIndex + receiverCount, parameterInfo) return } diff --git a/idea/testData/quickfix/changeSignature/addExtensionFunctionParameterForTypeMismatch.kt b/idea/testData/quickfix/changeSignature/addExtensionFunctionParameterForTypeMismatch.kt new file mode 100644 index 00000000000..4aee89fb796 --- /dev/null +++ b/idea/testData/quickfix/changeSignature/addExtensionFunctionParameterForTypeMismatch.kt @@ -0,0 +1,8 @@ +// "Add 2nd parameter to function 'bar'" "true" +interface Foo + +private fun Foo.bar(s: String, i: Int) {} + +fun test(foo: Foo, b: Boolean) { + foo.bar("", b, 0) +} \ No newline at end of file diff --git a/idea/testData/quickfix/changeSignature/addExtensionFunctionParameterForTypeMismatch.kt.after b/idea/testData/quickfix/changeSignature/addExtensionFunctionParameterForTypeMismatch.kt.after new file mode 100644 index 00000000000..1b948222593 --- /dev/null +++ b/idea/testData/quickfix/changeSignature/addExtensionFunctionParameterForTypeMismatch.kt.after @@ -0,0 +1,8 @@ +// "Add 2nd parameter to function 'bar'" "true" +interface Foo + +private fun Foo.bar(s: String, b: Boolean, i: Int) {} + +fun test(foo: Foo, b: Boolean) { + foo.bar("", b, 0) +} \ No newline at end of file diff --git a/idea/testData/quickfix/changeSignature/addFunctionParameterForTypeMismatch1.kt b/idea/testData/quickfix/changeSignature/addFunctionParameterForTypeMismatch1.kt index b0d530d4179..dbe7bd03f56 100644 --- a/idea/testData/quickfix/changeSignature/addFunctionParameterForTypeMismatch1.kt +++ b/idea/testData/quickfix/changeSignature/addFunctionParameterForTypeMismatch1.kt @@ -1,5 +1,4 @@ // "Add 1st parameter to function 'foo'" "true" -// DISABLE-ERRORS fun foo(i1: Int, i2: Int, i3: Int, i4: Int) { } diff --git a/idea/testData/quickfix/changeSignature/addFunctionParameterForTypeMismatch1.kt.after b/idea/testData/quickfix/changeSignature/addFunctionParameterForTypeMismatch1.kt.after index 92ee6ee28e4..a34e70071ff 100644 --- a/idea/testData/quickfix/changeSignature/addFunctionParameterForTypeMismatch1.kt.after +++ b/idea/testData/quickfix/changeSignature/addFunctionParameterForTypeMismatch1.kt.after @@ -1,5 +1,4 @@ // "Add 1st parameter to function 'foo'" "true" -// DISABLE-ERRORS fun foo(i11: String, i1: Int, i2: Int, i3: Int, i4: Int) { } diff --git a/idea/testData/quickfix/changeSignature/addFunctionParameterForTypeMismatch2.kt b/idea/testData/quickfix/changeSignature/addFunctionParameterForTypeMismatch2.kt index d3561715121..7682eebc7b7 100644 --- a/idea/testData/quickfix/changeSignature/addFunctionParameterForTypeMismatch2.kt +++ b/idea/testData/quickfix/changeSignature/addFunctionParameterForTypeMismatch2.kt @@ -1,5 +1,4 @@ // "Add 2nd parameter to function 'foo'" "true" -// DISABLE-ERRORS fun foo(i1: Int, i2: Int, i3: Int, i4: Int) { } diff --git a/idea/testData/quickfix/changeSignature/addFunctionParameterForTypeMismatch2.kt.after b/idea/testData/quickfix/changeSignature/addFunctionParameterForTypeMismatch2.kt.after index 9c7920ae268..67140a712ca 100644 --- a/idea/testData/quickfix/changeSignature/addFunctionParameterForTypeMismatch2.kt.after +++ b/idea/testData/quickfix/changeSignature/addFunctionParameterForTypeMismatch2.kt.after @@ -1,5 +1,4 @@ // "Add 2nd parameter to function 'foo'" "true" -// DISABLE-ERRORS fun foo(i1: Int, i21: String, i2: Int, i3: Int, i4: Int) { } diff --git a/idea/testData/quickfix/changeSignature/addFunctionParameterForTypeMismatch3.kt b/idea/testData/quickfix/changeSignature/addFunctionParameterForTypeMismatch3.kt index 196d9fe4aa5..f5504f477f8 100644 --- a/idea/testData/quickfix/changeSignature/addFunctionParameterForTypeMismatch3.kt +++ b/idea/testData/quickfix/changeSignature/addFunctionParameterForTypeMismatch3.kt @@ -1,5 +1,4 @@ // "Add 3rd parameter to function 'foo'" "true" -// DISABLE-ERRORS fun foo(i1: Int, i2: Int, i3: Int, i4: Int) { } diff --git a/idea/testData/quickfix/changeSignature/addFunctionParameterForTypeMismatch3.kt.after b/idea/testData/quickfix/changeSignature/addFunctionParameterForTypeMismatch3.kt.after index f9253f50376..31130e6b3d7 100644 --- a/idea/testData/quickfix/changeSignature/addFunctionParameterForTypeMismatch3.kt.after +++ b/idea/testData/quickfix/changeSignature/addFunctionParameterForTypeMismatch3.kt.after @@ -1,5 +1,4 @@ // "Add 3rd parameter to function 'foo'" "true" -// DISABLE-ERRORS fun foo(i1: Int, i2: Int, i31: String, i3: Int, i4: Int) { } diff --git a/idea/testData/quickfix/changeSignature/addFunctionParameterForTypeMismatch4.kt b/idea/testData/quickfix/changeSignature/addFunctionParameterForTypeMismatch4.kt index dfa9286f3b0..577f60bc644 100644 --- a/idea/testData/quickfix/changeSignature/addFunctionParameterForTypeMismatch4.kt +++ b/idea/testData/quickfix/changeSignature/addFunctionParameterForTypeMismatch4.kt @@ -1,5 +1,4 @@ // "Add 4th parameter to function 'foo'" "true" -// DISABLE-ERRORS fun foo(i1: Int, i2: Int, i3: Int, i4: Int) { } diff --git a/idea/testData/quickfix/changeSignature/addFunctionParameterForTypeMismatch4.kt.after b/idea/testData/quickfix/changeSignature/addFunctionParameterForTypeMismatch4.kt.after index 1b634f2f21e..1e956c2bef9 100644 --- a/idea/testData/quickfix/changeSignature/addFunctionParameterForTypeMismatch4.kt.after +++ b/idea/testData/quickfix/changeSignature/addFunctionParameterForTypeMismatch4.kt.after @@ -1,5 +1,4 @@ // "Add 4th parameter to function 'foo'" "true" -// DISABLE-ERRORS fun foo(i1: Int, i2: Int, i3: Int, i41: String, i4: Int) { } diff --git a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java index e651eba8be6..dfa48502dd2 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java @@ -2306,6 +2306,11 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest { runTest("idea/testData/quickfix/changeSignature/addEnumConstructorParameter5.kt"); } + @TestMetadata("addExtensionFunctionParameterForTypeMismatch.kt") + public void testAddExtensionFunctionParameterForTypeMismatch() throws Exception { + runTest("idea/testData/quickfix/changeSignature/addExtensionFunctionParameterForTypeMismatch.kt"); + } + @TestMetadata("addForItParameter.kt") public void testAddForItParameter() throws Exception { runTest("idea/testData/quickfix/changeSignature/addForItParameter.kt");