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

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

Issue 2542833002: Some fixes for lazy JS types (Closed)
Patch Set: Created 4 years 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/sdk/ddc_sdk.sum ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/types.dart
diff --git a/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/types.dart b/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/types.dart
index 91a4ea82f883c5754c3557c915f098774700802a..4d402db12c117e7ed6b633ca64e7a420543b7322 100644
--- a/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/types.dart
+++ b/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/types.dart
@@ -77,8 +77,19 @@ class LazyJSType implements Type {
toString() => _jsTypeCallback != null ? typeName(_rawJSType) : _dartName;
}
+void _warn(arg) {
+ JS('void', 'console.warn(#)', arg);
+}
+
_isInstanceOfLazyJSType(o, LazyJSType t) {
if (t._jsTypeCallback != null) {
+ if (t._rawJSType == null) {
+ var expected = t._dartName;
+ var actual = typeName(getReifiedType(o));
+ _warn('Cannot find native JavaScript type ($expected) '
+ 'to type check $actual');
+ return true;
+ }
return JS('bool', 'dart.is(#, #)', o, t._rawJSType);
}
if (o == null) return false;
@@ -88,6 +99,13 @@ _isInstanceOfLazyJSType(o, LazyJSType t) {
_asInstanceOfLazyJSType(o, LazyJSType t) {
if (t._jsTypeCallback != null) {
+ if (t._rawJSType == null) {
+ var expected = t._dartName;
+ var actual = typeName(getReifiedType(o));
+ _warn('Cannot find native JavaScript type ($expected) '
+ 'to type check $actual');
+ return o;
+ }
return JS('bool', 'dart.as(#, #)', o, t._rawJSType);
}
// Anonymous case: allow any JS type.
@@ -134,6 +152,9 @@ _initialize2() => JS(
$LazyJSType.prototype.as = function as_T(object) {
return $_asInstanceOfLazyJSType(object, this);
};
+ $LazyJSType.prototype._check = function check_T(object) {
+ return $_asInstanceOfLazyJSType(object, this);
+ };
})()''');
class Void extends TypeRep {
« no previous file with comments | « pkg/dev_compiler/lib/sdk/ddc_sdk.sum ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698