From 3da80be1400791109174c90632ec6b39bbc72832 Mon Sep 17 00:00:00 2001 From: Alexander Markov Date: Thu, 30 Mar 2023 18:42:08 +0000 Subject: [PATCH] [vm] Fix crashes on record types in mirrors and observatory TEST=ci, manually verified tests with https://dart-review.googlesource.com/c/sdk/+/290760. Fixes https://github.com/dart-lang/sdk/issues/51900 Change-Id: I338bc1b1f2e58d2343f6195ff9d12151edbd90dc Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291969 Reviewed-by: Ryan Macnak Reviewed-by: Ben Konyi Commit-Queue: Alexander Markov --- runtime/lib/mirrors.cc | 6 ++++++ runtime/observatory/lib/src/service/object.dart | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/runtime/lib/mirrors.cc b/runtime/lib/mirrors.cc index 81a6ae89d0a..3529c3d1881 100644 --- a/runtime/lib/mirrors.cc +++ b/runtime/lib/mirrors.cc @@ -530,6 +530,12 @@ static InstancePtr CreateTypeMirror(const AbstractType& type) { if (type.IsFunctionType()) { return CreateFunctionTypeMirror(type); } + if (type.IsRecordType()) { + const Class& cls = + Class::Handle(IsolateGroup::Current()->object_store()->record_class()); + return CreateClassMirror(cls, AbstractType::Handle(cls.DeclarationType()), + Bool::False(), Object::null_instance()); + } if (type.HasTypeClass()) { const Class& cls = Class::Handle(type.type_class()); // Handle void and dynamic types. diff --git a/runtime/observatory/lib/src/service/object.dart b/runtime/observatory/lib/src/service/object.dart index 6e49e9b9359..3086a67eef7 100644 --- a/runtime/observatory/lib/src/service/object.dart +++ b/runtime/observatory/lib/src/service/object.dart @@ -2782,9 +2782,9 @@ M.InstanceKind stringToInstanceKind(String s) { return M.InstanceKind.typeRef; case 'ReceivePort': return M.InstanceKind.receivePort; - case '_RecordType': + case 'RecordType': return M.InstanceKind.recordType; - case '_Record': + case 'Record': return M.InstanceKind.record; case 'Finalizer': return M.InstanceKind.finalizer;