Skip to content

Commit 26b6793

Browse files
authored
allow latest pkg:analyzer (#804)
1 parent 81d7abc commit 26b6793

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

json_serializable/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 4.0.1
2+
3+
- Allow latest `package:analyzer`.
4+
15
## 4.0.0
26

37
- Requires Dart 2.12 or greater.

json_serializable/lib/src/json_key_utils.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ JsonKey _from(FieldElement element, JsonSerializable classAnnotation) {
136136
}
137137
assert(targetEnumType != null);
138138
final annotatedEnumType = annotationValue.objectValue.type;
139-
if (annotatedEnumType != targetEnumType) {
139+
if (!_interfaceTypesEqual(annotatedEnumType, targetEnumType)) {
140140
throwUnsupported(
141141
element,
142142
'`$fieldName` has type '
@@ -254,3 +254,11 @@ bool _includeIfNull(
254254
}
255255
return keyIncludeIfNull ?? classIncludeIfNull;
256256
}
257+
258+
bool _interfaceTypesEqual(DartType a, DartType b) {
259+
if (a is InterfaceType && b is InterfaceType) {
260+
// Handle nullability case. Pretty sure this is fine for enums.
261+
return a.element == b.element;
262+
}
263+
return a == b;
264+
}

json_serializable/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: json_serializable
2-
version: 4.0.0
2+
version: 4.0.1
33
description: >-
44
Automatically generate code for converting to and from JSON by annotating
55
Dart classes.
@@ -9,7 +9,7 @@ environment:
99
sdk: '>=2.11.99 <3.0.0'
1010

1111
dependencies:
12-
analyzer: ^0.41.2
12+
analyzer: '>=0.41.2 <2.0.0'
1313
build: ^1.6.1
1414
build_config: ^0.4.4
1515

0 commit comments

Comments
 (0)