ChangeFunctionSignatureFix: fix wrong result

#KT-32001 Fixed
This commit is contained in:
Dmitry Gridin
2019-06-19 15:59:40 +07:00
parent 85210d5db0
commit 22a73bc09d
7 changed files with 53 additions and 3 deletions
@@ -38,7 +38,7 @@ import org.jetbrains.kotlin.idea.refactoring.changeSignature.runChangeSignature
import org.jetbrains.kotlin.psi.KtCallElement
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.psi.ValueArgument
import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
import org.jetbrains.kotlin.resolve.calls.callUtil.getCall
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
@@ -71,7 +71,7 @@ abstract class ChangeFunctionSignatureFix(
}
companion object : KotlinSingleIntentionActionFactoryWithDelegate<KtCallElement, CallableDescriptor>() {
override fun getElementOfInterest(diagnostic: Diagnostic): KtCallElement? = diagnostic.psiElement.getNonStrictParentOfType()
override fun getElementOfInterest(diagnostic: Diagnostic): KtCallElement? = diagnostic.psiElement.getStrictParentOfType()
override fun extractFixData(element: KtCallElement, diagnostic: Diagnostic): CallableDescriptor? {
return DiagnosticFactory.cast(diagnostic, Errors.TOO_MANY_ARGUMENTS, Errors.NO_VALUE_FOR_PARAMETER).a
@@ -0,0 +1,10 @@
// "Add parameter to function 'called'" "true"
// WITH_RUNTIME
// DISABLE-ERRORS
// WITH_NEW_INFERENCE
fun caller() {
called(<caret>setOf(1, 2, 3))
}
fun called() {}
@@ -0,0 +1,10 @@
// "Add parameter to function 'called'" "true"
// WITH_RUNTIME
// DISABLE-ERRORS
// WITH_NEW_INFERENCE
fun caller() {
called(<caret>setOf(1, 2, 3))
}
fun called(of: Set<Int>) {}
@@ -0,0 +1,10 @@
// "Add parameter to function 'called'" "true"
// WITH_RUNTIME
// DISABLE-ERRORS
// !WITH_NEW_INFERENCE
fun caller() {
called(<caret>setOf(1, 2, 3))
}
fun called() {}
@@ -0,0 +1,10 @@
// "Add parameter to function 'called'" "true"
// WITH_RUNTIME
// DISABLE-ERRORS
// !WITH_NEW_INFERENCE
fun caller() {
called(<caret>setOf(1, 2, 3))
}
fun called(of: Set<Int>) {}
@@ -1,4 +1,4 @@
// "Change the signature of function 'doSmthWithChild'" "true"
// "Add parameter to function 'doSmthWithChild'" "true"
// DISABLE-ERRORS
// COMPILER_ARGUMENTS: -XXLanguage:+NewInference
@@ -1939,6 +1939,16 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
runTest("idea/testData/quickfix/changeSignature/addFunctionParameter.kt");
}
@TestMetadata("addFunctionParameter2.kt")
public void testAddFunctionParameter2() throws Exception {
runTest("idea/testData/quickfix/changeSignature/addFunctionParameter2.kt");
}
@TestMetadata("addFunctionParameter3.kt")
public void testAddFunctionParameter3() throws Exception {
runTest("idea/testData/quickfix/changeSignature/addFunctionParameter3.kt");
}
@TestMetadata("addFunctionParameterAndChangeTypes.kt")
public void testAddFunctionParameterAndChangeTypes() throws Exception {
runTest("idea/testData/quickfix/changeSignature/addFunctionParameterAndChangeTypes.kt");