KT-11275 Inconsistent behaviour when using lambda calls with function arguments without parens
#KT-11275 Fixed
This commit is contained in:
@@ -94,7 +94,7 @@ fun KtCallExpression.moveFunctionLiteralOutsideParentheses() {
|
||||
val dummyCall = KtPsiFactory(this).createExpressionByPattern("foo()$0:'{}'", expression) as KtCallExpression
|
||||
val functionLiteralArgument = dummyCall.lambdaArguments.single()
|
||||
this.add(functionLiteralArgument)
|
||||
if (argumentList.arguments.size > 1) {
|
||||
if (argumentList.arguments.size > 1 || calleeExpression is KtCallExpression /* we should not remove empty parenthesis when callee is a call too - it won't parse */) {
|
||||
argumentList.removeArgument(argument)
|
||||
}
|
||||
else {
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
fun bar() {
|
||||
foo { "one" } (<caret>{ "two" })
|
||||
}
|
||||
|
||||
fun foo(a: () -> String): (() -> String) -> Unit {
|
||||
return { }
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
fun bar() {
|
||||
foo { "one" } () { "two" }
|
||||
}
|
||||
|
||||
fun foo(a: () -> String): (() -> String) -> Unit {
|
||||
return { }
|
||||
}
|
||||
@@ -6777,6 +6777,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/moveLambdaOutsideParentheses/moveLambda6.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("noTwoConsequentLambdas.kt")
|
||||
public void testNoTwoConsequentLambdas() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/moveLambdaOutsideParentheses/noTwoConsequentLambdas.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/intentions/moveOutOfCompanion")
|
||||
|
||||
Reference in New Issue
Block a user