Replace deprecated symbol usage: move named lambda argument outside parentheses

#KT-31523 Fixed
This commit is contained in:
Toshiaki Kameyama
2019-10-24 10:11:48 +09:00
committed by klunnii
parent d9cf4ee732
commit c09c0468d4
4 changed files with 29 additions and 1 deletions
@@ -621,7 +621,6 @@ class CodeInliner<TCallElement : KtElement>(
val argument = expr.parent as? KtValueArgument ?: return
if (argument is KtLambdaArgument) return
if (argument.isNamed()) return
val argumentList = argument.parent as? KtValueArgumentList ?: return
if (argument != argumentList.arguments.last()) return
val callExpression = argumentList.parent as? KtCallExpression ?: return
@@ -0,0 +1,12 @@
// "Replace with 'newFun(p1, null, p2)'" "true"
interface I {
@Deprecated("", ReplaceWith("newFun(p1, null, p2)"))
fun oldFun(p1: String, p2: () -> Boolean)
fun newFun(p1: String, p2: String?, p3: () -> Boolean)
}
fun foo(i: I) {
i.<caret>oldFun(p1 = "a") { true }
}
@@ -0,0 +1,12 @@
// "Replace with 'newFun(p1, null, p2)'" "true"
interface I {
@Deprecated("", ReplaceWith("newFun(p1, null, p2)"))
fun oldFun(p1: String, p2: () -> Boolean)
fun newFun(p1: String, p2: String?, p3: () -> Boolean)
}
fun foo(i: I) {
i.<caret>newFun(p1 = "a", p2 = null) { true }
}
@@ -6923,6 +6923,11 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
public void testKeepOutside() throws Exception {
runTest("idea/testData/quickfix/deprecatedSymbolUsage/functionLiteralArguments/keepOutside.kt");
}
@TestMetadata("keepOutsideWithNamedArgument.kt")
public void testKeepOutsideWithNamedArgument() throws Exception {
runTest("idea/testData/quickfix/deprecatedSymbolUsage/functionLiteralArguments/keepOutsideWithNamedArgument.kt");
}
}
@TestMetadata("idea/testData/quickfix/deprecatedSymbolUsage/imports")