Generate line numbers for closing '}' in 'init {}' blocks (KT-12787)
This commit is contained in:
@@ -472,21 +472,38 @@ public abstract class MemberCodegen<T extends KtPureElement/* TODO: & KtDeclarat
|
||||
return clInit;
|
||||
}
|
||||
|
||||
private boolean nopSeparatorNeeded = false;
|
||||
|
||||
private void generateNopSeparatorIfNeeded(NotNullLazyValue<ExpressionCodegen> codegen) {
|
||||
if (nopSeparatorNeeded) {
|
||||
nopSeparatorNeeded = false;
|
||||
codegen.invoke().v.nop();
|
||||
}
|
||||
}
|
||||
|
||||
protected void generateInitializers(@NotNull Function0<ExpressionCodegen> createCodegen) {
|
||||
NotNullLazyValue<ExpressionCodegen> codegen = LockBasedStorageManager.NO_LOCKS.createLazyValue(createCodegen);
|
||||
|
||||
for (KtDeclaration declaration : ((KtDeclarationContainer) element).getDeclarations()) {
|
||||
if (declaration instanceof KtProperty) {
|
||||
if (shouldInitializeProperty((KtProperty) declaration)) {
|
||||
generateNopSeparatorIfNeeded(codegen);
|
||||
initializeProperty(codegen.invoke(), (KtProperty) declaration);
|
||||
}
|
||||
}
|
||||
else if (declaration instanceof KtDestructuringDeclaration) {
|
||||
generateNopSeparatorIfNeeded(codegen);
|
||||
codegen.invoke().initializeDestructuringDeclaration((KtDestructuringDeclaration) declaration, true);
|
||||
}
|
||||
else if (declaration instanceof KtAnonymousInitializer) {
|
||||
KtExpression body = ((KtAnonymousInitializer) declaration).getBody();
|
||||
if (body != null) {
|
||||
codegen.invoke().gen(body, Type.VOID_TYPE);
|
||||
generateNopSeparatorIfNeeded(codegen);
|
||||
|
||||
ExpressionCodegen expressionCodegen = codegen.invoke();
|
||||
expressionCodegen.gen(body, Type.VOID_TYPE);
|
||||
expressionCodegen.markLineNumber(declaration, true);
|
||||
nopSeparatorNeeded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user