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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | tests/co19/co19-co19.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/parser.h" 5 #include "vm/parser.h"
6 #include "vm/flags.h" 6 #include "vm/flags.h"
7 7
8 #ifndef DART_PRECOMPILED_RUNTIME 8 #ifndef DART_PRECOMPILED_RUNTIME
9 9
10 #include "lib/invocation_mirror.h" 10 #include "lib/invocation_mirror.h"
(...skipping 13609 matching lines...) Expand 10 before | Expand all | Expand 10 after
13620 type_class = type.type_class(); 13620 type_class = type.type_class();
13621 type_class_name = type_class.Name(); 13621 type_class_name = type_class.Name();
13622 type_arguments = type.arguments(); 13622 type_arguments = type.arguments();
13623 constructor = constructor.RedirectionTarget(); 13623 constructor = constructor.RedirectionTarget();
13624 constructor_name = constructor.name(); 13624 constructor_name = constructor.name();
13625 ASSERT(!constructor.IsNull()); 13625 ASSERT(!constructor.IsNull());
13626 } 13626 }
13627 } 13627 }
13628 ASSERT(!constructor.IsNull()); 13628 ASSERT(!constructor.IsNull());
13629 13629
13630 // It is a compile time error to instantiate a const instance of an
13631 // abstract class. Factory methods are ok.
13632 if (is_const && type_class.is_abstract() && !constructor.IsFactory()) {
13633 ReportError(new_pos, "cannot instantiate abstract class");
13634 }
13635
13630 // It is ok to call a factory method of an abstract class, but it is 13636 // It is ok to call a factory method of an abstract class, but it is
13631 // a dynamic error to instantiate an abstract class. 13637 // a dynamic error to instantiate an abstract class.
13632 if (type_class.is_abstract() && !constructor.IsFactory()) { 13638 if (type_class.is_abstract() && !constructor.IsFactory()) {
13633 // Evaluate arguments before throwing. 13639 // Evaluate arguments before throwing.
13634 LetNode* result = new(Z) LetNode(call_pos); 13640 LetNode* result = new(Z) LetNode(call_pos);
13635 for (intptr_t i = 0; i < arguments->length(); ++i) { 13641 for (intptr_t i = 0; i < arguments->length(); ++i) {
13636 result->AddNode(arguments->NodeAt(i)); 13642 result->AddNode(arguments->NodeAt(i));
13637 } 13643 }
13638 ArgumentListNode* error_arguments = new(Z) ArgumentListNode(type_pos); 13644 ArgumentListNode* error_arguments = new(Z) ArgumentListNode(type_pos);
13639 error_arguments->Add(new(Z) LiteralNode( 13645 error_arguments->Add(new(Z) LiteralNode(
(...skipping 970 matching lines...) Expand 10 before | Expand all | Expand 10 after
14610 const ArgumentListNode& function_args, 14616 const ArgumentListNode& function_args,
14611 const LocalVariable* temp_for_last_arg, 14617 const LocalVariable* temp_for_last_arg,
14612 bool is_super_invocation) { 14618 bool is_super_invocation) {
14613 UNREACHABLE(); 14619 UNREACHABLE();
14614 return NULL; 14620 return NULL;
14615 } 14621 }
14616 14622
14617 } // namespace dart 14623 } // namespace dart
14618 14624
14619 #endif // DART_PRECOMPILED_RUNTIME 14625 #endif // DART_PRECOMPILED_RUNTIME
OLDNEW
« 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