[ddc] Extending record type 'is' checks to dispatch through its fields' types.
Fixes #52480
Change-Id: I01fed52dc553ecd51a3b7e074bead6aaa6a65628
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/305560
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
diff --git a/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/types.dart b/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/types.dart
index a80ad80..53184f4 100644
--- a/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/types.dart
+++ b/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/types.dart
@@ -2304,11 +2304,17 @@
@JSExportName('is')
bool is_T(obj) {
- if (obj is RecordImpl) {
- var actual = getReifiedType(obj);
- return actual != null && isSubtypeOf(actual, this);
+ if (!(obj is RecordImpl)) return false;
+ if (shape != obj.shape) return false;
+ if (types.length != obj.values.length) {
+ return false;
}
- return false;
+ for (var i = 0; i < types.length; i++) {
+ if (!JS<bool>('!', '#.is(#)', types[i], obj.values[i])) {
+ return false;
+ }
+ }
+ return true;
}
@JSExportName('as')