From 3c2196bf54e7dfc21ba6d58d9ec630e3848b2123 Mon Sep 17 00:00:00 2001 From: Yui T Date: Sat, 11 Apr 2015 12:15:22 -0700 Subject: [PATCH] Address code review --- src/compiler/checker.ts | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 59400b959b3..123346aa210 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11925,7 +11925,8 @@ module ts { // GRAMMAR CHECKING function isReservedwordInStrictMode(node: Identifier): boolean { // Check that originalKeywordKind is less than LastFurtureReservedWord to see if an Identifier is a strict-mode reserved word - return (node.parserContextFlags & ParserContextFlags.StrictMode) && node.originalKeywordKind <= SyntaxKind.LastFutureReservedWord; + return (node.parserContextFlags & ParserContextFlags.StrictMode) && + (node.originalKeywordKind >= SyntaxKind.FirstFutureReservedWord && node.originalKeywordKind <= SyntaxKind.LastFutureReservedWord); } function reportStrictModeGrammarErrorInClassDeclaration(identifier: Identifier, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): boolean { @@ -12015,16 +12016,8 @@ module ts { // Walk from right to left and report a possible error at each Identifier in QualifiedName // Example: // x1: public.private.package // error at public and private - let qualifiedName = typeName; - while (qualifiedName && qualifiedName.kind === SyntaxKind.QualifiedName) { - checkGrammarTypeNameInStrictMode((qualifiedName).right); - qualifiedName = (qualifiedName).left; - } - - // Report an error at the last Identifier in QualifiedName - // Example: - // x1: public.private.package // error at package - checkGrammarTypeNameInStrictMode(qualifiedName); + checkGrammarTypeNameInStrictMode((typeName).right); + checkGrammarTypeReferenceInStrictMode((typeName).left); } } @@ -12034,27 +12027,18 @@ module ts { // public // error at public // public.private.package // error at public // B.private.B // no error - function checkGrammarHeritageClauseElementInStrictMode(expression: Expression) { + function checkGrammarHeritageClauseElementInStrictMode(expression: PropertyAccessExpression) { // Example: // class C extends public // error at public if (expression && expression.kind === SyntaxKind.Identifier) { return checkGrammarIdentifierInStrictMode(expression); } else if (expression && expression.kind === SyntaxKind.PropertyAccessExpression) { - let propertyAccessExp = expression; - // Walk from left to right in PropertyAccessExpression until we are at the left most expression // in PropertyAccessExpression. According to grammar production of MemberExpression, // the left component expression is a PrimaryExpression (i.e. Identifier) while the other // component after dots can be IdentifierName. - while (propertyAccessExp && propertyAccessExp.kind === SyntaxKind.PropertyAccessExpression) { - propertyAccessExp = propertyAccessExp.expression; - } - - // Report strict mode at the property of memberExpression - // Example: - // public.private.package // error at public as it is parsed as an Identifier in the PropertyAccessExpression - checkGrammarIdentifierInStrictMode(propertyAccessExp); + checkGrammarHeritageClauseElementInStrictMode(expression.expression); } }