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

Unified Diff: runtime/vm/parser.cc

Issue 57133004: Complete latest spec changes regarding malformed types (see issue 14006). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 1 month 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/co19/co19-dart2dart.status » ('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 29923)
+++ runtime/vm/parser.cc (working copy)
@@ -6912,7 +6912,10 @@
SequenceNode* catch_handler = CloseBlock();
ExpectToken(Token::kRBRACE);
- if (!exception_param.type.IsDynamicType()) { // Has a type specification.
+ const bool is_bad_type = exception_param.type.IsMalformed() ||
+ exception_param.type.IsMalbounded();
+ if (!is_bad_type && !exception_param.type.IsDynamicType()) {
+ // Has a type specification that is not malformed or malbounded.
// Now form an 'if type check' as an exception type exists in the
// catch specifier.
if (!exception_param.type.IsInstantiated() &&
@@ -6940,6 +6943,11 @@
handler_types.Add(exception_param.type);
}
} else {
+ if (is_bad_type) {
+ current_block_->statements->Add(ThrowTypeError(catch_pos,
+ exception_param.type));
+ // We still add the dead code below to satisfy the code generator.
+ }
// No exception type exists in the catch specifier so execute the
// catch handler code unconditionally.
current_block_->statements->Add(catch_handler);
@@ -8615,36 +8623,24 @@
// referenced by a static member.
if (ParsingStaticMember()) {
ASSERT(scope_class.raw() == current_class().raw());
- if ((finalization == ClassFinalizer::kCanonicalizeWellFormed) ||
- FLAG_error_on_bad_type) {
- *type = ClassFinalizer::NewFinalizedMalformedType(
- Error::Handle(), // No previous error.
- script_,
- type->token_pos(),
- "type parameter '%s' cannot be referenced "
- "from static member",
- String::Handle(type_parameter.name()).ToCString());
- } else {
- // Map the malformed type to dynamic and ignore type arguments.
- *type = Type::DynamicType();
- }
+ *type = ClassFinalizer::NewFinalizedMalformedType(
+ Error::Handle(), // No previous error.
+ script_,
+ type->token_pos(),
+ "type parameter '%s' cannot be referenced "
+ "from static member",
+ String::Handle(type_parameter.name()).ToCString());
return;
}
// A type parameter cannot be parameterized, so make the type
// malformed if type arguments have previously been parsed.
if (!AbstractTypeArguments::Handle(type->arguments()).IsNull()) {
- if ((finalization == ClassFinalizer::kCanonicalizeWellFormed) ||
- FLAG_error_on_bad_type) {
- *type = ClassFinalizer::NewFinalizedMalformedType(
- Error::Handle(), // No previous error.
- script_,
- type_parameter.token_pos(),
- "type parameter '%s' cannot be parameterized",
- String::Handle(type_parameter.name()).ToCString());
- } else {
- // Map the malformed type to dynamic and ignore type arguments.
- *type = Type::DynamicType();
- }
+ *type = ClassFinalizer::NewFinalizedMalformedType(
+ Error::Handle(), // No previous error.
+ script_,
+ type_parameter.token_pos(),
+ "type parameter '%s' cannot be parameterized",
+ String::Handle(type_parameter.name()).ToCString());
return;
}
*type = type_parameter.raw();
@@ -8671,18 +8667,12 @@
// Replace unresolved class with resolved type class.
parameterized_type.set_type_class(resolved_type_class);
} else if (finalization >= ClassFinalizer::kCanonicalize) {
- if ((finalization == ClassFinalizer::kCanonicalizeWellFormed) ||
- FLAG_error_on_bad_type) {
- ClassFinalizer::FinalizeMalformedType(
- Error::Handle(), // No previous error.
- script_,
- parameterized_type,
- "type '%s' is not loaded",
- String::Handle(parameterized_type.UserVisibleName()).ToCString());
- } else {
- // Map the malformed type to dynamic and ignore type arguments.
- *type = Type::DynamicType();
- }
+ ClassFinalizer::FinalizeMalformedType(
+ Error::Handle(), // No previous error.
+ script_,
+ parameterized_type,
+ "type '%s' is not loaded",
+ String::Handle(parameterized_type.UserVisibleName()).ToCString());
return;
}
}
@@ -9286,15 +9276,12 @@
ResolveIdentInLocalScope(type_name.ident_pos, *type_name.ident, NULL)) {
// The type is malformed. Skip over its type arguments.
ParseTypeArguments(ClassFinalizer::kIgnore);
- if (finalization == ClassFinalizer::kCanonicalizeWellFormed) {
- return ClassFinalizer::NewFinalizedMalformedType(
- Error::Handle(), // No previous error.
- script_,
- type_name.ident_pos,
- "using '%s' in this context is invalid",
- type_name.ident->ToCString());
- }
- return Type::DynamicType();
+ return ClassFinalizer::NewFinalizedMalformedType(
+ Error::Handle(), // No previous error.
+ script_,
+ type_name.ident_pos,
+ "using '%s' in this context is invalid",
+ type_name.ident->ToCString());
}
}
Object& type_class = Object::Handle(isolate());
« no previous file with comments | « runtime/vm/object.cc ('k') | tests/co19/co19-dart2dart.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698