Skip to content

Commit bfcd5af

Browse files
mosuemCommit Queue
authored andcommitted
[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 <[email protected]> Commit-Queue: Moritz Sümmermann <[email protected]>
1 parent 27803be commit bfcd5af

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

pkg/record_use/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.4.2
2+
3+
- Fix empty instance parsing.
4+
15
## 0.4.1
26

37
- Fix bug in signature parsing.

pkg/record_use/lib/src/constant.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ sealed class Constant {
6161
),
6262
),
6363
InstanceConstant._type => InstanceConstant(
64-
fields: (value[_valueKey] as Map<String, Object?>).map(
64+
fields: (value[_valueKey] as Map<String, Object?>? ?? {}).map(
6565
(key, value) => MapEntry(key, constants[value as int]),
6666
),
6767
),

pkg/record_use/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: record_use
22
description: >
33
The serialization logic and API for the usage recording SDK feature.
4-
version: 0.4.1
4+
version: 0.4.2
55
repository: https://github.com/dart-lang/sdk/tree/main/pkg/record_use
66

77
environment:

pkg/record_use/test/test_data.dart

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ final recordedUses = Recordings(
7373
loadingUnit: '3',
7474
location: Location(uri: 'lib/test3.dart'),
7575
),
76+
const InstanceReference(
77+
instanceConstant: InstanceConstant(fields: {}),
78+
loadingUnit: '3',
79+
location: Location(uri: 'lib/test3.dart'),
80+
),
7681
],
7782
},
7883
);
@@ -181,6 +186,9 @@ final recordedUsesJson = '''{
181186
"a": 13,
182187
"b": 14
183188
}
189+
},
190+
{
191+
"type": "Instance"
184192
}
185193
],
186194
"locations": [
@@ -243,6 +251,11 @@ final recordedUsesJson = '''{
243251
"constant_index": 15,
244252
"loading_unit": "3",
245253
"@": 2
254+
},
255+
{
256+
"constant_index": 16,
257+
"loading_unit": "3",
258+
"@": 2
246259
}
247260
]
248261
}

0 commit comments

Comments
 (0)