[record_use] Parse empty fields in instances

We don't store empty maps of field values in instances, which we forgot about when parsing. This fixes that and adds a ? operator at the right place.

Change-Id: I9377a4aff186d924fbdc3324a51eed79025ceafe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/445320
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Moritz Sümmermann <mosum@google.com>
This commit is contained in:
Moritz
2025-08-14 11:27:01 -07:00
committed by Commit Queue
parent 27803be274
commit bfcd5afb2e
4 changed files with 19 additions and 2 deletions
+4
View File
@@ -1,3 +1,7 @@
## 0.4.2
- Fix empty instance parsing.
## 0.4.1
- Fix bug in signature parsing.
+1 -1
View File
@@ -61,7 +61,7 @@ sealed class Constant {
),
),
InstanceConstant._type => InstanceConstant(
fields: (value[_valueKey] as Map<String, Object?>).map(
fields: (value[_valueKey] as Map<String, Object?>? ?? {}).map(
(key, value) => MapEntry(key, constants[value as int]),
),
),
+1 -1
View File
@@ -1,7 +1,7 @@
name: record_use
description: >
The serialization logic and API for the usage recording SDK feature.
version: 0.4.1
version: 0.4.2
repository: https://github.com/dart-lang/sdk/tree/main/pkg/record_use
environment:
+13
View File
@@ -73,6 +73,11 @@ final recordedUses = Recordings(
loadingUnit: '3',
location: Location(uri: 'lib/test3.dart'),
),
const InstanceReference(
instanceConstant: InstanceConstant(fields: {}),
loadingUnit: '3',
location: Location(uri: 'lib/test3.dart'),
),
],
},
);
@@ -181,6 +186,9 @@ final recordedUsesJson = '''{
"a": 13,
"b": 14
}
},
{
"type": "Instance"
}
],
"locations": [
@@ -243,6 +251,11 @@ final recordedUsesJson = '''{
"constant_index": 15,
"loading_unit": "3",
"@": 2
},
{
"constant_index": 16,
"loading_unit": "3",
"@": 2
}
]
}