diff --git a/pkg/nnbd_migration/lib/src/fix_builder.dart b/pkg/nnbd_migration/lib/src/fix_builder.dart index ebf383d43f9..fd486b8878c 100644 --- a/pkg/nnbd_migration/lib/src/fix_builder.dart +++ b/pkg/nnbd_migration/lib/src/fix_builder.dart @@ -192,6 +192,8 @@ class FixBuilder { class MigrationResolutionHooksImpl implements MigrationResolutionHooks { final FixBuilder _fixBuilder; + final Expando> _collectionElements = Expando(); + FlowAnalysis _flowAnalysis; @@ -240,7 +242,7 @@ class MigrationResolutionHooksImpl implements MigrationResolutionHooks { @override List getListElements(ListLiteral node) { - return node.elements + return _collectionElements[node] ??= node.elements .map(_transformCollectionElement) .where((e) => e != null) .toList(); @@ -254,7 +256,7 @@ class MigrationResolutionHooksImpl implements MigrationResolutionHooks { @override List getSetOrMapElements(SetOrMapLiteral node) { - return node.elements + return _collectionElements[node] ??= node.elements .map(_transformCollectionElement) .where((e) => e != null) .toList();