[JVM] Improve debug step behavior around lambdas.

- Add tests to clarify problematic behavior
- Avoid line numbers on return instructions of lambdas without explicit returns
This commit is contained in:
Kristoffer Andersen
2020-03-31 14:05:59 +02:00
committed by max-kammerer
parent fc7d667282
commit 7ec4c9990a
7 changed files with 123 additions and 8 deletions
@@ -1759,8 +1759,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
if (!endsWithReturn(expr)) {
if (isLambdaVoidBody(expr, typeForExpression)) {
markLineNumber((KtFunctionLiteral) expr.getParent(), true);
}
else {
} else if (!isLambdaBody(expr)){
markLineNumber(expr, true);
}
@@ -1782,13 +1781,14 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
}
private static boolean isLambdaVoidBody(@NotNull KtElement bodyExpression, @NotNull Type returnType) {
return isLambdaBody(bodyExpression) && Type.VOID_TYPE.equals(returnType);
}
private static boolean isLambdaBody(@NotNull KtElement bodyExpression) {
if (bodyExpression instanceof KtBlockExpression) {
PsiElement parent = bodyExpression.getParent();
if (parent instanceof KtFunctionLiteral) {
return Type.VOID_TYPE.equals(returnType);
}
return parent instanceof KtFunctionLiteral;
}
return false;
}