[ddc] Fix RecordImpl instanceof test

The `instanceof` operator needs a reference to the JavaScript class
instead of the Dart Type. This avoids an issue when changing the
type representation in the new runtime type system where the two
are no longer interchangeable.

Update the parameter name for `_jsInstanceof()` which which was
probably the remnants of a copy paste.

Change-Id: I1d3fcf1915fb3e189ad7f3e130e101009ee50381
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296341
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
This commit is contained in:
Nicholas Shahan 2023-04-19 21:32:33 +00:00 committed by Commit Queue
parent 0698c194ae
commit 2a56d8ba84
2 changed files with 5 additions and 5 deletions

View file

@ -122,7 +122,7 @@ dload(obj, field) {
if (hasMethod(type, f)) return bind(obj, f, null);
// Handle record types by trying to access [f] via convenience getters.
if (JS<bool>('!', '# instanceof #', obj, _RecordImpl) && f is String) {
if (_jsInstanceOf(obj, _RecordImpl) && f is String) {
// It is a compile-time error for record names to clash, so we don't
// need to check the positionals or named elements in any order.
var value = JS('', '#.#', obj, f);

View file

@ -1431,17 +1431,17 @@ bool _isTop(type) {
return _equalType(type, dynamic) || JS('!', '# === #', type, void_);
}
/// Wraps the JavaScript `instanceof` operator returning `true` if [type] is an
/// instance of [cls].
/// Wraps the JavaScript `instanceof` operator returning `true` if [obj] is an
/// instance of the JavaScript class reference for [cls].
///
/// This method is equivalent to:
///
/// JS<bool>('!', '# instanceof #', type, cls);
/// JS<bool>('!', '# instanceof #', obj, JS_CLASS_REF(cls));
///
/// but the code is generated by the compiler directly (a low-tech way of
/// inlining).
@notNull
external bool _jsInstanceOf(type, cls);
external bool _jsInstanceOf(obj, cls);
/// Returns `true` if [type] is [cls].
///