Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1033)

Unified Diff: runtime/vm/parser.cc

Issue 2077293003: Instantiating a const instance of an abstract class is a compile-time error (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: wip Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/co19/co19-co19.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/parser.cc
diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc
index e682207680984eeae35eb3ab5de4868482ba30e3..5c1bc446c6f8d008038b7e68547ce0bc79df2ade 100644
--- a/runtime/vm/parser.cc
+++ b/runtime/vm/parser.cc
@@ -13627,6 +13627,12 @@ AstNode* Parser::ParseNewOperator(Token::Kind op_kind) {
}
ASSERT(!constructor.IsNull());
+ // It is a compile time error to instantiate a const instance of an
+ // abstract class. Factory methods are ok.
+ if (is_const && type_class.is_abstract() && !constructor.IsFactory()) {
+ ReportError(new_pos, "cannot instantiate abstract class");
+ }
+
// It is ok to call a factory method of an abstract class, but it is
// a dynamic error to instantiate an abstract class.
if (type_class.is_abstract() && !constructor.IsFactory()) {
« no previous file with comments | « no previous file | tests/co19/co19-co19.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698