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

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
Index: runtime/vm/parser.cc
===================================================================
--- runtime/vm/parser.cc (revision 29871)
+++ runtime/vm/parser.cc (working copy)
@@ -6932,7 +6932,10 @@
SequenceNode* catch_handler = CloseBlock();
ExpectToken(Token::kRBRACE);
- if (!exception_param.type->IsDynamicType()) { // Has a type specification.
+ const bool throw_on_bad_type = exception_param.type->IsMalformed() ||
hausner 2013/11/05 17:45:17 const bool is_bad_type = ... ?
+ exception_param.type->IsMalbounded();
+ if (!throw_on_bad_type && !exception_param.type->IsDynamicType()) {
+ // Has a type specification.
// Now form an 'if type check' as an exception type exists in
// the catch specifier.
if (!exception_param.type->IsInstantiated() &&
@@ -6961,6 +6964,11 @@
handler_types.Add(*exception_param.type);
}
} else {
+ if (throw_on_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);
@@ -8643,36 +8651,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();
@@ -8699,18 +8695,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;
}
}
@@ -9314,15 +9304,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());

Powered by Google App Engine
This is Rietveld 408576698