Fixed critical bug in DeprecatedSymbolUsageFix

This commit is contained in:
Valentin Kipyatkov
2015-05-28 11:26:15 +03:00
parent 68eca8bc00
commit d415b0c74d
4 changed files with 28 additions and 1 deletions
@@ -132,7 +132,8 @@ public abstract class DeprecatedSymbolUsageFixBase(
val descriptor = resolvedCall.getResultingDescriptor()
val callExpression = resolvedCall.getCall().getCallElement() as JetExpression
val qualifiedExpression = callExpression.getParent() as? JetQualifiedExpression
val parent = callExpression.getParent()
val qualifiedExpression = if (parent is JetQualifiedExpression && callExpression == parent.getSelectorExpression()) parent else null
val expressionToBeReplaced = qualifiedExpression ?: callExpression
val commentSaver = CommentSaver(expressionToBeReplaced)
@@ -0,0 +1,10 @@
// "Replace with 'newFun()'" "true"
@deprecated("", ReplaceWith("newFun()"))
fun oldFun(): String = ""
fun newFun(): String = ""
fun foo() {
val value = <caret>oldFun().length()
}
@@ -0,0 +1,10 @@
// "Replace with 'newFun()'" "true"
@deprecated("", ReplaceWith("newFun()"))
fun oldFun(): String = ""
fun newFun(): String = ""
fun foo() {
val value = <caret>newFun().length()
}
@@ -2872,6 +2872,12 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/quickfix/deprecatedSymbolUsage"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), true);
}
@TestMetadata("callChainBug.kt")
public void testCallChainBug() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/deprecatedSymbolUsage/callChainBug.kt");
doTest(fileName);
}
@TestMetadata("callWithError.kt")
public void testCallWithError() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/deprecatedSymbolUsage/callWithError.kt");