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

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

Issue 2668543002: Fix dynamic calls on JS interop classes. (Closed)
Patch Set: Created 3 years, 11 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 399b4ffb276ee0c03c30b43eec6994c65849d639..d94d1a995bafd3dee2710c5e2322ac35d5c314d3 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
@@ -41,6 +41,26 @@ dload(obj, field) {
if (hasField(type, f) || hasGetter(type, f)) return JS('', '#[#]', obj, f);
if (hasMethod(type, f)) return bind(obj, f, JS('', 'void 0'));
+
+ // Always allow for JS interop objects.
+ if (isJsInterop(obj)) return JS('', '#[#]', obj, f);
+ }
+ return noSuchMethod(
+ obj, new InvocationImpl(field, JS('', '[]'), isGetter: true));
+}
+
+// Version of dload that matches legacy mirrors behavior for JS types.
+dloadMirror(obj, field) {
+ var f = _canonicalMember(obj, field);
+
+ _trackCall(obj);
+ if (f != null) {
+ var type = getType(obj);
+
+ if (hasField(type, f) || hasGetter(type, f)) return JS('', '#[#]', obj, f);
+ if (hasMethod(type, f)) return bind(obj, f, JS('', 'void 0'));
+
+ // Do not support calls on JS interop objects to match Dart2JS behavior.
}
return noSuchMethod(
obj, new InvocationImpl(field, JS('', '[]'), isGetter: true));
@@ -52,24 +72,34 @@ _stripGenericArguments(type) {
return type;
}
-// Version of dput that matches legacy Dart 1 type check rules.
-// TODO(jacobr): remove this temporary workaround when mirrors based
+// Version of dput that matches legacy Dart 1 type check rules and mirrors
+// behavior for JS types.
+// TODO(jacobr): remove the type checking rules workaround when mirrors based
// PageLoader code can generate the correct reified generic types.
-dputLegacy(obj, field, value) {
+dputMirror(obj, field, value) {
var f = _canonicalMember(obj, field);
_trackCall(obj);
if (f != null) {
var objType = getType(obj);
var setterType = getSetterType(objType, f);
if (JS('bool', '# != void 0', setterType)) {
- return JS('', '#[#] = #', obj, f, check(value, _stripGenericArguments(JS('', '#.args[0]', setterType))));
+ return JS(
+ '',
+ '#[#] = #',
+ obj,
+ f,
+ check(
+ value, _stripGenericArguments(JS('', '#.args[0]', setterType))));
} else {
var fieldType = getFieldType(objType, f);
// TODO(jacobr): add metadata tracking which fields are final and throw
// if a setter is called on a final field.
if (JS('bool', '# != void 0', fieldType)) {
- return JS('', '#[#] = #', obj, f, check(value, _stripGenericArguments(fieldType)));
+ return JS('', '#[#] = #', obj, f,
+ check(value, _stripGenericArguments(fieldType)));
}
+
+ // Do not support calls on JS interop objects to match Dart2JS behavior.
}
}
return noSuchMethod(
@@ -83,7 +113,8 @@ dput(obj, field, value) {
var objType = getType(obj);
var setterType = getSetterType(objType, f);
if (JS('bool', '# != void 0', setterType)) {
- return JS('', '#[#] = #', obj, f, check(value, JS('', '#.args[0]', setterType)));
+ return JS('', '#[#] = #', obj, f,
+ check(value, JS('', '#.args[0]', setterType)));
} else {
var fieldType = getFieldType(objType, f);
// TODO(jacobr): add metadata tracking which fields are final and throw
@@ -91,6 +122,10 @@ dput(obj, field, value) {
if (JS('bool', '# != void 0', fieldType)) {
return JS('', '#[#] = #', obj, f, check(value, fieldType));
}
+ // Always allow for JS interop objects.
+ if (isJsInterop(obj)) {
+ return JS('', '#[#] = #', obj, f, value);
+ }
}
}
return noSuchMethod(

Powered by Google App Engine
This is Rietveld 408576698