Skip to content

Incorrect "JSC_USED_GLOBAL_THIS" warning on this in class field initializer #4230

@lauraharker

Description

@lauraharker

As noted in #2731 - the compiler incorrectly reports "[JSC_USED_GLOBAL_THIS] dangerous use of the global this object" on the this.y reference below.

class Foo {
  x = () => this.y;
  y = 3;
}

this in a non-static class field initializer will refer to the class instance.

To reproduce -

closure-compiler-debugger

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions