Convert receiver to parameter: place value argument list after type argument list

#KT-41499 Fixed
This commit is contained in:
Toshiaki Kameyama
2020-09-08 11:18:24 +09:00
committed by Dmitry Gridin
parent b1629cc5f4
commit f9f8fd055b
4 changed files with 18 additions and 2 deletions
@@ -77,8 +77,9 @@ class KotlinFunctionCallUsage(
changeNameIfNeeded(changeInfo, element)
if (element.valueArgumentList == null && changeInfo.isParameterSetOrOrderChanged && element.lambdaArguments.isNotEmpty()) {
element.calleeExpression?.let {
element.addAfter(KtPsiFactory(element).createCallArguments("()"), it)
val anchor = element.typeArgumentList ?: element.calleeExpression
if (anchor != null) {
element.addAfter(KtPsiFactory(element).createCallArguments("()"), anchor)
}
}
if (element.valueArgumentList != null) {
@@ -0,0 +1,5 @@
fun <T> <caret>Any.foo(callback: () -> Unit) {}
fun bar() {
"".foo<Int> {}
}
@@ -0,0 +1,5 @@
fun <T> foo(any: Any, callback: () -> Unit) {}
fun bar() {
foo<Int>("") {}
}
@@ -6472,6 +6472,11 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
runTest("idea/testData/intentions/convertReceiverToParameter/usedInAnonymousObject.kt");
}
@TestMetadata("usedWithTypeArgumentAndLambdaArgument.kt")
public void testUsedWithTypeArgumentAndLambdaArgument() throws Exception {
runTest("idea/testData/intentions/convertReceiverToParameter/usedWithTypeArgumentAndLambdaArgument.kt");
}
@TestMetadata("validOverload.kt")
public void testValidOverload() throws Exception {
runTest("idea/testData/intentions/convertReceiverToParameter/validOverload.kt");