Skip to content

Commit a1471e1

Browse files
committed
final inference fixes
1 parent b334072 commit a1471e1

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

analysis_options.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
analyzer:
2-
strong-mode: true
2+
strong-mode:
3+
implicit-casts: false
34
errors:
45
unused_element: error
56
unused_import: error

lib/src/json_serializable_generator.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ class JsonSerializableGenerator
357357

358358
// If `itemSubVal` is the same, then we don't need to do anything fancy
359359
if (itemVal == itemSubVal) {
360-
return varExpression;
360+
return '$varExpression as List';
361361
}
362362

363363
var output = "($varExpression as List)?.map(($itemVal) => $itemSubVal)";

test/json_serializable_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ void main() {
159159
await _getClassForCodeString('ParentObjectWithDynamicChildren');
160160
var output = await _generator.generate(element, null);
161161

162-
expect(output, contains('children = json[\'children\'];'));
162+
expect(output, contains('children = json[\'children\'] as List;'));
163163
});
164164

165165
test('class with list of int is cast for strong mode', () async {

test/test_files/json_test_example.g.dart

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

0 commit comments

Comments
 (0)