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

Unified Diff: pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/errors.dart

Issue 2835743002: add an option to turn off errors from strong mode is-checks (Closed)
Patch Set: fix comment Created 3 years, 8 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: pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/errors.dart
diff --git a/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/errors.dart b/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/errors.dart
index 156539e2bd43900d5dcaae84174a779b9b840c90..dfaa87289a5dfd7627c916505da391177ec4472b 100644
--- a/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/errors.dart
+++ b/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/errors.dart
@@ -5,6 +5,7 @@ part of dart._runtime;
bool _trapRuntimeErrors = true;
bool _ignoreWhitelistedErrors = true;
+bool _failForWeakModeIsChecks = true;
// Override, e.g., for testing
void trapRuntimeErrors(bool flag) {
@@ -15,6 +16,25 @@ void ignoreWhitelistedErrors(bool flag) {
_ignoreWhitelistedErrors = flag;
}
+/// Throw an exception on `is` checks that would return an unsound answer in
+/// non-strong mode Dart.
+///
+/// For example `x is List<int>` where `x = <Object>['hello']`.
+///
+/// These checks behave correctly in strong mode (they return false), however,
+/// they will produce a different answer if run on a platform without strong
+/// mode. As a debugging feature, these checks can be configured to throw, to
+/// avoid seeing different behavior between modes.
+///
+/// (There are many other ways that different `is` behavior can be observed,
+/// however, even with this flag. The most obvious is due to lack of reified
+/// generic type parameters. This affects generic functions and methods, as
+/// well as generic types when the type parameter was inferred. Setting this
+/// flag to `true` will not catch these differences in behavior..)
+void failForWeakModeIsChecks(bool flag) {
+ _failForWeakModeIsChecks = flag;
+}
+
throwCastError(object, actual, type) => JS(
'',
'''(() => {
« no previous file with comments | « pkg/dev_compiler/test/browser/runtime_tests.js ('k') | pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/operations.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698