Skip to content

Commit 55a821b

Browse files
committed
fix: fixes after rebase
1 parent b62058d commit 55a821b

File tree

7 files changed

+72
-89
lines changed

7 files changed

+72
-89
lines changed

example/lib/complex_sealed_class_examples.g.dart

Lines changed: 20 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/lib/sealed_class_example.g.dart

Lines changed: 22 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

json_annotation/CHANGELOG.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
- Add `JsonSerializable.unionRename`
44
- Add `JsonSerializable.unionDiscriminator`
5-
6-
## 4.9.1-wip
7-
85
- Require Dart 3.8
96

107
## 4.9.0

json_serializable/CHANGELOG.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
- Add support for deserializing union json to sealed class
44
- Add support for serializing sealed class to union json
5-
6-
## 6.9.6-wip
7-
85
- Move `package:collection` to a dev dependency.
96
- Use new `null-aware element` feature in generated code.
107
- Require Dart 3.8

json_serializable/example/sealed_example.g.dart

Lines changed: 16 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

json_serializable/lib/src/generator_helper.dart

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import 'package:analyzer/dart/element/element.dart';
66
import 'package:build/build.dart';
7-
import 'package:collection/collection.dart';
87
import 'package:source_gen/source_gen.dart';
98

109
import '../type_helper.dart';
@@ -56,7 +55,7 @@ class GeneratorHelper extends HelperCore with EncodeHelper, DecodeHelper {
5655
),
5756
);
5857

59-
if (sealedSupersAndConfigs.firstWhereOrNull((e) => e.config == null)
58+
if (sealedSupersAndConfigs.where((e) => e.config == null).firstOrNull
6059
case final notAnnotated? when sealedSupersAndConfigs.isNotEmpty) {
6160
throw InvalidGenerationSourceError(
6261
'The class `${element.displayName}` is annotated '
@@ -82,9 +81,11 @@ class GeneratorHelper extends HelperCore with EncodeHelper, DecodeHelper {
8281
);
8382
}
8483

85-
if (sealedSupersAndConfigs.firstWhereOrNull(
86-
(e) => e.config?.unionDiscriminator == config.unionDiscriminator,
87-
)
84+
if (sealedSupersAndConfigs
85+
.where(
86+
(e) => e.config?.unionDiscriminator == config.unionDiscriminator,
87+
)
88+
.firstOrNull
8889
case final conflictingSuper? when element.isSealed) {
8990
throw InvalidGenerationSource(
9091
'The classes `${conflictingSuper.classElement.displayName}` and '
@@ -97,9 +98,9 @@ class GeneratorHelper extends HelperCore with EncodeHelper, DecodeHelper {
9798
);
9899
}
99100

100-
if (sealedSupersAndConfigs.firstWhereOrNull(
101-
(e) => e.config?.createToJson != config.createToJson,
102-
)
101+
if (sealedSupersAndConfigs
102+
.where((e) => e.config?.createToJson != config.createToJson)
103+
.firstOrNull
103104
case final diffSuper?) {
104105
throw InvalidGenerationSourceError(
105106
'The class `${diffSuper.classElement.displayName}` is sealed but its '
@@ -191,9 +192,9 @@ class GeneratorHelper extends HelperCore with EncodeHelper, DecodeHelper {
191192
..fold(<String>{}, (Set<String> set, fe) {
192193
final jsonKey = nameAccess(fe);
193194

194-
if (sealedSupersAndConfigs.firstWhereOrNull(
195-
(e) => e.config?.unionDiscriminator == jsonKey,
196-
)
195+
if (sealedSupersAndConfigs
196+
.where((e) => e.config?.unionDiscriminator == jsonKey)
197+
.firstOrNull
197198
case final conflict?) {
198199
throw InvalidGenerationSourceError(
199200
'The JSON key `$jsonKey` is conflicting with the discriminator '

json_serializable/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ topics:
1515
resolution: workspace
1616

1717
dependencies:
18-
analyzer: '>=6.9.0 <8.0.0'
18+
analyzer: '>=7.4.0 <8.0.0'
1919
async: ^2.10.0
2020
build: ^2.4.1
2121
build_config: ^1.1.0
22-
dart_style: '>=2.3.7 <4.0.0'
22+
dart_style: '>=3.1.0 <4.0.0'
2323

2424
# Use a tight version constraint to ensure that a constraint on
2525
# `json_annotation` properly constrains all features it provides.

0 commit comments

Comments
 (0)