From 1efff2857fa1c8fff2ac00443dc8fda8003c22a8 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 1 Jul 2015 14:45:53 -0700 Subject: [PATCH] fixed union-type determination, moved abstract implementation test, and reformatted a line --- src/compiler/checker.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 36981435828..54bdbe4c443 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7244,8 +7244,7 @@ namespace ts { let declaringClass = getDeclaredTypeOfSymbol(prop.parent);; if (left.kind === SyntaxKind.SuperKeyword) { - let errorNode = (node).name ? - (node).name : + let errorNode = node.kind === SyntaxKind.PropertyAccessExpression ? (node).name : (node).right; // TS 1.0 spec (April 2014): 4.8.2 @@ -9978,6 +9977,12 @@ namespace ts { // Grammar checking for modifiers is done inside the function checkGrammarFunctionLikeDeclaration checkFunctionLikeDeclaration(node); + + // Abstract methods cannot have an implementation. + // Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node. + if(node.flags & NodeFlags.Abstract && node.body) { + error(node, Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, declarationNameToString(node.name)); + } } function checkConstructorDeclaration(node: ConstructorDeclaration) { @@ -10381,12 +10386,6 @@ namespace ts { if (!bodyDeclaration) { bodyDeclaration = node; } - - // abstract functions cannot have an implementation. - // Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node. - if (currentNodeFlags & NodeFlags.Abstract && node.kind === SyntaxKind.MethodDeclaration && !isConstructor) { - error(node, Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, declarationNameToString(node.name)) - } } else { hasOverloads = true; @@ -14251,8 +14250,9 @@ namespace ts { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } else if (flags & NodeFlags.Abstract) { - if (modifier.kind === SyntaxKind.PrivateKeyword) { - return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract")} + if (modifier.kind === SyntaxKind.PrivateKeyword) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); + } else { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, text, "abstract"); }