Skip to content

Commit 0d476f8

Browse files
committed
skip final alloc in any terminating scenario
1 parent 53e0787 commit 0d476f8

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/compiler.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1111,8 +1111,7 @@ export class Compiler extends DiagnosticEmitter {
11111111
assert(instance.is(CommonFlags.INSTANCE));
11121112
let classInstance = assert(instance.parent); assert(classInstance.kind == ElementKind.CLASS);
11131113

1114-
// implicitly return `this` if the constructor doesn't always return on its own
1115-
if (!flow.is(FlowFlags.RETURNS)) {
1114+
if (!flow.isAny(FlowFlags.ANY_TERMINATING)) {
11161115

11171116
// if `this` wasn't accessed before, allocate if necessary and initialize `this`
11181117
if (!flow.is(FlowFlags.ALLOCATES)) {
@@ -1133,6 +1132,8 @@ export class Compiler extends DiagnosticEmitter {
11331132
);
11341133
this.makeFieldInitialization(<Class>classInstance, stmts);
11351134
}
1135+
1136+
// implicitly return `this`
11361137
stmts.push(
11371138
module.createGetLocal(0, nativeSizeType)
11381139
);

0 commit comments

Comments
 (0)