[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:
committed by
max-kammerer
parent
fc7d667282
commit
7ec4c9990a
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user