Lift return out: do not suggest for lambda in return #KT-18711 Fixed
This commit is contained in:
+3
-1
@@ -43,7 +43,9 @@ object BranchedFoldingUtils {
|
||||
}
|
||||
|
||||
fun getFoldableBranchedReturn(branch: KtExpression?): KtReturnExpression? =
|
||||
(branch?.lastBlockStatementOrThis() as? KtReturnExpression)?.takeIf { it.returnedExpression != null }
|
||||
(branch?.lastBlockStatementOrThis() as? KtReturnExpression)?.takeIf {
|
||||
it.returnedExpression != null && it.returnedExpression !is KtLambdaExpression
|
||||
}
|
||||
|
||||
fun checkAssignmentsMatch(a1: KtBinaryExpression, a2: KtBinaryExpression): Boolean =
|
||||
a1.left?.text == a2.left?.text && a1.operationToken == a2.operationToken
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
// PROBLEM: none
|
||||
|
||||
fun foo(x: Boolean): (Int) -> String {
|
||||
<caret>when (x) {
|
||||
true -> return { it.toString() }
|
||||
else -> return { "42" }
|
||||
}
|
||||
}
|
||||
@@ -648,6 +648,12 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/liftOut/whenToReturn/whenThrowOnly.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("whenWithLambda.kt")
|
||||
public void testWhenWithLambda() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/liftOut/whenToReturn/whenWithLambda.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user