Chromium Code Reviews| 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 7b046c9e48160576788e171478b5ff946933fceb..c6d828050249aa7ef1d936f94fbb361e8c14c836 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) { |
|
ahe
2012/11/30 15:44:07
Add a doc comment explaining who calls this.
Johnni Winther
2012/12/04 10:07:17
Done.
|
| + throw new TypeErrorImplementation.malformedSubtype(value, type, reasons); |
| +} |
| + |
| throwAbstractClassInstantiationError(className) { |
| throw new AbstractClassInstantiationError(className); |
| } |
| @@ -1519,6 +1523,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 +1542,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; |
| } |