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

Unified Diff: runtime/vm/parser.cc

Issue 10035058: Throw a type error in production mode when the type of the type test is not (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 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/class_finalizer.cc ('k') | tests/co19/co19-runtime.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 6753)
+++ runtime/vm/parser.cc (working copy)
@@ -3166,11 +3166,16 @@
do {
ConsumeToken();
type = ParseType(finalization);
- types.Add(type);
// Only keep the error for the first malformed type argument.
if (malformed_error->IsNull() && type.IsMalformed()) {
*malformed_error = type.malformed_error();
}
+ // Map a malformed type argument to Dynamic, so that malformed types with
+ // a resolved type class are handled properly in production mode.
+ if (type.IsMalformed()) {
+ type = Type::DynamicType();
+ }
+ types.Add(type);
} while (CurrentToken() == Token::kCOMMA);
Token::Kind token = CurrentToken();
if ((token == Token::kGT) || (token == Token::kSHR)) {
@@ -7217,7 +7222,9 @@
}
AbstractType& type = AbstractType::Handle(
Type::New(type_class, type_arguments, type_name.ident_pos));
- if (!malformed_error.IsNull()) {
+ // In production mode, malformed type arguments are mapped to Dynamic.
+ // In checked mode, a type with malformed type arguments is malformed.
+ if (FLAG_enable_type_checks && !malformed_error.IsNull()) {
Type& parameterized_type = Type::Handle();
parameterized_type ^= type.raw();
parameterized_type.set_type_class(Class::Handle(Object::dynamic_class()));
« no previous file with comments | « runtime/vm/class_finalizer.cc ('k') | tests/co19/co19-runtime.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698