diff --git a/pkg/record_use/CHANGELOG.md b/pkg/record_use/CHANGELOG.md index ca6b75d6f18..e0d7d562c4a 100644 --- a/pkg/record_use/CHANGELOG.md +++ b/pkg/record_use/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.4.2 + +- Fix empty instance parsing. + ## 0.4.1 - Fix bug in signature parsing. diff --git a/pkg/record_use/lib/src/constant.dart b/pkg/record_use/lib/src/constant.dart index 81e0dfd6bb3..e86f5595f12 100644 --- a/pkg/record_use/lib/src/constant.dart +++ b/pkg/record_use/lib/src/constant.dart @@ -61,7 +61,7 @@ sealed class Constant { ), ), InstanceConstant._type => InstanceConstant( - fields: (value[_valueKey] as Map).map( + fields: (value[_valueKey] as Map? ?? {}).map( (key, value) => MapEntry(key, constants[value as int]), ), ), diff --git a/pkg/record_use/pubspec.yaml b/pkg/record_use/pubspec.yaml index c42244111a3..d7c093fc8f4 100644 --- a/pkg/record_use/pubspec.yaml +++ b/pkg/record_use/pubspec.yaml @@ -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: diff --git a/pkg/record_use/test/test_data.dart b/pkg/record_use/test/test_data.dart index c1aae17c3cc..42171c2763e 100644 --- a/pkg/record_use/test/test_data.dart +++ b/pkg/record_use/test/test_data.dart @@ -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 } ] }