Skip to content

Commit 0872ed6

Browse files
committed
Merge pull request microsoft#3266 from Microsoft/localTypes
Local types
2 parents f531ff8 + 6f734d6 commit 0872ed6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+2916
-489
lines changed

src/compiler/binder.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -519,17 +519,17 @@ module ts {
519519
bindBlockScopedDeclaration(<Declaration>node, SymbolFlags.Class, SymbolFlags.ClassExcludes);
520520
break;
521521
case SyntaxKind.InterfaceDeclaration:
522-
bindDeclaration(<Declaration>node, SymbolFlags.Interface, SymbolFlags.InterfaceExcludes, /*isBlockScopeContainer*/ false);
522+
bindBlockScopedDeclaration(<Declaration>node, SymbolFlags.Interface, SymbolFlags.InterfaceExcludes);
523523
break;
524524
case SyntaxKind.TypeAliasDeclaration:
525-
bindDeclaration(<Declaration>node, SymbolFlags.TypeAlias, SymbolFlags.TypeAliasExcludes, /*isBlockScopeContainer*/ false);
525+
bindBlockScopedDeclaration(<Declaration>node, SymbolFlags.TypeAlias, SymbolFlags.TypeAliasExcludes);
526526
break;
527527
case SyntaxKind.EnumDeclaration:
528528
if (isConst(node)) {
529-
bindDeclaration(<Declaration>node, SymbolFlags.ConstEnum, SymbolFlags.ConstEnumExcludes, /*isBlockScopeContainer*/ false);
529+
bindBlockScopedDeclaration(<Declaration>node, SymbolFlags.ConstEnum, SymbolFlags.ConstEnumExcludes);
530530
}
531531
else {
532-
bindDeclaration(<Declaration>node, SymbolFlags.RegularEnum, SymbolFlags.RegularEnumExcludes, /*isBlockScopeContainer*/ false);
532+
bindBlockScopedDeclaration(<Declaration>node, SymbolFlags.RegularEnum, SymbolFlags.RegularEnumExcludes);
533533
}
534534
break;
535535
case SyntaxKind.ModuleDeclaration:

src/compiler/checker.ts

Lines changed: 151 additions & 46 deletions
Large diffs are not rendered by default.

src/compiler/core.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,16 @@ module ts {
129129
}
130130
}
131131

132+
export function rangeEquals<T>(array1: T[], array2: T[], pos: number, end: number) {
133+
while (pos < end) {
134+
if (array1[pos] !== array2[pos]) {
135+
return false;
136+
}
137+
pos++;
138+
}
139+
return true;
140+
}
141+
132142
/**
133143
* Returns the last element of an array if non-empty, undefined otherwise.
134144
*/

src/compiler/diagnosticInformationMap.generated.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,5 @@ module ts {
548548
decorators_can_only_be_used_in_a_ts_file: { code: 8017, category: DiagnosticCategory.Error, key: "'decorators' can only be used in a .ts file." },
549549
Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses: { code: 9002, category: DiagnosticCategory.Error, key: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses." },
550550
class_expressions_are_not_currently_supported: { code: 9003, category: DiagnosticCategory.Error, key: "'class' expressions are not currently supported." },
551-
class_declarations_are_only_supported_directly_inside_a_module_or_as_a_top_level_declaration: { code: 9004, category: DiagnosticCategory.Error, key: "'class' declarations are only supported directly inside a module or as a top level declaration." },
552551
};
553552
}

src/compiler/diagnosticMessages.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2185,9 +2185,5 @@
21852185
"'class' expressions are not currently supported.": {
21862186
"category": "Error",
21872187
"code": 9003
2188-
},
2189-
"'class' declarations are only supported directly inside a module or as a top level declaration.": {
2190-
"category": "Error",
2191-
"code": 9004
21922188
}
21932189
}

src/compiler/parser.ts

Lines changed: 229 additions & 298 deletions
Large diffs are not rendered by default.

src/compiler/types.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,7 @@ module ts {
917917
_classElementBrand: any;
918918
}
919919

920-
export interface InterfaceDeclaration extends Declaration, ModuleElement {
920+
export interface InterfaceDeclaration extends Declaration, Statement {
921921
name: Identifier;
922922
typeParameters?: NodeArray<TypeParameterDeclaration>;
923923
heritageClauses?: NodeArray<HeritageClause>;
@@ -929,7 +929,7 @@ module ts {
929929
types?: NodeArray<ExpressionWithTypeArguments>;
930930
}
931931

932-
export interface TypeAliasDeclaration extends Declaration, ModuleElement {
932+
export interface TypeAliasDeclaration extends Declaration, Statement {
933933
name: Identifier;
934934
type: TypeNode;
935935
}
@@ -941,7 +941,7 @@ module ts {
941941
initializer?: Expression;
942942
}
943943

944-
export interface EnumDeclaration extends Declaration, ModuleElement {
944+
export interface EnumDeclaration extends Declaration, Statement {
945945
name: Identifier;
946946
members: NodeArray<EnumMember>;
947947
}
@@ -1626,6 +1626,8 @@ module ts {
16261626
// Class and interface types (TypeFlags.Class and TypeFlags.Interface)
16271627
export interface InterfaceType extends ObjectType {
16281628
typeParameters: TypeParameter[]; // Type parameters (undefined if non-generic)
1629+
outerTypeParameters: TypeParameter[]; // Outer type parameters (undefined if none)
1630+
localTypeParameters: TypeParameter[]; // Local type parameters (undefined if none)
16291631
}
16301632

16311633
export interface InterfaceTypeWithBaseTypes extends InterfaceType {

tests/baselines/reference/classDeclarationBlockScoping1.errors.txt

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
=== tests/cases/compiler/classDeclarationBlockScoping1.ts ===
2+
class C {
3+
>C : Symbol(C, Decl(classDeclarationBlockScoping1.ts, 0, 0))
4+
}
5+
6+
{
7+
class C {
8+
>C : Symbol(C, Decl(classDeclarationBlockScoping1.ts, 3, 1))
9+
}
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
=== tests/cases/compiler/classDeclarationBlockScoping1.ts ===
2+
class C {
3+
>C : C
4+
}
5+
6+
{
7+
class C {
8+
>C : C
9+
}
10+
}

0 commit comments

Comments
 (0)