refactor(compiler-cli): avoid superfluous parenthesis around statements (#33514)

Previously, due to a bug a `Context` with `isStatement: false` could be
returned in places where a `Context` with `isStatement: true` was
requested. As a result, some statements would be unnecessarily wrapped
in parenthesis.

This commit fixes the bug in `Context#withStatementMode` to always
return a `Context` with the correct `isStatement` value. Note that this
does not have any impact on the generated code other than avoiding some
superfluous parenthesis on certain statements.

PR Close #33514
This commit is contained in:
George Kalpakas
2019-10-31 01:09:38 +02:00
committed by Kara Erickson
parent 4c706086a7
commit 1c1240c21a
4 changed files with 30 additions and 30 deletions

View File

@ -18,7 +18,7 @@ export class Context {
get withExpressionMode(): Context { return this.isStatement ? new Context(false) : this; }
get withStatementMode(): Context { return this.isStatement ? new Context(true) : this; }
get withStatementMode(): Context { return !this.isStatement ? new Context(true) : this; }
}
const BINARY_OPERATORS = new Map<BinaryOperator, ts.BinaryOperator>([