JS: Also emit 'this' variable for class scopes

This commit is contained in:
Asger F
2026-02-27 11:44:31 +01:00
parent 4a3b86c652
commit f0f58dacb3

View File

@@ -1545,8 +1545,9 @@ public class ASTExtractor {
if (!isClassExpression) {
visit(ac.getId(), key, 0, IdContext.VAR_AND_TYPE_DECL);
}
scopeManager.enterScope(scopeNode);
scopeManager.addVariables("this"); // 'this' in static field initialiers refers to the class
if (ac.hasId() || ac.hasTypeParameters()) {
scopeManager.enterScope(scopeNode);
if (isClassExpression && ac.hasId()) {
scopeManager.addVariables(ac.getId().getName());
scopeManager.addTypeName(ac.getId().getName());
@@ -1569,9 +1570,7 @@ public class ASTExtractor {
addDefaultConstructor(ac);
}
visit(ac.getBody(), key, 2);
if (ac.hasId() || ac.hasTypeParameters()) {
scopeManager.leaveScope();
}
scopeManager.leaveScope();
emitNodeSymbol(ac, key);
return key;
}