Fix source element for JsSwitch generated from 'when'

Before this change we set JsSwitch source to subject's JsExpression.
We ignore these types of source elements during:
1. js ast serialization (see 'JsAstSerializer.extractLocation');
2. source map generation (see 'SourceMapBuilderConsumer.addMapping').

However we might add indent during source generation
(see 'JsToStringGenerationVisitor.pushSourceInfo').

That seemingly broken 'testEnumEntryRemoved' in
'IncrementalJsCompilerRunnerTestGenerated.ClassHierarchyAffected',
because deserialized ast during incremental build would not
have source element at all (JsExpression was ignored), but ast
during rebuild would have JsExpression source element.
This commit is contained in:
Alexey Tsvetkov
2018-04-08 00:53:28 +03:00
parent b0e8c85e88
commit 87558873b5
2 changed files with 2 additions and 2 deletions
@@ -163,7 +163,7 @@ private constructor(private val whenExpression: KtWhenExpression, context: Trans
lastEntry.statements += JsBreak().apply { source = entry }
members
}
Pair(JsSwitch(subjectSupplier(), switchEntries).apply { source = expression }, nextIndex)
Pair(JsSwitch(subjectSupplier(), switchEntries).apply { source = whenExpression }, nextIndex)
}
else {
null
@@ -18,4 +18,4 @@ fun box(x: Int) {
)
}
// LINES: 19 4 4 3 4 6 9 9 6 11 13 13 11 16 16 3 2
// LINES: 19 4 4 3 3 4 6 9 9 6 11 13 13 11 16 16 3 2