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

@ -167,7 +167,7 @@ runInEachFileSystem(os => {
expect(jsContents).toContain('factory: function Service_Factory(t) { var r = null; if (t) {');
expect(jsContents).toContain('return new (t || Service)(i0.ɵɵinject(Dep));');
expect(jsContents)
.toContain('(r = (function (dep) { return new Service(dep); })(i0.ɵɵinject(Dep)));');
.toContain('r = (function (dep) { return new Service(dep); })(i0.ɵɵinject(Dep));');
expect(jsContents).toContain('return r; }, providedIn: \'root\' });');
expect(jsContents).not.toContain('__decorate');
const dtsContents = env.getContents('test.d.ts');