diff --git a/pkg/front_end/lib/src/fasta/flow_analysis/flow_analysis.dart b/pkg/front_end/lib/src/fasta/flow_analysis/flow_analysis.dart index f220caf0d99b..181210b57430 100644 --- a/pkg/front_end/lib/src/fasta/flow_analysis/flow_analysis.dart +++ b/pkg/front_end/lib/src/fasta/flow_analysis/flow_analysis.dart @@ -884,11 +884,19 @@ class FlowModel { /// be able to remove this method. FlowModel removePromotedAll( Iterable variables, Set referencedVariables) { - Map> newVariableInfo = - _removePromotedAll(variableInfo, variables, referencedVariables); - - if (identical(newVariableInfo, variableInfo)) return this; - + Map> newVariableInfo; + for (Variable variable in variables) { + assert(() { + referencedVariables?.add(variable); + return true; + }()); + VariableModel info = variableInfo[variable]; + if (info?.promotedType != null) { + (newVariableInfo ??= new Map>.from( + variableInfo))[variable] = info.withPromotedType(null); + } + } + if (newVariableInfo == null) return this; return new FlowModel._(reachable, newVariableInfo); } @@ -971,34 +979,6 @@ class FlowModel { return _updateVariableInfo(variable, newInfoForVar); } - /// Updates a "variableInfo" [map] to indicate that a set of [variable] is no - /// longer promoted, treating the map as immutable. - /// - /// If assertions are enabled and [referencedVariables] is not `null`, all - /// variables in [variables] will be stored in [referencedVariables] as a side - /// effect of this call. - Map> _removePromotedAll( - Map> map, - Iterable variables, - Set referencedVariables) { - if (map.isEmpty) return const {}; - Map> result; - for (Variable variable in variables) { - assert(() { - referencedVariables?.add(variable); - return true; - }()); - VariableModel info = map[variable]; - if (info?.promotedType != null) { - (result ??= - new Map>.from(map))[variable] = - info.withPromotedType(null); - } - } - if (result == null) return map; - return result; - } - /// Returns a new [FlowModel] where the information for [variable] is replaced /// with [model]. FlowModel _updateVariableInfo(