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

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: Rebased Created 8 years 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 b93f71a7c0bbbfd00d438e08bae262fd3becc8e0..7ed7b2d1177b7f4d399b8e8f7091a6e8fdaf45ea 100644
--- a/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart
+++ b/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart
@@ -538,7 +538,7 @@ class Primitives {
static num numMicroseconds() {
if (JS('bool', 'typeof window != "undefined" && window !== null')) {
var performance = JS('var', 'window.performance');
- if (performance != null &&
+ if (performance != null &&
JS('bool', 'typeof #.webkitNow == "function"', performance)) {
return (1000 * JS('num', '#.webkitNow()', performance)).floor();
}
@@ -961,6 +961,14 @@ throwRuntimeError(message) {
throw new RuntimeError(message);
}
+/**
+ * The SSA builder generates a call to this method when a malformed type is used
+ * in a subtype test.
+ */
+throwMalformedSubtypeError(value, type, reasons) {
+ throw new TypeErrorImplementation.malformedSubtype(value, type, reasons);
+}
+
throwAbstractClassInstantiationError(className) {
throw new AbstractClassInstantiationError(className);
}
@@ -1519,6 +1527,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
@@ -1533,9 +1546,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