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

Unified Diff: runtime/vm/parser.cc

Issue 269253007: - Fix the external_test.dart as it was relying on outdated (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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 | « runtime/vm/object.cc ('k') | tests/language/external_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/parser.cc
===================================================================
--- runtime/vm/parser.cc (revision 37188)
+++ runtime/vm/parser.cc (working copy)
@@ -2851,6 +2851,18 @@
} else if (CurrentToken() == Token::kSEMICOLON) {
// Some constructors have no function body.
ConsumeToken();
+ if (func.is_external()) {
+ // Body of an external method contains a single throw.
+ const String& function_name = String::ZoneHandle(func.name());
+ current_block_->statements->Add(
+ ThrowNoSuchMethodError(TokenPos(),
+ cls,
+ function_name,
+ NULL, // No arguments.
+ InvocationMirror::kStatic,
+ InvocationMirror::kMethod,
+ NULL)); // No existing function.
+ }
} else {
UnexpectedToken();
}
@@ -3020,7 +3032,7 @@
const String& function_name = String::ZoneHandle(I, func.name());
current_block_->statements->Add(
ThrowNoSuchMethodError(TokenPos(),
- current_class(),
+ Class::Handle(func.Owner()),
function_name,
NULL, // Ignore arguments.
func.is_static() ?
@@ -3267,6 +3279,11 @@
"for optional parameters",
method->name->ToCString());
}
+ if (method->has_external) {
+ ErrorMsg(TokenPos(),
+ "external factory constructor '%s' may not have redirection",
+ method->name->ToCString());
+ }
ConsumeToken();
const intptr_t type_pos = TokenPos();
is_redirecting = true;
@@ -3295,6 +3312,11 @@
if (!method->IsConstructor()) {
ErrorMsg("initializers only allowed on constructors");
}
+ if (method->has_external) {
+ ErrorMsg(TokenPos(),
+ "external constructor '%s' may not have initializers",
+ method->name->ToCString());
+ }
if ((LookaheadToken(1) == Token::kTHIS) &&
((LookaheadToken(2) == Token::kLPAREN) ||
LookaheadToken(4) == Token::kLPAREN)) {
@@ -3326,23 +3348,32 @@
// Only constructors can redirect to another method.
ASSERT((method->redirect_name == NULL) || method->IsConstructor());
+ if (method->IsConstructor() &&
+ method->has_external &&
+ method->params.has_field_initializer) {
+ ErrorMsg(method->name_pos,
+ "external constructor '%s' may not have field initializers",
+ method->name->ToCString());
+ }
+
intptr_t method_end_pos = TokenPos();
if ((CurrentToken() == Token::kLBRACE) ||
(CurrentToken() == Token::kARROW)) {
if (method->has_abstract) {
- ErrorMsg(method->name_pos,
+ ErrorMsg(TokenPos(),
"abstract method '%s' may not have a function body",
method->name->ToCString());
} else if (method->has_external) {
- ErrorMsg(method->name_pos,
- "external method '%s' may not have a function body",
+ ErrorMsg(TokenPos(),
+ "external %s '%s' may not have a function body",
+ method->IsFactoryOrConstructor() ? "constructor" : "method",
method->name->ToCString());
} else if (method->IsConstructor() && method->has_const) {
- ErrorMsg(method->name_pos,
+ ErrorMsg(TokenPos(),
"const constructor '%s' may not have a function body",
method->name->ToCString());
} else if (method->IsFactory() && method->has_const) {
- ErrorMsg(method->name_pos,
+ ErrorMsg(TokenPos(),
"const factory '%s' may not have a function body",
method->name->ToCString());
}
« no previous file with comments | « runtime/vm/object.cc ('k') | tests/language/external_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698