Error on creating a new instance of an abstract class

This commit is contained in:
Dick van den Brink
2015-04-30 17:51:16 +02:00
parent 0e72677fd2
commit b42e447df8
3 changed files with 10 additions and 0 deletions
+5
View File
@@ -7084,6 +7084,11 @@ module ts {
return resolveErrorCall(node);
}
var valueDecl = (expressionType.symbol ? expressionType.symbol.valueDeclaration : undefined);
if (valueDecl && valueDecl.flags & NodeFlags.Abstract) {
error(node, Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, declarationNameToString(valueDecl.name));
}
// Technically, this signatures list may be incomplete. We are taking the apparent type,
// but we are not including construct signatures that may have been added to the Object or
// Function interface, since they have none by default. This is a bit of a leap of faith
@@ -363,6 +363,7 @@ module ts {
An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2499, category: DiagnosticCategory.Error, key: "An interface can only extend an identifier/qualified-name with optional type arguments." },
A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2500, category: DiagnosticCategory.Error, key: "A class can only implement an identifier/qualified-name with optional type arguments." },
A_rest_element_cannot_contain_a_binding_pattern: { code: 2501, category: DiagnosticCategory.Error, key: "A rest element cannot contain a binding pattern." },
Cannot_create_an_instance_of_the_abstract_class_0: { code: 2502, category: DiagnosticCategory.Error, key: "Cannot create an instance of the abstract class '{0}'" },
Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." },
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." },
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." },
+4
View File
@@ -1440,6 +1440,10 @@
"category": "Error",
"code": 2501
},
"Cannot create an instance of the abstract class '{0}'": {
"category": "Error",
"code": 2502
},
"Import declaration '{0}' is using private name '{1}'.": {
"category": "Error",