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

Side by Side Diff: runtime/vm/parser.cc

Issue 18558002: Const constructor must have const super initializer (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/class_finalizer.cc ('k') | tests/language/const_constructor_super_test.dart » ('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 6
7 #include "lib/invocation_mirror.h" 7 #include "lib/invocation_mirror.h"
8 #include "vm/bigint_operations.h" 8 #include "vm/bigint_operations.h"
9 #include "vm/class_finalizer.h" 9 #include "vm/class_finalizer.h"
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
(...skipping 1787 matching lines...) Expand 10 before | Expand all | Expand 10 after
1798 new LiteralNode(supercall_pos, 1798 new LiteralNode(supercall_pos,
1799 Smi::ZoneHandle(Smi::New(Function::kCtorPhaseAll))); 1799 Smi::ZoneHandle(Smi::New(Function::kCtorPhaseAll)));
1800 arguments->Add(phase_parameter); 1800 arguments->Add(phase_parameter);
1801 const Function& super_ctor = Function::ZoneHandle( 1801 const Function& super_ctor = Function::ZoneHandle(
1802 super_class.LookupConstructor(ctor_name)); 1802 super_class.LookupConstructor(ctor_name));
1803 if (super_ctor.IsNull()) { 1803 if (super_ctor.IsNull()) {
1804 ErrorMsg(supercall_pos, 1804 ErrorMsg(supercall_pos,
1805 "unresolved implicit call to super constructor '%s()'", 1805 "unresolved implicit call to super constructor '%s()'",
1806 String::Handle(super_class.Name()).ToCString()); 1806 String::Handle(super_class.Name()).ToCString());
1807 } 1807 }
1808 if (current_function().is_const() && !super_ctor.is_const()) {
1809 ErrorMsg(supercall_pos, "implicit call to non-const super constructor");
1810 }
1811
1808 String& error_message = String::Handle(); 1812 String& error_message = String::Handle();
1809 if (!super_ctor.AreValidArguments(arguments->length(), 1813 if (!super_ctor.AreValidArguments(arguments->length(),
1810 arguments->names(), 1814 arguments->names(),
1811 &error_message)) { 1815 &error_message)) {
1812 ErrorMsg(supercall_pos, 1816 ErrorMsg(supercall_pos,
1813 "invalid arguments passed to super constructor '%s()': %s", 1817 "invalid arguments passed to super constructor '%s()': %s",
1814 String::Handle(super_class.Name()).ToCString(), 1818 String::Handle(super_class.Name()).ToCString(),
1815 error_message.ToCString()); 1819 error_message.ToCString());
1816 } 1820 }
1817 current_block_->statements->Add( 1821 current_block_->statements->Add(
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1856 receiver->set_invisible(false); 1860 receiver->set_invisible(false);
1857 1861
1858 // Resolve the constructor. 1862 // Resolve the constructor.
1859 const Function& super_ctor = Function::ZoneHandle( 1863 const Function& super_ctor = Function::ZoneHandle(
1860 super_class.LookupConstructor(ctor_name)); 1864 super_class.LookupConstructor(ctor_name));
1861 if (super_ctor.IsNull()) { 1865 if (super_ctor.IsNull()) {
1862 ErrorMsg(supercall_pos, 1866 ErrorMsg(supercall_pos,
1863 "super class constructor '%s' not found", 1867 "super class constructor '%s' not found",
1864 ctor_name.ToCString()); 1868 ctor_name.ToCString());
1865 } 1869 }
1870 if (current_function().is_const() && !super_ctor.is_const()) {
1871 ErrorMsg(supercall_pos, "super constructor must be const");
1872 }
1866 String& error_message = String::Handle(); 1873 String& error_message = String::Handle();
1867 if (!super_ctor.AreValidArguments(arguments->length(), 1874 if (!super_ctor.AreValidArguments(arguments->length(),
1868 arguments->names(), 1875 arguments->names(),
1869 &error_message)) { 1876 &error_message)) {
1870 ErrorMsg(supercall_pos, 1877 ErrorMsg(supercall_pos,
1871 "invalid arguments passed to super class constructor '%s': %s", 1878 "invalid arguments passed to super class constructor '%s': %s",
1872 ctor_name.ToCString(), 1879 ctor_name.ToCString(),
1873 error_message.ToCString()); 1880 error_message.ToCString());
1874 } 1881 }
1875 return new StaticCallNode(supercall_pos, super_ctor, arguments); 1882 return new StaticCallNode(supercall_pos, super_ctor, arguments);
(...skipping 8091 matching lines...) Expand 10 before | Expand all | Expand 10 after
9967 void Parser::SkipQualIdent() { 9974 void Parser::SkipQualIdent() {
9968 ASSERT(IsIdentifier()); 9975 ASSERT(IsIdentifier());
9969 ConsumeToken(); 9976 ConsumeToken();
9970 if (CurrentToken() == Token::kPERIOD) { 9977 if (CurrentToken() == Token::kPERIOD) {
9971 ConsumeToken(); // Consume the kPERIOD token. 9978 ConsumeToken(); // Consume the kPERIOD token.
9972 ExpectIdentifier("identifier expected after '.'"); 9979 ExpectIdentifier("identifier expected after '.'");
9973 } 9980 }
9974 } 9981 }
9975 9982
9976 } // namespace dart 9983 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/class_finalizer.cc ('k') | tests/language/const_constructor_super_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698