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

Unified Diff: sdk/lib/_internal/compiler/implementation/lib/js_helper.dart

Issue 11412245: MalformedType used for all invalid type annotations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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: sdk/lib/_internal/compiler/implementation/lib/js_helper.dart
diff --git a/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart b/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart
index f10d3d72408a924c2bf51196010434ddaa2dc7e6..53a395d2dcee76464f35a97f1c8e71bf8bca28ec 100644
--- a/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart
+++ b/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart
@@ -961,6 +961,10 @@ throwRuntimeError(message) {
throw new RuntimeError(message);
}
+throwMalformedSubtypeError(value, type, reasons) {
ngeoffray 2012/11/30 12:00:40 Why this helper and not inlining it line 1511?
Johnni Winther 2012/12/04 10:07:17 The builder will generate calls for it.
+ throw new TypeErrorImplementation.malformedSubtype(value, type, reasons);
+}
+
throwAbstractClassInstantiationError(className) {
throw new AbstractClassInstantiationError(className);
}
@@ -1502,6 +1506,11 @@ voidTypeCheck(value) {
throw new TypeErrorImplementation(value, 'void');
}
+malformedTypeCheck(value, type, reasons) {
+ if (value == null) return value;
+ throwMalformedSubtypeError(value, type, reasons);
+}
+
/**
* Special interface recognized by the compiler and implemented by DOM
* objects that support integer indexing. This interface is not
@@ -1516,9 +1525,22 @@ abstract class JavaScriptIndexingBehavior {
/** Thrown by type assertions that fail. */
class TypeErrorImplementation implements TypeError {
final String message;
+
+ /**
+ * Normal type error caused by a failed subtype test.
+ */
TypeErrorImplementation(Object value, String type)
- : message = "type '${Primitives.objectTypeName(value)}' is not a subtype "
- "of type '$type'";
+ : message = "type '${Primitives.objectTypeName(value)}' is not a subtype "
+ "of type '$type'";
+
+ /**
+ * Type error caused by a subtype test on a malformed type.
+ */
+ TypeErrorImplementation.malformedSubtype(Object value,
+ String type, String reasons)
+ : message = "type '${Primitives.objectTypeName(value)}' is not a subtype "
+ "of type '$type' because '$type' is malformed: $reasons.";
+
String toString() => message;
}

Powered by Google App Engine
This is Rietveld 408576698