diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 5d449b8b4b1..fa9cc95128e 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -68,8 +68,7 @@ module ts { if (!file.locals) { file.locals = {}; - container = file; - setBlockScopeContainer(file, /*cleanLocals*/ false); + container = blockScopeContainer = file; bind(file); file.symbolCount = symbolCount; } @@ -79,13 +78,6 @@ module ts { return new Symbol(flags, name); } - function setBlockScopeContainer(node: Node, cleanLocals: boolean) { - blockScopeContainer = node; - if (cleanLocals) { - blockScopeContainer.locals = undefined; - } - } - function addDeclarationToSymbol(symbol: Symbol, node: Declaration, symbolFlags: SymbolFlags) { symbol.flags |= symbolFlags; @@ -266,7 +258,10 @@ module ts { // these cases are: // - node has locals (symbolKind & HasLocals) !== 0 // - node is a source file - setBlockScopeContainer(node, /*cleanLocals*/ (symbolFlags & SymbolFlags.HasLocals) === 0 && node.kind !== SyntaxKind.SourceFile); + blockScopeContainer = node; + if ((symbolFlags & SymbolFlags.HasLocals) === 0 && node.kind !== SyntaxKind.SourceFile) { + blockScopeContainer.locals = undefined; + } } forEachChild(node, bind);