diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 296e75c4b76..0fda2989e1a 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1582,10 +1582,10 @@ module ts { Tuple = 0x00002000, // Tuple Union = 0x00004000, // Union Anonymous = 0x00008000, // Anonymous - /* @internal */ + /* @internal */ FromSignature = 0x00010000, // Created for signature assignment check ObjectLiteral = 0x00020000, // Originates in an object literal - /* @internal */ + /* @internal */ ContainsUndefinedOrNull = 0x00040000, // Type is or contains Undefined or Null type /* @internal */ ContainsObjectLiteral = 0x00080000, // Type is or contains object literal type diff --git a/src/services/services.ts b/src/services/services.ts index 0865c68db64..691aebf6cc3 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -4988,18 +4988,6 @@ module ts { return location.getText(); } - // Special case for function expressions, whose names are solely local to their bodies. - // TODO (drosen): Why would we have to lookup the interned name for a function expression? - // Shouldn't we have found a scope? Consider a 'Debug.fail()'. - let functionExpression: FunctionExpression; - if (symbol.valueDeclaration && symbol.valueDeclaration.kind === SyntaxKind.FunctionExpression) { - functionExpression = symbol.valueDeclaration; - - if (functionExpression.name) { - return functionExpression.name.text; - } - } - // Try to get the local symbol if we're dealing with an 'export default' // since that symbol has the "true" name. let localExportDefaultSymbol = getLocalSymbolForExportDefault(symbol); @@ -5008,7 +4996,20 @@ module ts { return stripQuotes(symbol.name); } + /** + * Determines the smallest scope in which a symbol may have named references. + * + * Returns undefined if the scope cannot be determined, often implying that + * a reference to a symbol can occur anywhere. + */ function getSymbolScope(symbol: Symbol): Node { + // If this is the symbol of a function expression, then named references + // are limited to its own scope. + let valueDeclaration = symbol.valueDeclaration; + if (valueDeclaration && valueDeclaration.kind === SyntaxKind.FunctionExpression) { + return valueDeclaration; + } + // If this is private property or method, the scope is the containing class if (symbol.flags & (SymbolFlags.Property | SymbolFlags.Method)) { let privateDeclaration = forEach(symbol.getDeclarations(), d => (d.flags & NodeFlags.Private) ? d : undefined);