@@ -11821,6 +11821,38 @@ module ts {
11821
11821
}
11822
11822
}
11823
11823
11824
+ function isStatementWithLocals(node: Node) {
11825
+ switch (node.kind) {
11826
+ case SyntaxKind.Block:
11827
+ case SyntaxKind.CaseBlock:
11828
+ case SyntaxKind.ForStatement:
11829
+ case SyntaxKind.ForInStatement:
11830
+ case SyntaxKind.ForOfStatement:
11831
+ return true;
11832
+ }
11833
+ return false;
11834
+ }
11835
+
11836
+ function getIsNestedRedeclaration(symbol: Symbol): boolean {
11837
+ let links = getSymbolLinks(symbol);
11838
+ if (links.isNestedRedeclaration === undefined) {
11839
+ let container = getEnclosingBlockScopeContainer(symbol.valueDeclaration);
11840
+ links.isNestedRedeclaration = isStatementWithLocals(container) &&
11841
+ !!resolveName(container.parent, symbol.name, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined);
11842
+ }
11843
+ return links.isNestedRedeclaration;
11844
+ }
11845
+
11846
+ function getReferencedNestedRedeclaration(node: Identifier): Declaration {
11847
+ let symbol = getReferencedValueSymbol(node);
11848
+ return symbol && symbol.flags & SymbolFlags.BlockScoped && getIsNestedRedeclaration(symbol) ? symbol.valueDeclaration : undefined;
11849
+ }
11850
+
11851
+ function isNestedRedeclaration(node: Declaration): boolean {
11852
+ let symbol = getSymbolOfNode(node);
11853
+ return symbol.flags & SymbolFlags.BlockScoped && getIsNestedRedeclaration(symbol);
11854
+ }
11855
+
11824
11856
function isValueAliasDeclaration(node: Node): boolean {
11825
11857
switch (node.kind) {
11826
11858
case SyntaxKind.ImportEqualsDeclaration:
@@ -11924,8 +11956,10 @@ module ts {
11924
11956
/** Serializes an EntityName (with substitutions) to an appropriate JS constructor value. Used by the __metadata decorator. */
11925
11957
function serializeEntityName(node: EntityName, getGeneratedNameForNode: (Node: Node) => string, fallbackPath?: string[]): string {
11926
11958
if (node.kind === SyntaxKind.Identifier) {
11927
- var substitution = getExpressionNameSubstitution(<Identifier>node, getGeneratedNameForNode);
11928
- var text = substitution || (<Identifier>node).text;
11959
+ // TODO(andersh): Fix this
11960
+ // var substitution = getExpressionNameSubstitution(<Identifier>node, getGeneratedNameForNode);
11961
+ // var text = substitution || (<Identifier>node).text;
11962
+ var text = (<Identifier>node).text;
11929
11963
if (fallbackPath) {
11930
11964
fallbackPath.push(text);
11931
11965
}
@@ -12140,11 +12174,6 @@ module ts {
12140
12174
return hasProperty(globals, name);
12141
12175
}
12142
12176
12143
- function resolvesToSomeValue(location: Node, name: string): boolean {
12144
- Debug.assert(!nodeIsSynthesized(location), "resolvesToSomeValue called with a synthesized location");
12145
- return !!resolveName(location, name, SymbolFlags.Value, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined);
12146
- }
12147
-
12148
12177
function getReferencedValueSymbol(reference: Identifier): Symbol {
12149
12178
return getNodeLinks(reference).resolvedSymbol ||
12150
12179
resolveName(reference, reference.text, SymbolFlags.Value | SymbolFlags.ExportValue | SymbolFlags.Alias,
@@ -12198,9 +12227,10 @@ module ts {
12198
12227
12199
12228
function createResolver(): EmitResolver {
12200
12229
return {
12201
- getExpressionNameSubstitution,
12202
12230
getReferencedExportContainer,
12203
12231
getReferencedImportDeclaration,
12232
+ getReferencedNestedRedeclaration,
12233
+ isNestedRedeclaration,
12204
12234
isValueAliasDeclaration,
12205
12235
hasGlobalName,
12206
12236
isReferencedAliasDeclaration,
@@ -12214,7 +12244,6 @@ module ts {
12214
12244
isSymbolAccessible,
12215
12245
isEntityNameVisible,
12216
12246
getConstantValue,
12217
- resolvesToSomeValue,
12218
12247
collectLinkedAliases,
12219
12248
getBlockScopedVariableId,
12220
12249
getReferencedValueDeclaration,
0 commit comments