Lift return out fix: do not suggest for labeled returns
This commit is contained in:
+3
-1
@@ -45,7 +45,9 @@ object BranchedFoldingUtils {
|
||||
|
||||
fun getFoldableBranchedReturn(branch: KtExpression?): KtReturnExpression? =
|
||||
(branch?.lastBlockStatementOrThis() as? KtReturnExpression)?.takeIf {
|
||||
it.returnedExpression != null && it.returnedExpression !is KtLambdaExpression
|
||||
it.returnedExpression != null &&
|
||||
it.returnedExpression !is KtLambdaExpression &&
|
||||
it.getTargetLabel() == null
|
||||
}
|
||||
|
||||
fun checkAssignmentsMatch(a1: KtBinaryExpression, a2: KtBinaryExpression): Boolean =
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// PROBLEM: none
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun test(arg: String?): Int {
|
||||
arg?.let {
|
||||
<caret>when (arg) {
|
||||
"" -> return 1
|
||||
else -> return@let 42
|
||||
}
|
||||
42
|
||||
}
|
||||
return 0
|
||||
}
|
||||
@@ -712,6 +712,12 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("localReturns.kt")
|
||||
public void testLocalReturns() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/liftOut/whenToReturn/localReturns.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("otherReturns.kt")
|
||||
public void testOtherReturns() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/liftOut/whenToReturn/otherReturns.kt");
|
||||
|
||||
Reference in New Issue
Block a user