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

Unified Diff: sdk/lib/_internal/js_runtime/lib/js_helper.dart

Issue 1346093003: Revert "Add optional message to assert in Dart2js - continued" (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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 | « pkg/compiler/lib/src/world.dart ('k') | sdk/lib/core/errors.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/js_runtime/lib/js_helper.dart
diff --git a/sdk/lib/_internal/js_runtime/lib/js_helper.dart b/sdk/lib/_internal/js_runtime/lib/js_helper.dart
index 309f255f7a75d48a2fe662fcede9a3bab75e4d9e..b4ab91c192b236631901ea56dfd63960692ea18a 100644
--- a/sdk/lib/_internal/js_runtime/lib/js_helper.dart
+++ b/sdk/lib/_internal/js_runtime/lib/js_helper.dart
@@ -3321,33 +3321,18 @@ class FallThroughErrorImplementation extends FallThroughError {
/**
* Helper function for implementing asserts. The compiler treats this specially.
- *
- * Returns the negation of the condition. That is: `true` if the assert should
- * fail.
- */
-bool assertTest(condition) {
- // Do bool success check first, it is common and faster than 'is Function'.
- if (true == condition) return false;
- if (condition is Function) condition = condition();
- if (condition is bool) return !condition;
- throw new TypeErrorImplementation(condition, 'bool');
-}
-
-/**
- * Helper function for implementing asserts with messages.
- * The compiler treats this specially.
*/
-void assertThrow(Object message) {
- throw new _AssertionError(message);
-}
-
-/**
- * Helper function for implementing asserts without messages.
- * The compiler treats this specially.
- */
-@NoInline()
void assertHelper(condition) {
- if (assertTest(condition)) throw new AssertionError();
+ // Do a bool check first because it is common and faster than 'is Function'.
+ if (condition is !bool) {
+ if (condition is Function) condition = condition();
+ if (condition is !bool) {
+ throw new TypeErrorImplementation(condition, 'bool');
+ }
+ }
+ // Compare to true to avoid boolean conversion check in checked
+ // mode.
+ if (true != condition) throw new AssertionError();
}
/**
@@ -4010,10 +3995,3 @@ void badMain() {
void mainHasTooManyParameters() {
throw new MainError("'main' expects too many parameters.");
}
-
-class _AssertionError extends AssertionError {
- final _message;
- _AssertionError(this._message);
-
- String toString() => "Assertion failed: " + Error.safeToString(_message);
-}
« no previous file with comments | « pkg/compiler/lib/src/world.dart ('k') | sdk/lib/core/errors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698