Change Signature: Use correct index in getOriginalParameter()
#KT-18642 Fixed #KT-18606 Fixed
This commit is contained in:
+1
-3
@@ -191,9 +191,7 @@ class KotlinParameterInfo @JvmOverloads constructor (
|
||||
}
|
||||
|
||||
private fun getOriginalParameter(inheritedCallable: KotlinCallableDefinitionUsage<*>): KtParameter? {
|
||||
val currentFunction = inheritedCallable.declaration as? KtFunction ?: return null
|
||||
val originalParameterIndex = if (currentFunction.receiverTypeReference == null) originalIndex else originalIndex - 1
|
||||
return currentFunction.valueParameters.getOrNull(originalParameterIndex)
|
||||
return (inheritedCallable.declaration as? KtFunction)?.valueParameters?.getOrNull(originalIndex)
|
||||
}
|
||||
|
||||
private fun buildNewParameter(inheritedCallable: KotlinCallableDefinitionUsage<*>, parameterIndex: Int): KtParameter {
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
fun <caret>Int.f1(vararg i: Int){}
|
||||
@@ -0,0 +1 @@
|
||||
fun <caret>f1(i1: Int, vararg i: Int){}
|
||||
@@ -0,0 +1,4 @@
|
||||
// "Remove parameter 'a'" "true"
|
||||
|
||||
fun String.foo(<caret>a:Int = 0, b: Int) {
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// "Remove parameter 'a'" "true"
|
||||
|
||||
fun String.foo(b: Int) {
|
||||
}
|
||||
@@ -5725,6 +5725,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/convertReceiverToParameter/validOverload.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("varargs.kt")
|
||||
public void testVarargs() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/convertReceiverToParameter/varargs.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/intentions/convertReferenceToLambda")
|
||||
|
||||
@@ -1172,6 +1172,12 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("removeParameterFromExtension.kt")
|
||||
public void testRemoveParameterFromExtension() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/changeSignature/removeParameterFromExtension.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("removeParameterFromFakeOverride.kt")
|
||||
public void testRemoveParameterFromFakeOverride() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/changeSignature/removeParameterFromFakeOverride.kt");
|
||||
|
||||
Reference in New Issue
Block a user