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

Unified Diff: runtime/vm/class_finalizer.cc

Issue 11049038: Change compile-time errors into dynamic errors in instance creation expression (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 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.h ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/class_finalizer.cc
===================================================================
--- runtime/vm/class_finalizer.cc (revision 13204)
+++ runtime/vm/class_finalizer.cc (working copy)
@@ -746,6 +746,16 @@
type_argument = arguments.TypeAt(i);
type_argument = FinalizeType(cls, type_argument, finalization);
if (type_argument.IsMalformed()) {
+ // Malformed type arguments to a constructor of a generic type are
+ // reported as a compile-time error.
+ if (finalization >= kCanonicalizeForCreation) {
+ const Script& script = Script::Handle(cls.script());
+ const String& type_name =
+ String::Handle(parameterized_type.UserVisibleName());
+ ReportError(script, parameterized_type.token_pos(),
+ "type '%s' has malformed type argument",
+ type_name.ToCString());
+ }
// 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 || FLAG_error_on_malformed_type) {
@@ -775,6 +785,14 @@
// However, type parameter bounds are checked below, even for a raw type.
if (!arguments.IsNull() && (arguments.Length() != num_type_parameters)) {
// Wrong number of type arguments. The type is malformed.
+ if (finalization >= kCanonicalizeForCreation) {
+ const Script& script = Script::Handle(cls.script());
+ const String& type_name =
+ String::Handle(parameterized_type.UserVisibleName());
+ ReportError(script, parameterized_type.token_pos(),
+ "wrong number of type arguments in type '%s'",
+ type_name.ToCString());
+ }
FinalizeMalformedType(
Error::Handle(), // No previous error.
cls, parameterized_type, finalization,
« no previous file with comments | « runtime/vm/class_finalizer.h ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698