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

Unified Diff: pkg/dev_compiler/lib/src/compiler/code_generator.dart

Issue 3003943002: restore FutureOr cast failure ignore (Closed)
Patch Set: 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
« no previous file with comments | « pkg/dev_compiler/lib/js/legacy/dart_sdk.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/dev_compiler/lib/src/compiler/code_generator.dart
diff --git a/pkg/dev_compiler/lib/src/compiler/code_generator.dart b/pkg/dev_compiler/lib/src/compiler/code_generator.dart
index b8a4d6df8e22ed6d961cd8643d50b7ef24bde945..a22c5b8c3fec764e8dbc809a180292ff03437583 100644
--- a/pkg/dev_compiler/lib/src/compiler/code_generator.dart
+++ b/pkg/dev_compiler/lib/src/compiler/code_generator.dart
@@ -1124,27 +1124,27 @@ class CodeGenerator extends Object
if (classElem.library.isDartAsync) {
if (classElem == types.futureOrType.element) {
var typeParamT = classElem.typeParameters[0].type;
- var tOrFutureOfT = js.call('#.is(o) || #.is(o)', [
- _emitType(typeParamT),
- _emitType(types.futureType.instantiate([typeParamT]))
- ]);
+ var typeT = _emitType(typeParamT);
+ var futureOrT = _emitType(types.futureType.instantiate([typeParamT]));
body.add(js.statement('''
#.is = function is_FutureOr(o) {
- return #;
+ return #.is(o) || #.is(o);
}
- ''', [className, tOrFutureOfT]));
+ ''', [className, typeT, futureOrT]));
+ // TODO(jmesserly): remove the fallback to `dart.as`. It's only for the
+ // _ignoreTypeFailure logic.
body.add(js.statement('''
#.as = function as_FutureOr(o) {
- if (o == null || #) return o;
- return #.castError(o, this, false);
+ if (o == null || #.is(o) || #.is(o)) return o;
+ return #.as(o, this, false);
}
- ''', [className, tOrFutureOfT, _runtimeModule]));
+ ''', [className, typeT, futureOrT, _runtimeModule]));
body.add(js.statement('''
#._check = function check_FutureOr(o) {
- if (o == null || #) return o;
- return #.castError(o, this, true);
+ if (o == null || #.is(o) || #.is(o)) return o;
+ return #.as(o, this, true);
}
- ''', [className, tOrFutureOfT, _runtimeModule]));
+ ''', [className, typeT, futureOrT, _runtimeModule]));
return null;
}
}
« no previous file with comments | « pkg/dev_compiler/lib/js/legacy/dart_sdk.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698