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

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

Issue 2996573002: fix #28988, remove throw on Dart1 incompatible is-checks for dartdevc (Closed)
Patch Set: fix changelog Created 3 years, 4 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/operations.dart
diff --git a/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/operations.dart b/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/operations.dart
index 17066d60754c0da97f28774e4fbb6dbfe98f8774..91f541ea3cf5789bb0091a2c03ac2ee745ba91be 100644
--- a/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/operations.dart
+++ b/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/operations.dart
@@ -482,56 +482,44 @@ final _ignoreTypeFailure = JS('', '''(() => {
});
})()''');
-/// Returns true if [obj] is an instance of [type]
-/// Returns true if [obj] is a JS function and [type] is a function type
-/// Returns false if [obj] is not an instance of [type] in both spec
-/// and strong mode
-/// Returns null if [obj] is not an instance of [type] in strong mode
-/// but might be in spec mode
+/// Returns true if [obj] is an instance of [type] in strong mode, otherwise
+/// false.
+///
+/// This also allows arbitrary JS function objects to be subtypes of every Dart
+/// function types.
bool strongInstanceOf(obj, type, ignoreFromWhiteList) => JS('', '''(() => {
let actual = $getReifiedType($obj);
let result = $isSubtype(actual, $type);
- if (result || (actual == $int && $isSubtype($double, $type))) return true;
- if (actual == $jsobject && $_isFunctionType(type) &&
- typeof(obj) === 'function') {
+ if (result ||
+ (actual == $int && $isSubtype($double, $type)) ||
+ (actual == $jsobject && $_isFunctionType(type) &&
+ typeof(obj) === 'function')) {
return true;
}
- if (result === false) return false;
- if (!dart.__ignoreWhitelistedErrors ||
- ($ignoreFromWhiteList == void 0)) {
- return result;
+ if (result === null &&
+ dart.__ignoreWhitelistedErrors &&
+ $ignoreFromWhiteList &&
+ $_ignoreTypeFailure(actual, $type)) {
+ return true;
}
- if ($_ignoreTypeFailure(actual, $type)) return true;
- return result;
+ return false;
})()''');
/// Returns true if [obj] is null or an instance of [type]
/// Returns false if [obj] is non-null and not an instance of [type]
/// in strong mode
-instanceOfOrNull(obj, type) => JS('', '''(() => {
+bool instanceOfOrNull(obj, type) {
// If strongInstanceOf returns null, convert to false here.
- if (($obj == null) || $strongInstanceOf($obj, $type, true)) return true;
- return false;
-})()''');
+ return obj == null || JS('bool', '#', strongInstanceOf(obj, type, true));
+}
@JSExportName('is')
-bool instanceOf(obj, type) => JS('', '''(() => {
- if ($obj == null) {
- return $type == $Null || $_isTop($type);
+bool instanceOf(obj, type) {
+ if (obj == null) {
+ return JS('bool', '# == # || #', type, Null, _isTop(type));
}
- let result = $strongInstanceOf($obj, $type);
- if (result !== null) return result;
- if (!dart.__failForWeakModeIsChecks) return false;
- let actual = $getReifiedType($obj);
- let message = 'Strong mode is-check failure: ' +
- $typeName(actual) + ' does not soundly subtype ' +
- $typeName($type);
- if (!dart.__ignoreAllErrors) {
- $throwStrongModeError(message);
- }
- console.error(message);
- return true; // Match Dart 1.0 Semantics when ignoring errors.
-})()''');
+ return strongInstanceOf(obj, type, false);
+}
@JSExportName('as')
cast(obj, type) {

Powered by Google App Engine
This is Rietveld 408576698