Skip to content

Commit 1efff28

Browse files
author
Arthur Ozga
committed
fixed union-type determination, moved abstract implementation test, and reformatted a line
1 parent 1608845 commit 1efff28

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

Diff for: src/compiler/checker.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -7244,8 +7244,7 @@ namespace ts {
72447244
let declaringClass = <InterfaceType>getDeclaredTypeOfSymbol(prop.parent);;
72457245

72467246
if (left.kind === SyntaxKind.SuperKeyword) {
7247-
let errorNode = (<PropertyAccessExpression>node).name ?
7248-
(<PropertyAccessExpression>node).name :
7247+
let errorNode = node.kind === SyntaxKind.PropertyAccessExpression ? (<PropertyAccessExpression>node).name :
72497248
(<QualifiedName>node).right;
72507249

72517250
// TS 1.0 spec (April 2014): 4.8.2
@@ -9978,6 +9977,12 @@ namespace ts {
99789977

99799978
// Grammar checking for modifiers is done inside the function checkGrammarFunctionLikeDeclaration
99809979
checkFunctionLikeDeclaration(node);
9980+
9981+
// Abstract methods cannot have an implementation.
9982+
// Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node.
9983+
if(node.flags & NodeFlags.Abstract && node.body) {
9984+
error(node, Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, declarationNameToString(node.name));
9985+
}
99819986
}
99829987

99839988
function checkConstructorDeclaration(node: ConstructorDeclaration) {
@@ -10381,12 +10386,6 @@ namespace ts {
1038110386
if (!bodyDeclaration) {
1038210387
bodyDeclaration = node;
1038310388
}
10384-
10385-
// abstract functions cannot have an implementation.
10386-
// Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node.
10387-
if (currentNodeFlags & NodeFlags.Abstract && node.kind === SyntaxKind.MethodDeclaration && !isConstructor) {
10388-
error(node, Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, declarationNameToString(node.name))
10389-
}
1039010389
}
1039110390
else {
1039210391
hasOverloads = true;
@@ -14251,8 +14250,9 @@ namespace ts {
1425114250
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_module_element, text);
1425214251
}
1425314252
else if (flags & NodeFlags.Abstract) {
14254-
if (modifier.kind === SyntaxKind.PrivateKeyword) {
14255-
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract")}
14253+
if (modifier.kind === SyntaxKind.PrivateKeyword) {
14254+
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract");
14255+
}
1425614256
else {
1425714257
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, text, "abstract");
1425814258
}

0 commit comments

Comments
 (0)