Skip to content

Commit

Permalink
[ddc] Extending record type 'is' checks to dispatch through its field…
Browse files Browse the repository at this point in the history
…s' 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>
  • Loading branch information
Markzipan authored and Commit Queue committed May 25, 2023
1 parent 8dfd25a commit 44b5ca7
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/types.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2304,11 +2304,17 @@ class RecordType extends DartType {

@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')
Expand Down

0 comments on commit 44b5ca7

Please sign in to comment.