Don't add double linenumber when return expression is absent (KT-18949)

#KT-18949 Fixed
This commit is contained in:
Nikolay Krasko
2017-07-15 16:21:51 +03:00
parent a41c9d2476
commit d282f14eac
5 changed files with 31 additions and 4 deletions
@@ -1613,11 +1613,12 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
// If it does not end with return we should return something
// because if we don't there can be VerifyError (specific cases with Nothing-typed expressions)
if (!endsWithReturn(expr)) {
markLineNumber(expr, true);
if (isLambdaVoidBody(expr, typeForExpression)) {
markLineNumber((KtFunctionLiteral) expr.getParent(), true);
}
else {
markLineNumber(expr, true);
}
if (typeForExpression.getSort() == Type.VOID) {
StackValue.none().put(returnType, v);
@@ -0,0 +1,19 @@
fun foo() {
bar {
nop()
baz()
}
}
inline fun bar(f: () -> Unit) {
nop()
f()
}
inline fun baz() {
nop()
}
fun nop() {}
// 2 20 21 3 4 25 26 5 27 6 9 10 11 14 15 17
@@ -209,6 +209,12 @@ public class LineNumberTestGenerated extends AbstractLineNumberTest {
doTestCustom(fileName);
}
@TestMetadata("inTheEndOfLambdaArgumentOfInlineCall.kt")
public void testInTheEndOfLambdaArgumentOfInlineCall() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/lineNumber/custom/inTheEndOfLambdaArgumentOfInlineCall.kt");
doTestCustom(fileName);
}
@TestMetadata("multilineFunctionCall.kt")
public void testMultilineFunctionCall() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/lineNumber/custom/multilineFunctionCall.kt");
@@ -5,4 +5,4 @@ fun main(args: Array<String>) {
}
// ADDITIONAL_BREAKPOINT: functionInLibrary.kt:public inline fun simpleFun()
// STEP_INTO: 4
// STEP_INTO: 5
@@ -2,7 +2,8 @@ LineBreakpoint created at soInlineCallInLastStatementInInlineFunctionArgumentDex
Run Java
Connected to the target VM
soInlineCallInLastStatementInInlineFunctionArgumentDex.kt:7
soInlineCallInLastStatementInInlineFunctionArgumentDex.kt:7
soInlineCallInLastStatementInInlineFunctionArgumentDex.kt:8
soInlineCallInLastStatementInInlineFunctionArgumentDex.kt:14
soInlineCallInLastStatementInInlineFunctionArgumentDex.kt:9
Disconnected from the target VM