Debugger: Generate line numbers for class initializers with a number on the 'init' keyword (KT-16277)
Debugger tests not absent as they use the bootstrap version of kotlinc. Obviously, this change is not present in it yet.
This commit is contained in:
@@ -1473,7 +1473,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
markLineNumber(element, false);
|
||||
}
|
||||
|
||||
public void markLineNumber(@NotNull KtElement statement, boolean markEndOffset) {
|
||||
public void markLineNumber(@NotNull PsiElement statement, boolean markEndOffset) {
|
||||
if (!shouldMarkLineNumbers) return;
|
||||
|
||||
Integer lineNumber = CodegenUtil.getLineNumberForElement(statement, markEndOffset);
|
||||
|
||||
@@ -507,9 +507,18 @@ public abstract class MemberCodegen<T extends KtPureElement/* TODO: & KtDeclarat
|
||||
if (i == declarations.size() - 1 && this instanceof ScriptCodegen) {
|
||||
bodyExpressionType = expressionCodegen.expressionType(body);
|
||||
}
|
||||
|
||||
if (declaration instanceof KtClassInitializer) {
|
||||
KtClassInitializer classInitializer = (KtClassInitializer) declaration;
|
||||
expressionCodegen.markLineNumber(classInitializer.getInitKeyword(), true);
|
||||
expressionCodegen.v.nop();
|
||||
}
|
||||
|
||||
expressionCodegen.gen(body, bodyExpressionType);
|
||||
expressionCodegen.markLineNumber(declaration, true);
|
||||
nopSeparatorNeeded = true;
|
||||
if (declaration instanceof KtClassInitializer) {
|
||||
expressionCodegen.markLineNumber(declaration, true);
|
||||
nopSeparatorNeeded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+13
-1
@@ -28,7 +28,19 @@ class Boo {
|
||||
}
|
||||
}
|
||||
|
||||
class Zoo {
|
||||
init { val a = 5 }
|
||||
|
||||
init { val b = 6 }
|
||||
|
||||
init {
|
||||
val c = 7
|
||||
}
|
||||
|
||||
init { val d = 8 }
|
||||
}
|
||||
|
||||
fun x() = ""
|
||||
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// 2 2 1 5 6 9 11 12 15 16 24 19 21 22 24 27 28 31
|
||||
// 2 2 1 4 5 6 9 10 11 12 14 15 16 24 19 20 21 22 24 26 27 28 31 32 34 36 37 38 40 43
|
||||
@@ -15,4 +15,4 @@ fun main() {
|
||||
Foo()
|
||||
}
|
||||
|
||||
// STEP_OVER: 5
|
||||
// STEP_OVER: 6
|
||||
@@ -3,6 +3,7 @@ Run Java
|
||||
Connected to the target VM
|
||||
initBlocks.kt:6
|
||||
initBlocks.kt:7
|
||||
initBlocks.kt:9
|
||||
initBlocks.kt:10
|
||||
initBlocks.kt:11
|
||||
initBlocks.kt:15
|
||||
|
||||
+1
-1
@@ -13,4 +13,4 @@ class A {
|
||||
}
|
||||
|
||||
// SKIP_CONSTRUCTORS: false
|
||||
// STEP_INTO: 3
|
||||
// STEP_INTO: 4
|
||||
|
||||
+1
@@ -3,6 +3,7 @@ Run Java
|
||||
Connected to the target VM
|
||||
doNotSkipConstructors.kt:5
|
||||
doNotSkipConstructors.kt:9
|
||||
doNotSkipConstructors.kt:10
|
||||
doNotSkipConstructors.kt:11
|
||||
doNotSkipConstructors.kt:12
|
||||
Disconnected from the target VM
|
||||
|
||||
Reference in New Issue
Block a user