refactor: fix closure compatibility errors in compiler (#62493)

The static fields may be part of advanced compilations where the
receiver would change as part of the static field collapsing
optimization.

The optimization requires us to use the explicit class name, over
`this` that would change to e.g. `globalThis`.

PR Close #62493
This commit is contained in:
Paul Gschwendtner
2025-07-07 06:20:59 +00:00
committed by Pawel Kozlowski
parent 434508fd04
commit 20724e64d9
2 changed files with 5 additions and 5 deletions
@@ -2250,12 +2250,12 @@ class Scope {
const firstDecl = varMap.get(v.name)!;
tcb.oobRecorder.duplicateTemplateVar(tcb.id, v, firstDecl);
}
this.registerVariable(scope, v, new TcbTemplateVariableOp(tcb, scope, scopedNode, v));
Scope.registerVariable(scope, v, new TcbTemplateVariableOp(tcb, scope, scopedNode, v));
}
} else if (scopedNode instanceof TmplAstIfBlockBranch) {
const {expression, expressionAlias} = scopedNode;
if (expression !== null && expressionAlias !== null) {
this.registerVariable(
Scope.registerVariable(
scope,
expressionAlias,
new TcbBlockVariableOp(
@@ -2281,7 +2281,7 @@ class Scope {
const type = ts.factory.createKeywordTypeNode(
this.forLoopContextVariableTypes.get(variable.value)!,
);
this.registerVariable(
Scope.registerVariable(
scope,
variable,
new TcbBlockImplicitVariableOp(tcb, scope, type, variable),
@@ -226,7 +226,7 @@ export class OpList<OpT extends Op<OpT>> {
let prev: OpT = oldPrev!;
for (const newOp of newOps) {
this.assertIsUnowned(newOp);
OpList.assertIsUnowned(newOp);
newOp.debugListId = listId;
prev!.next = newOp;
@@ -276,7 +276,7 @@ export class OpList<OpT extends Op<OpT>> {
static insertBefore<OpT extends Op<OpT>>(op: OpT | OpT[], target: OpT): void {
if (Array.isArray(op)) {
for (const o of op) {
this.insertBefore(o, target);
OpList.insertBefore(o, target);
}
return;
}