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:
Yan Zhulanow
2019-07-16 19:44:59 +09:00
parent bebc8974b2
commit 076166c22f
7 changed files with 29 additions and 6 deletions
@@ -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;
}
}
}
}