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>
This commit is contained in:
Robert Nystrom 2019-06-19 21:50:21 +00:00 committed by commit-bot@chromium.org
parent 54b197ccc2
commit ee8d2322d4
8 changed files with 4 additions and 74 deletions

View file

@ -152,7 +152,6 @@ String getWrapperContent(
};
let main = $inputFileNameNoExt.main;
dart.ignoreWhitelistedErrors(false);
try {
dartMainRunner(main, []);
} catch(e) {
@ -191,7 +190,6 @@ String getWrapperHtmlContent(String jsRootDart, String outFileRootBuild) {
import { dart, _isolate_helper } from '$jsRootDart';
import { test } from '$outFileRootBuild';
let main = test.main;
dart.ignoreWhitelistedErrors(false);
main();
</script>
</head>

View file

@ -17,10 +17,6 @@ import 'dart:io';
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 @@ void main(List<String> args) async {
function(sdk, app) {
'use strict';
sdk._debugger.registerDevtoolsFormatter();
sdk.dart.ignoreWhitelistedErrors($ignoreWhitelistedErrors);
app.$basename.main();
});
</script>
@ -228,7 +223,6 @@ void main(List<String> args) async {
}
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 @@ void main(List<String> args) async {
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();

View file

@ -106,7 +106,6 @@ echo "
}
let sdk = require(\"dart_sdk\");
let main = require(\"./$BASENAME\").$BASENAME.main;
sdk.dart.ignoreWhitelistedErrors(false);
try {
sdk._isolate_helper.startRootIsolate(main, []);
} catch(e) {

View file

@ -174,7 +174,6 @@ window.ddcSettings = {
<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();

View file

@ -14,10 +14,6 @@ void trapRuntimeErrors(bool flag) {
JS('', 'dart.__trapRuntimeErrors = #', flag);
}
void ignoreWhitelistedErrors(bool flag) {
JS('', 'dart.__ignoreWhitelistedErrors = #', flag);
}
// TODO(jmesserly): remove this?
void ignoreAllErrors(bool flag) {
JS('', 'dart.__ignoreAllErrors = #', flag);

View file

@ -412,56 +412,6 @@ dindex(obj, index) => callMethod(obj, '_get', null, [index], null, '[]');
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 @@ bool instanceOf(obj, type) {
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 @@ final constants = JS('', 'new Map()');
/// - 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

View file

@ -92,7 +92,7 @@ bool polyfill(window) => JS('', '''(() => {
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 @@ final global_ = JS('', '''
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 @@ void hotRestart() {
for (var m in _cacheMaps) JS('', '#.clear()', m);
_cacheMaps.clear();
JS('', '#.clear()', constantMaps);
JS('', '#.clear()', _ignoreSubtypeCache);
}
/// Marks enqueuing an async operation.

View file

@ -472,8 +472,7 @@ class FunctionType extends AbstractFunctionType {
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;
}
}