@@ -99,19 +99,19 @@ module ts {
9999
100100 let globals: SymbolTable = {};
101101
102- let globalArraySymbol: Symbol;
103102 let globalESSymbolConstructorSymbol: Symbol;
104103
105104 let globalObjectType: ObjectType;
106105 let globalFunctionType: ObjectType;
107- let globalArrayType: ObjectType ;
106+ let globalArrayType: GenericType ;
108107 let globalStringType: ObjectType;
109108 let globalNumberType: ObjectType;
110109 let globalBooleanType: ObjectType;
111110 let globalRegExpType: ObjectType;
112111 let globalTemplateStringsArrayType: ObjectType;
113112 let globalESSymbolType: ObjectType;
114- let globalIterableType: ObjectType;
113+ let globalIterableType: GenericType;
114+ let globalIterableIteratorType: GenericType;
115115
116116 let anyArrayType: Type;
117117 let getGlobalClassDecoratorType: () => ObjectType;
@@ -3468,16 +3468,20 @@ module ts {
34683468 return globalESSymbolConstructorSymbol || (globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol"));
34693469 }
34703470
3471+ function createTypeFromGlobalGenericType(globalGenericType: GenericType, elementType: Type): Type {
3472+ return <ObjectType>globalGenericType !== emptyObjectType ? createTypeReference(globalGenericType, [elementType]) : emptyObjectType;
3473+ }
3474+
34713475 function createIterableType(elementType: Type): Type {
3472- return globalIterableType !== emptyObjectType ? createTypeReference(<GenericType>globalIterableType, [elementType]) : emptyObjectType;
3476+ return createTypeFromGlobalGenericType(globalIterableType, elementType);
3477+ }
3478+
3479+ function createIterableIteratorType(elementType: Type): Type {
3480+ return createTypeFromGlobalGenericType(globalIterableIteratorType, elementType);
34733481 }
34743482
34753483 function createArrayType(elementType: Type): Type {
3476- // globalArrayType will be undefined if we get here during creation of the Array type. This for example happens if
3477- // user code augments the Array type with call or construct signatures that have an array type as the return type.
3478- // We instead use globalArraySymbol to obtain the (not yet fully constructed) Array type.
3479- let arrayType = globalArrayType || getDeclaredTypeOfSymbol(globalArraySymbol);
3480- return arrayType !== emptyObjectType ? createTypeReference(<GenericType>arrayType, [elementType]) : emptyObjectType;
3484+ return createTypeFromGlobalGenericType(globalArrayType, elementType);
34813485 }
34823486
34833487 function getTypeFromArrayTypeNode(node: ArrayTypeNode): Type {
@@ -8142,6 +8146,16 @@ module ts {
81428146 }
81438147 }
81448148
8149+ function isSyntacticallyValidGenerator(node: SignatureDeclaration): boolean {
8150+ if (!(<FunctionLikeDeclaration>node).asteriskToken || !(<FunctionLikeDeclaration>node).body) {
8151+ return false;
8152+ }
8153+
8154+ return node.kind === SyntaxKind.MethodDeclaration ||
8155+ node.kind === SyntaxKind.FunctionDeclaration ||
8156+ node.kind === SyntaxKind.FunctionExpression;
8157+ }
8158+
81458159 function checkSignatureDeclaration(node: SignatureDeclaration) {
81468160 // Grammar checking
81478161 if (node.kind === SyntaxKind.IndexSignature) {
@@ -11967,8 +11981,7 @@ module ts {
1196711981 getSymbolLinks(unknownSymbol).type = unknownType;
1196811982 globals[undefinedSymbol.name] = undefinedSymbol;
1196911983 // Initialize special types
11970- globalArraySymbol = getGlobalTypeSymbol("Array");
11971- globalArrayType = getTypeOfGlobalSymbol(globalArraySymbol, /*arity*/ 1);
11984+ globalArrayType = <GenericType>getGlobalType("Array", /*arity*/ 1);
1197211985 globalObjectType = getGlobalType("Object");
1197311986 globalFunctionType = getGlobalType("Function");
1197411987 globalStringType = getGlobalType("String");
@@ -11986,7 +11999,8 @@ module ts {
1198611999 globalTemplateStringsArrayType = getGlobalType("TemplateStringsArray");
1198712000 globalESSymbolType = getGlobalType("Symbol");
1198812001 globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol");
11989- globalIterableType = getGlobalType("Iterable", /*arity*/ 1);
12002+ globalIterableType = <GenericType>getGlobalType("Iterable", /*arity*/ 1);
12003+ globalIterableIteratorType = <GenericType>getGlobalType("IterableIterator", /*arity*/ 1);
1199012004 }
1199112005 else {
1199212006 globalTemplateStringsArrayType = unknownType;
0 commit comments