| 32 | } |
| 33 | |
| 34 | exit() { |
| 35 | const oldClassScope = this.stack.pop()!; |
| 36 | |
| 37 | // Migrate the usage of not yet defined private names to the outer |
| 38 | // class scope, or raise an error if we reached the top-level scope. |
| 39 | |
| 40 | const current = this.current(); |
| 41 | |
| 42 | // Array.from is needed because this is compiled to an array-like for loop |
| 43 | for (const [name, loc] of Array.from(oldClassScope.undefinedPrivateNames)) { |
| 44 | if (current) { |
| 45 | if (!current.undefinedPrivateNames.has(name)) { |
| 46 | current.undefinedPrivateNames.set(name, loc); |
| 47 | } |
| 48 | } else { |
| 49 | this.parser.raise(Errors.InvalidPrivateFieldResolution, loc, { |
| 50 | identifierName: name, |
| 51 | }); |
| 52 | } |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | declarePrivateName(name: string, elementType: ClassElementType, loc: number) { |
| 57 | const { privateNames, loneAccessors, undefinedPrivateNames } = |