[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 <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
This commit is contained in:
Nicholas Shahan 2022-12-03 00:26:58 +00:00 committed by Commit Queue
parent eb827958a4
commit bf548e788a

View file

@ -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);
}