From bf548e788aac22a4d2442826694f4492078287a5 Mon Sep 17 00:00:00 2001 From: Nicholas Shahan Date: Sat, 3 Dec 2022 00:26:58 +0000 Subject: [PATCH] [ddc] Clarify class vs type references for records Preparation for separating type representation from classes. Use `JS_CLASS_REF(_RecordImpl)` to inline a reference to the class in JavaScript (not the type representation). Use a standard Dart `is _RecordImpl` type test and let the compiler produce the correct type test code. Change-Id: I160312d61137ad0c6b2aa30b8aeba4acbe848df9 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273523 Reviewed-by: Mark Zhou Commit-Queue: Nicholas Shahan --- .../_internal/js_dev_runtime/private/ddc_runtime/types.dart | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 3932915f375..3efd024825c 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 @@ -2344,7 +2344,8 @@ Object registerRecord(@notNull String shapeRecipe, @notNull int positionals, return cached; } - Object recordClass = JS('!', 'class _Record extends # {}', _RecordImpl); + Object recordClass = + JS('!', 'class _Record extends # {}', JS_CLASS_REF(_RecordImpl)); // Add a 'new' function to be used instead of a constructor // (which is disallowed on dart objects). Object newRecord = JS( @@ -2478,7 +2479,7 @@ class RecordType extends DartType { @JSExportName('is') bool is_T(obj) { - if (JS('!', '# instanceof #', obj, _RecordImpl)) { + if (obj is _RecordImpl) { var actual = getReifiedType(obj); return actual != null && isSubtypeOf(actual, this); }