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

Unified Diff: lib/compiler/implementation/lib/mock.dart

Issue 10540048: Implement 'as' operator. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: No entries in language.status, vm and dartc already implemented 'as'. Created 8 years, 6 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
Index: lib/compiler/implementation/lib/mock.dart
diff --git a/lib/compiler/implementation/lib/mock.dart b/lib/compiler/implementation/lib/mock.dart
index 89e26be7fe34929bedd1de454fa3c135ea42d88c..d5e601c6756d9f6fa88b4a63743e29dcbbf5f3ba 100644
--- a/lib/compiler/implementation/lib/mock.dart
+++ b/lib/compiler/implementation/lib/mock.dart
@@ -13,6 +13,21 @@ class TypeError extends AssertionError {
String toString() => msg;
}
+/** Thrown by the 'as' operator if the cast isn't valid. */
+class CastException implements TypeError {
+ // TODO(lrn): Change actualType and expectedType to "Type" when reified
+ // types are available.
+ final Object actualType;
+ final Object expectedType;
+
+ CastException(this.actualType, this.expectedType);
+
+ String toString() {
+ return "CastException: Casting value of type $actualType to"
+ " incompatible type $expectedType";
+ }
+}
+
class FallThroughError {
const FallThroughError();
String toString() => "Switch case fall-through.";

Powered by Google App Engine
This is Rietveld 408576698