Skip to content

Commit 211d81f

Browse files
authored
Fix another type issue, prepare for v1.2.5 (#622)
`root.fields` has a runtime type of `Iterable<FieldElementImpl>` which is not compatible with the value used in the `addAll` call. Using collection literal syntax to fix the issue Runtime error: type 'ExpandIterable<InterfaceType, FieldElement>' is not a subtype of type 'Iterable<FieldElementImpl>' of 'other'
1 parent f8f5dc7 commit 211d81f

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

source_gen/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.2.5
2+
3+
* Fix another issue with overly specific types.
4+
15
## 1.2.4
26

37
* Fix overly-specific cast.

source_gen/lib/src/constants/utils.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@ void assertHasField(InterfaceElement root, String name) {
1717
}
1818
element = element.supertype?.element2;
1919
}
20-
final allFields = root.fields.toSet()
21-
..addAll(root.allSupertypes.expand((t) => t.element2.fields));
20+
final allFields = {
21+
...root.fields,
22+
for (var t in root.allSupertypes) ...t.element2.fields,
23+
};
24+
2225
throw FormatException(
2326
'Class ${root.name} does not have field "$name".',
2427
'Fields: \n - ${allFields.map((e) => e.name).join('\n - ')}',

source_gen/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: source_gen
2-
version: 1.2.4
2+
version: 1.2.5
33
description: >-
44
Source code generation builders and utilities for the Dart build system
55
repository: https://github.com/dart-lang/source_gen

0 commit comments

Comments
 (0)