Make sure we have an appropriate error for heritage clause lists.

This commit is contained in:
Cyrus Najmabadi
2014-12-01 17:07:13 -08:00
parent ae3b030223
commit df4f9044d9
3 changed files with 11 additions and 5 deletions

View File

@@ -137,6 +137,7 @@ module ts {
Classes_can_only_extend_a_single_class: { code: 1174, category: DiagnosticCategory.Error, key: "Classes can only extend a single class." },
implements_clause_already_seen: { code: 1175, category: DiagnosticCategory.Error, key: "'implements' clause already seen." },
Interface_declaration_cannot_have_implements_clause: { code: 1176, category: DiagnosticCategory.Error, key: "Interface declaration cannot have 'implements' clause." },
Unexpected_token_expected: { code: 1177, category: DiagnosticCategory.Error, key: "Unexpected token. '{' expected." },
Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." },
Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." },
Static_members_cannot_reference_class_type_parameters: { code: 2302, category: DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." },

View File

@@ -539,6 +539,10 @@
"category": "Error",
"code": 1176
},
"Unexpected token. '{' expected.": {
"category": "Error",
"code": 1177
},
"Duplicate identifier '{0}'.": {
"category": "Error",

View File

@@ -779,7 +779,7 @@ module ts {
TypeMembers, // Members in interface or type literal
ClassMembers, // Members in class declaration
EnumMembers, // Members in enum declaration
BaseTypeReferences, // Type references in extends or implements clause
TypeReferences, // Type references in extends or implements clause
VariableDeclarations, // Variable declarations in variable statement
ArgumentExpressions, // Expressions in argument list
ObjectLiteralMembers, // Members in object literal
@@ -808,7 +808,7 @@ module ts {
case ParsingContext.TypeMembers: return Diagnostics.Property_or_signature_expected;
case ParsingContext.ClassMembers: return Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected;
case ParsingContext.EnumMembers: return Diagnostics.Enum_member_expected;
case ParsingContext.BaseTypeReferences: return Diagnostics.Type_reference_expected;
case ParsingContext.TypeReferences: return Diagnostics.Type_reference_expected;
case ParsingContext.VariableDeclarations: return Diagnostics.Variable_declaration_expected;
case ParsingContext.ArgumentExpressions: return Diagnostics.Argument_expression_expected;
case ParsingContext.ObjectLiteralMembers: return Diagnostics.Property_assignment_expected;
@@ -817,6 +817,7 @@ module ts {
case ParsingContext.TypeParameters: return Diagnostics.Type_parameter_declaration_expected;
case ParsingContext.TypeArguments: return Diagnostics.Type_argument_expected;
case ParsingContext.TupleElementTypes: return Diagnostics.Type_expected;
case ParsingContext.HeritageClauses: return Diagnostics.Unexpected_token_expected;
}
};
@@ -1416,7 +1417,7 @@ module ts {
return token === SyntaxKind.OpenBracketToken || isLiteralPropertyName();
case ParsingContext.ObjectLiteralMembers:
return token === SyntaxKind.OpenBracketToken || token === SyntaxKind.AsteriskToken || isLiteralPropertyName();
case ParsingContext.BaseTypeReferences:
case ParsingContext.TypeReferences:
return isIdentifier() && ((token !== SyntaxKind.ExtendsKeyword && token !== SyntaxKind.ImplementsKeyword) || !lookAhead(() => (nextToken(), isIdentifier())));
case ParsingContext.VariableDeclarations:
case ParsingContext.TypeParameters:
@@ -1455,7 +1456,7 @@ module ts {
return token === SyntaxKind.CloseBraceToken;
case ParsingContext.SwitchClauseStatements:
return token === SyntaxKind.CloseBraceToken || token === SyntaxKind.CaseKeyword || token === SyntaxKind.DefaultKeyword;
case ParsingContext.BaseTypeReferences:
case ParsingContext.TypeReferences:
return token === SyntaxKind.OpenBraceToken || token === SyntaxKind.ExtendsKeyword || token === SyntaxKind.ImplementsKeyword;
case ParsingContext.VariableDeclarations:
return isVariableDeclaratorListTerminator();
@@ -3860,7 +3861,7 @@ module ts {
var node = <HeritageClause>createNode(SyntaxKind.HeritageClause);
node.token = token;
nextToken();
node.types = parseDelimitedList(ParsingContext.BaseTypeReferences, parseTypeReference);
node.types = parseDelimitedList(ParsingContext.TypeReferences, parseTypeReference);
return finishNode(node);
}