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

Unified Diff: tool/input_sdk/private/js_helper.dart

Issue 2026133002: Throw TypeError instead of CastError for type coercions. (Closed) Base URL: https://github.com/dart-lang/dev_compiler@master
Patch Set: Created 4 years, 7 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 | « tool/input_sdk/private/ddc_runtime/utils.dart ('k') | tool/sdk_expected_errors.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tool/input_sdk/private/js_helper.dart
diff --git a/tool/input_sdk/private/js_helper.dart b/tool/input_sdk/private/js_helper.dart
index 9048d0facc5d6e72471edf702ef79b1e60849278..8df5529ac0209e2256bd1d3e9f4bd67cd3acf5dd 100644
--- a/tool/input_sdk/private/js_helper.dart
+++ b/tool/input_sdk/private/js_helper.dart
@@ -782,9 +782,9 @@ class TypeErrorImplementation extends Error implements TypeError {
/**
* 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'";
+ TypeErrorImplementation(Object value, Object actualType, Object expectedType)
+ : message = "Type '${actualType}' is not a subtype "
+ "of type '${expectedType}'";
TypeErrorImplementation.fromMessage(String this.message);
@@ -799,13 +799,40 @@ class CastErrorImplementation extends Error implements CastError {
/**
* Normal cast error caused by a failed type cast.
*/
- CastErrorImplementation(Object actualType, Object expectedType)
- : message = "CastError: Casting value of type $actualType to"
- " incompatible type $expectedType";
+ CastErrorImplementation(Object value, Object actualType, Object expectedType)
Leaf 2016/06/01 17:01:51 Why the unused "value" parameter?
sra1 2016/06/01 17:07:13 I will add a TODO, but I would eventually like the
+ : message = "CastError: Casting value of type '$actualType' to"
+ " incompatible type '$expectedType'";
String toString() => message;
}
+/// Thrown by type assertions that fail in strong mode that would have passed in
+/// standard Dart.
+class StrongModeTypeError extends Error implements TypeError, StrongModeError {
+ final String message;
+ StrongModeTypeError(Object value, Object actualType, Object expectedType)
+ : message = "Type '${actualType}' is not a subtype "
+ "of type '${expectedType}' in strong mode";
+ String toString() => message;
+}
+
+/// Thrown by casts that fail in strong mode that would have passed in standard
+/// Dart.
+class StrongModeCastError extends Error implements CastError, StrongModeError {
+ final String message;
+ StrongModeCastError(Object value, Object actualType, Object expectedType)
+ : message = "CastError: Casting value of type '$actualType' to"
+ " type '$expectedType' which is incompatible in strong mode";
+ String toString() => message;
+}
+
+/// Used for Strong-mode errors other than type assertions and casts.
+class StrongModeErrorImplementation extends Error implements StrongModeError {
+ final String message;
+ StrongModeErrorImplementation(this.message);
+ String toString() => message;
+}
+
class FallThroughErrorImplementation extends FallThroughError {
FallThroughErrorImplementation();
String toString() => "Switch case fall-through.";
« no previous file with comments | « tool/input_sdk/private/ddc_runtime/utils.dart ('k') | tool/sdk_expected_errors.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698