Fixed critical bug in DeprecatedSymbolUsageFix
This commit is contained in:
@@ -132,7 +132,8 @@ public abstract class DeprecatedSymbolUsageFixBase(
|
|||||||
val descriptor = resolvedCall.getResultingDescriptor()
|
val descriptor = resolvedCall.getResultingDescriptor()
|
||||||
|
|
||||||
val callExpression = resolvedCall.getCall().getCallElement() as JetExpression
|
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 expressionToBeReplaced = qualifiedExpression ?: callExpression
|
||||||
|
|
||||||
val commentSaver = CommentSaver(expressionToBeReplaced)
|
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);
|
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")
|
@TestMetadata("callWithError.kt")
|
||||||
public void testCallWithError() throws Exception {
|
public void testCallWithError() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/deprecatedSymbolUsage/callWithError.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/deprecatedSymbolUsage/callWithError.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user