Remove support for ignoring cast failures in DDC.
Change-Id: I63aac10df5e26155f394623308a03c1977eba1e3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/106400
Reviewed-by: Vijay Menon <vsm@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
diff --git a/pkg/dev_compiler/test/sourcemap/ddc_common.dart b/pkg/dev_compiler/test/sourcemap/ddc_common.dart
index 2609d4e..33f0a99 100644
--- a/pkg/dev_compiler/test/sourcemap/ddc_common.dart
+++ b/pkg/dev_compiler/test/sourcemap/ddc_common.dart
@@ -152,7 +152,6 @@
};
let main = $inputFileNameNoExt.main;
- dart.ignoreWhitelistedErrors(false);
try {
dartMainRunner(main, []);
} catch(e) {
@@ -191,7 +190,6 @@
import { dart, _isolate_helper } from '$jsRootDart';
import { test } from '$outFileRootBuild';
let main = test.main;
- dart.ignoreWhitelistedErrors(false);
main();
</script>
</head>
diff --git a/pkg/dev_compiler/tool/ddb b/pkg/dev_compiler/tool/ddb
index 6cd6de3..67be845 100755
--- a/pkg/dev_compiler/tool/ddb
+++ b/pkg/dev_compiler/tool/ddb
@@ -17,10 +17,6 @@
import 'package:args/args.dart' show ArgParser;
import 'package:path/path.dart' as path;
-// TODO(vsm): Remove this once we stop ignoring. It's off here, but
-// configurable for manual testing.
-const ignoreWhitelistedErrors = false;
-
void main(List<String> args) async {
void printUsage() {
print('Usage: ddb [options] <dart-script-file>\n');
@@ -201,7 +197,6 @@
function(sdk, app) {
'use strict';
sdk._debugger.registerDevtoolsFormatter();
- sdk.dart.ignoreWhitelistedErrors($ignoreWhitelistedErrors);
app.$basename.main();
});
</script>
@@ -228,7 +223,6 @@
}
let sdk = require(\"dart_sdk\");
let main = require(\"./$basename\").$basename.main;
- sdk.dart.ignoreWhitelistedErrors($ignoreWhitelistedErrors);
try {
sdk._isolate_helper.startRootIsolate(main, []);
} catch(e) {
@@ -259,7 +253,6 @@
import { dart, _isolate_helper } from '$sdkJsPath/dart_sdk.js';
import { $basename } from '$basename.js';
let main = $basename.main;
- dart.ignoreWhitelistedErrors($ignoreWhitelistedErrors);
try {
_isolate_helper.startRootIsolate(() => {}, []);
main();
diff --git a/pkg/dev_compiler/tool/ddc b/pkg/dev_compiler/tool/ddc
index e8d4ad0..493f531 100755
--- a/pkg/dev_compiler/tool/ddc
+++ b/pkg/dev_compiler/tool/ddc
@@ -106,7 +106,6 @@
}
let sdk = require(\"dart_sdk\");
let main = require(\"./$BASENAME\").$BASENAME.main;
- sdk.dart.ignoreWhitelistedErrors(false);
try {
sdk._isolate_helper.startRootIsolate(main, []);
} catch(e) {
diff --git a/pkg/test_runner/lib/src/browser.dart b/pkg/test_runner/lib/src/browser.dart
index c30516b..1a5747e 100644
--- a/pkg/test_runner/lib/src/browser.dart
+++ b/pkg/test_runner/lib/src/browser.dart
@@ -174,7 +174,6 @@
<script type="text/javascript">
requirejs(["$testName", "dart_sdk", "async_helper"],
function($testId, sdk, async_helper) {
- sdk.dart.ignoreWhitelistedErrors(false);
sdk._isolate_helper.startRootIsolate(function() {}, []);
sdk._debugger.registerDevtoolsFormatter();
diff --git a/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart b/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart
index d4cec70..4ba9bc7 100644
--- a/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart
+++ b/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart
@@ -14,10 +14,6 @@
JS('', 'dart.__trapRuntimeErrors = #', flag);
}
-void ignoreWhitelistedErrors(bool flag) {
- JS('', 'dart.__ignoreWhitelistedErrors = #', flag);
-}
-
// TODO(jmesserly): remove this?
void ignoreAllErrors(bool flag) {
JS('', 'dart.__ignoreAllErrors = #', flag);
diff --git a/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart b/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart
index c34bca0..1525959 100644
--- a/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart
+++ b/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart
@@ -412,56 +412,6 @@
dsetindex(obj, index, value) =>
callMethod(obj, '_set', null, [index, value], null, '[]=');
-final _ignoreSubtypeCache = JS('', 'new Map()');
-
-/// Whether [t1] <: [t2], or if [isImplicit] is set and we should ignore the
-/// cast failure from t1 to t2.
-///
-/// See [_isSubtypeOrLegacySubtype] and [ignoreWhitelistedErrors].
-@notNull
-bool _isSubtypeOrIgnorableCastFailure(
- Object t1, Object t2, @notNull bool isImplicit) {
- var result = _isSubtypeOrLegacySubtype(t1, t2);
- return result == true ||
- result == null &&
- isImplicit &&
- JS<bool>('!', 'dart.__ignoreWhitelistedErrors') &&
- _ignoreTypeFailure(t1, t2);
-}
-
-@notNull
-bool _ignoreTypeFailure(Object t1, Object t2) {
- var map = JS('', '#.get(#)', _ignoreSubtypeCache, t1);
- if (map != null) {
- bool result = JS('', '#.get(#)', map, t2);
- if (JS('!', '# !== void 0', result)) return result;
- } else {
- map = JS('', 'new Map()');
- JS('', '#.set(#, #)', _ignoreSubtypeCache, t1, map);
- }
-
- // TODO(vsm): Remove this hack ...
- // This is primarily due to the lack of generic methods,
- // but we need to triage all the types.
- @notNull
- bool result;
- if (_isFutureOr(t2)) {
- // Ignore if we would ignore either side of union.
- var typeArg = getGenericArgs(t2)[0];
- var typeFuture = JS('', '#(#)', getGenericClass(Future), typeArg);
- result =
- _ignoreTypeFailure(t1, typeFuture) || _ignoreTypeFailure(t1, typeArg);
- } else {
- result = isSubtypeOf(t2, unwrapType(Iterable)) &&
- isSubtypeOf(t1, unwrapType(Iterable));
- if (result) {
- _warn('Ignoring cast fail from ${typeName(t1)} to ${typeName(t2)}');
- }
- }
- JS('', '#.set(#, #)', map, t2, result);
- return result;
-}
-
@notNull
@JSExportName('is')
bool instanceOf(obj, type) {
@@ -475,7 +425,7 @@
cast(obj, type, @notNull bool isImplicit) {
if (obj == null) return obj;
var actual = getReifiedType(obj);
- if (_isSubtypeOrIgnorableCastFailure(actual, type, isImplicit)) {
+ if (_isSubtypeOrLegacySubtype(actual, type) == true) {
return obj;
}
return castError(obj, type, isImplicit);
@@ -625,7 +575,7 @@
/// - nested values of the object are themselves already canonicalized.
///
@JSExportName('const')
-const_(obj) => JS('', '''(() => {
+const_(obj) => JS('', '''(() => {
let names = $getOwnNamesAndSymbols($obj);
let count = names.length;
// Index by count. All of the paths through this map
diff --git a/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/runtime.dart b/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/runtime.dart
index 3ec16c9..d79e835 100644
--- a/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/runtime.dart
+++ b/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/runtime.dart
@@ -92,7 +92,7 @@
if (typeof $window.SourceBufferList == "undefined") {
if ('MediaSource' in $window) {
$window.SourceBufferList =
- new $window.MediaSource().sourceBuffers.constructor;
+ new $window.MediaSource().sourceBuffers.constructor;
}
}
if (typeof $window.SpeechRecognition == "undefined") {
@@ -130,9 +130,6 @@
let settings = 'ddcSettings' in globalState ? globalState.ddcSettings : {};
$trapRuntimeErrors(
'trapRuntimeErrors' in settings ? settings.trapRuntimeErrors : false);
- $ignoreWhitelistedErrors(
- 'ignoreWhitelistedErrors' in settings ?
- settings.ignoreWhitelistedErrors : false);
$ignoreAllErrors(
'ignoreAllErrors' in settings ? settings.ignoreAllErrors : false);
@@ -200,7 +197,6 @@
for (var m in _cacheMaps) JS('', '#.clear()', m);
_cacheMaps.clear();
JS('', '#.clear()', constantMaps);
- JS('', '#.clear()', _ignoreSubtypeCache);
}
/// Marks enqueuing an async operation.
diff --git a/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/types.dart b/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/types.dart
index 41c3de7..3c9852c 100644
--- a/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/types.dart
+++ b/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/types.dart
@@ -472,8 +472,7 @@
var actual = JS('', '#[#]', obj, _runtimeType);
// If there's no actual type, it's a JS function.
// Allow them to subtype all Dart function types.
- if (actual == null ||
- _isSubtypeOrIgnorableCastFailure(actual, this, isImplicit)) {
+ if (actual == null || _isSubtypeOrLegacySubtype(actual, this) == true) {
return obj;
}
}