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

Unified Diff: pkg/compiler/lib/src/diagnostics/invariant.dart

Issue 2918253002: invariant cleanup (Closed)
Patch Set: Created 3 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
« no previous file with comments | « pkg/compiler/lib/src/common.dart ('k') | tests/compiler/dart2js/exit_code_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/diagnostics/invariant.dart
diff --git a/pkg/compiler/lib/src/diagnostics/invariant.dart b/pkg/compiler/lib/src/diagnostics/invariant.dart
index eb31d04b35a448af833c5de144fc06ccb9b50730..28a6b427eee2d7fcc5af3faf10fbf7684b3dd933 100644
--- a/pkg/compiler/lib/src/diagnostics/invariant.dart
+++ b/pkg/compiler/lib/src/diagnostics/invariant.dart
@@ -26,42 +26,6 @@ assertDebugMode(String message) {
failedAt(NO_LOCATION_SPANNABLE, 'Debug mode is not enabled: $message'));
}
-/**
- * Throws a [SpannableAssertionFailure] if [condition] is
- * [:false:]. [condition] must be either a [:bool:] or a no-arg
- * function returning a [:bool:].
- *
- * Use this method to provide better information for assertion by calling
- * [invariant] as the argument to an [:assert:] statement:
- *
- * assert(invariant(position, isValid));
- *
- * [spannable] must be non-null and will be used to provide positional
- * information in the generated error message.
- */
-bool invariant(Spannable spannable, var condition, {var message: null}) {
- // TODO(johnniwinther): Use [spannable] and [message] to provide better
- // information on assertion errors.
- if (spannable == null) {
- throw new SpannableAssertionFailure(CURRENT_ELEMENT_SPANNABLE,
- 'Spannable was null for invariant. Use CURRENT_ELEMENT_SPANNABLE.');
- }
- if (condition is Function) {
- condition = condition();
- if (condition is String) {
- message = condition;
- condition = false;
- }
- }
- if (!condition) {
- if (message is Function) {
- message = message();
- }
- throw new SpannableAssertionFailure(spannable, message);
- }
- return true;
-}
-
/// Throws a [SpannableAssertionFailure].
///
/// Use this method to provide better information for assertion by calling
@@ -85,5 +49,3 @@ bool failedAt(Spannable spannable, [var message]) {
}
throw new SpannableAssertionFailure(spannable, message);
}
-
-typedef void InternalErrorFunction(Spannable location, String message);
« no previous file with comments | « pkg/compiler/lib/src/common.dart ('k') | tests/compiler/dart2js/exit_code_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698