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

Unified Diff: runtime/vm/object.cc

Issue 9665013: Generate a dynamic type error when creating an instance with a bound error. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 9 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') | runtime/vm/parser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
===================================================================
--- runtime/vm/object.cc (revision 5248)
+++ runtime/vm/object.cc (working copy)
@@ -2751,12 +2751,18 @@
}
-static RawError* FormatError(const Script& script,
+static RawError* FormatError(const Error& prev_error,
+ const Script& script,
intptr_t token_index,
const char* format, ...) {
va_list args;
va_start(args, format);
- return Parser::FormatError(script, token_index, "Error", format, args);
+ if (prev_error.IsNull()) {
+ return Parser::FormatError(script, token_index, "Error", format, args);
+ } else {
+ return Parser::FormatErrorWithAppend(prev_error, script, token_index,
+ "Error", format, args);
+ }
}
@@ -2779,10 +2785,16 @@
bound = bounds.TypeAt(i);
if (!bound.IsDynamicType()) {
type = TypeAt(offset + i);
- if (!bound.IsInstantiated()) {
+ Error& malformed_bound_error = Error::Handle();
+ if (bound.IsMalformed()) {
+ malformed_bound_error = bound.malformed_error();
+ } else if (!bound.IsInstantiated()) {
bound = bound.InstantiateFrom(bounds_instantiator);
}
- if (!type.IsSubtypeOf(bound, malformed_error)) {
+ if (!malformed_bound_error.IsNull() ||
+ !type.IsSubtypeOf(bound, malformed_error)) {
+ // Ignore this bound error if another malformed error was already
+ // reported for this type test.
if (malformed_error->IsNull()) {
const String& type_argument_name = String::Handle(type.Name());
const String& class_name = String::Handle(cls.Name());
@@ -2793,7 +2805,8 @@
const TypeArguments& type_parameters =
TypeArguments::Handle(cls.type_parameters());
type = type_parameters.TypeAt(i);
- *malformed_error ^= FormatError(script, type.token_index(),
+ *malformed_error ^= FormatError(malformed_bound_error,
+ script, type.token_index(),
"type argument '%s' does not "
"extend bound '%s' of '%s'\n",
type_argument_name.ToCString(),
« no previous file with comments | « runtime/vm/class_finalizer.cc ('k') | runtime/vm/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698