Skip to content

Commit 723cbc1

Browse files
fishythefishCommit Queue
authored andcommitted
[dart2js] Change Enumset.operator +/- to Enumset.add/remove.
Change-Id: I92a97911531b699c5fc17cc37d5540c3fc44e63d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/396566 Commit-Queue: Mayank Patke <[email protected]> Reviewed-by: Stephen Adams <[email protected]>
1 parent 9f5217d commit 723cbc1

File tree

7 files changed

+46
-45
lines changed

7 files changed

+46
-45
lines changed

pkg/compiler/lib/src/common/codegen.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ class _CodegenImpact extends WorldImpactBuilderImpl implements CodegenImpact {
218218
bool get usesInterceptor => _usesInterceptor;
219219

220220
void registerAsyncMarker(AsyncMarker asyncMarker) {
221-
_asyncMarkers += asyncMarker;
221+
_asyncMarkers = _asyncMarkers.add(asyncMarker);
222222
}
223223

224224
@override

pkg/compiler/lib/src/inferrer/type_graph_nodes.dart

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ abstract class TypeInformation {
228228
}
229229

230230
void giveUp(InferrerEngine inferrer, {bool clearInputs = true}) {
231-
_flags += _Flag.abandonInferencing;
231+
_flags = _flags.add(_Flag.abandonInferencing);
232232
// Do not remove [this] as a user of nodes in [inputs],
233233
// because our tracing analysis could be interested in tracing
234234
// this node.
@@ -275,14 +275,14 @@ abstract class TypeInformation {
275275
// Do not remove users because the tracing analysis could be interested
276276
// in tracing the users of this node.
277277
_inputs = STOP_TRACKING_INPUTS_MARKER;
278-
_flags += _Flag.abandonInferencing;
279-
_flags += _Flag.isStable;
278+
_flags = _flags.add(_Flag.abandonInferencing);
279+
_flags = _flags.add(_Flag.isStable);
280280
}
281281

282282
void maybeResume() {
283283
if (!mightResume) return;
284-
_flags -= _Flag.abandonInferencing;
285-
_flags -= _Flag.doNotEnqueue;
284+
_flags = _flags.remove(_Flag.abandonInferencing);
285+
_flags = _flags.remove(_Flag.doNotEnqueue);
286286
}
287287

288288
/// Destroys information not needed after type inference.
@@ -501,10 +501,10 @@ abstract class MemberTypeInformation extends ElementTypeInformation
501501
void markCalled() {
502502
if (_flags.contains(_Flag.isCalled)) {
503503
if (!_flags.contains(_Flag.isCalledMoreThanOnce)) {
504-
_flags += _Flag.isCalledMoreThanOnce;
504+
_flags = _flags.add(_Flag.isCalledMoreThanOnce);
505505
}
506506
} else {
507-
_flags += _Flag.isCalled;
507+
_flags = _flags.add(_Flag.isCalled);
508508
}
509509
}
510510

@@ -809,7 +809,7 @@ class ParameterTypeInformation extends ElementTypeInformation {
809809
.abstractValue,
810810
_inputType = abstractValueDomain.uncomputedType,
811811
super._internal() {
812-
_flags += _Flag.isClosureParameter;
812+
_flags = _flags.add(_Flag.isClosureParameter);
813813
}
814814

815815
ParameterTypeInformation.static(
@@ -834,7 +834,7 @@ class ParameterTypeInformation extends ElementTypeInformation {
834834
_createInstanceMemberStaticType(abstractValueDomain, type, _method),
835835
_inputType = abstractValueDomain.uncomputedType,
836836
super._withInputs() {
837-
_flags += _Flag.isInstanceMemberParameter;
837+
_flags = _flags.add(_Flag.isInstanceMemberParameter);
838838
_flags = _flags.update(_Flag.isVirtual, isVirtual);
839839
}
840840

@@ -1223,12 +1223,12 @@ class DynamicCallSiteTypeInformation<T extends ir.Node>
12231223
}
12241224

12251225
void invalidateTargetsIncludeComplexNoSuchMethod() {
1226-
_flags -= _Flag.hasTargetsIncludeComplexNoSuchMethod;
1226+
_flags = _flags.remove(_Flag.hasTargetsIncludeComplexNoSuchMethod);
12271227
}
12281228

12291229
bool targetsIncludeComplexNoSuchMethod(InferrerEngine inferrer) {
12301230
if (!_hasTargetsIncludeComplexNoSuchMethod) {
1231-
_flags += _Flag.hasTargetsIncludeComplexNoSuchMethod;
1231+
_flags = _flags.add(_Flag.hasTargetsIncludeComplexNoSuchMethod);
12321232
final value = targets.any((target) => inferrer.memberHierarchyBuilder
12331233
.anyTargetMember(target, (MemberEntity e) {
12341234
return e.isFunction &&
@@ -1572,7 +1572,7 @@ class ClosureCallSiteTypeInformation extends CallSiteTypeInformation {
15721572
/// type.
15731573
class ConcreteTypeInformation extends TypeInformation {
15741574
ConcreteTypeInformation(super.type) : super.untracked() {
1575-
_flags += _Flag.isStable;
1575+
_flags = _flags.add(_Flag.isStable);
15761576
}
15771577

15781578
@override

pkg/compiler/lib/src/ir/impact_data.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ class ImpactBuilder extends ir.RecursiveVisitor implements ImpactRegistry {
762762
}
763763

764764
void _registerFeature(_Feature feature) {
765-
_data._features += feature;
765+
_data._features = _data._features.add(feature);
766766
}
767767

768768
void _registerTypeUse(ir.DartType type, _TypeUseKind kind) {

pkg/compiler/lib/src/js_backend/annotations.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ EnumSet<PragmaAnnotation> processMemberAnnotations(
153153
String suffix = data.suffix;
154154
final annotation = PragmaAnnotation.lookupMap[suffix];
155155
if (annotation != null) {
156-
annotations += annotation;
156+
annotations = annotations.add(annotation);
157157

158158
if (data.options != null && !annotation.hasOption) {
159159
reporter.reportErrorMessage(
@@ -210,7 +210,7 @@ EnumSet<PragmaAnnotation> processMemberAnnotations(
210210
"with @pragma('dart2js:${other.name}')."
211211
});
212212
reportedExclusions.update(
213-
annotation, (exclusions) => exclusions + other,
213+
annotation, (exclusions) => exclusions.add(other),
214214
ifAbsent: () => EnumSet.fromValue(other));
215215
}
216216
}

pkg/compiler/lib/src/universe/class_set.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,16 +145,16 @@ class ClassHierarchyNode {
145145
{required bool add}) {
146146
ClassHierarchyNode? parent = parentNode;
147147
if (add) {
148-
_mask -= Instantiation.UNINSTANTIATED;
149-
_mask += instantiation;
148+
_mask = _mask.remove(Instantiation.UNINSTANTIATED);
149+
_mask = _mask.add(instantiation);
150150
while (parent != null) {
151151
parent._updateInstantiatedSubclassCount(1);
152152
parent = parent.parentNode;
153153
}
154154
} else {
155-
_mask -= instantiation;
155+
_mask = _mask.remove(instantiation);
156156
if (_mask.isEmpty) {
157-
_mask += Instantiation.UNINSTANTIATED;
157+
_mask = _mask.add(Instantiation.UNINSTANTIATED);
158158
}
159159
while (parent != null) {
160160
parent._updateInstantiatedSubclassCount(-1);
@@ -183,12 +183,12 @@ class ClassHierarchyNode {
183183
bool after = isIndirectlyInstantiated;
184184
if (before != after) {
185185
if (after) {
186-
_mask -= Instantiation.UNINSTANTIATED;
187-
_mask += Instantiation.INDIRECTLY_INSTANTIATED;
186+
_mask = _mask.remove(Instantiation.UNINSTANTIATED);
187+
_mask = _mask.add(Instantiation.INDIRECTLY_INSTANTIATED);
188188
} else {
189-
_mask -= Instantiation.INDIRECTLY_INSTANTIATED;
189+
_mask = _mask.remove(Instantiation.INDIRECTLY_INSTANTIATED);
190190
if (_mask.isEmpty) {
191-
_mask += Instantiation.UNINSTANTIATED;
191+
_mask = _mask.add(Instantiation.UNINSTANTIATED);
192192
}
193193
}
194194
}

pkg/compiler/lib/src/util/enumset.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,16 @@ extension type const EnumSet<E extends Enum>(Bitset mask) {
3939

4040
/// Returns a set containing all enum values in [this] as well as [enumValue].
4141
@useResult
42-
EnumSet<E> operator +(E enumValue) => EnumSet(mask.union(enumValue.mask(0)));
42+
EnumSet<E> add(E enumValue) => EnumSet(mask.union(enumValue.mask(0)));
4343

4444
/// Returns a set containing all enum values in [this] except for [enumValue].
4545
@useResult
46-
EnumSet<E> operator -(E enumValue) =>
47-
EnumSet(mask.setMinus(enumValue.mask(0)));
46+
EnumSet<E> remove(E enumValue) => EnumSet(mask.setMinus(enumValue.mask(0)));
4847

4948
/// Returns a set with the bit for [value] enabled or disabled depending on
5049
/// [state].
5150
@useResult
52-
EnumSet<E> update(E value, bool state) => state ? this + value : this - value;
51+
EnumSet<E> update(E value, bool state) => state ? add(value) : remove(value);
5352

5453
/// Returns a new set containing all values in both this and the [other] set.
5554
@useResult

pkg/compiler/test/model/enumset_test.dart

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,36 +47,36 @@ void testAddRemoveContains() {
4747

4848
check(0, []);
4949

50-
enumSet += Enum.B;
50+
enumSet = enumSet.add(Enum.B);
5151
check(2, [Enum.B]);
5252

53-
enumSet += Enum.F;
53+
enumSet = enumSet.add(Enum.F);
5454
check(34, [Enum.F, Enum.B]);
5555

56-
enumSet += Enum.A;
56+
enumSet = enumSet.add(Enum.A);
5757
check(35, [Enum.F, Enum.B, Enum.A]);
5858

59-
enumSet += Enum.A;
59+
enumSet = enumSet.add(Enum.A);
6060
check(35, [Enum.F, Enum.B, Enum.A]);
6161

62-
enumSet -= Enum.C;
62+
enumSet = enumSet.remove(Enum.C);
6363
check(35, [Enum.F, Enum.B, Enum.A]);
6464

65-
enumSet -= Enum.B;
65+
enumSet = enumSet.remove(Enum.B);
6666
check(33, [Enum.F, Enum.A]);
6767

68-
enumSet -= Enum.A;
68+
enumSet = enumSet.remove(Enum.A);
6969
check(32, [Enum.F]);
7070

7171
enumSet = EnumSet.empty();
7272
check(0, []);
7373

74-
enumSet += Enum.A;
75-
enumSet += Enum.B;
76-
enumSet += Enum.C;
77-
enumSet += Enum.D;
78-
enumSet += Enum.E;
79-
enumSet += Enum.F;
74+
enumSet = enumSet.add(Enum.A);
75+
enumSet = enumSet.add(Enum.B);
76+
enumSet = enumSet.add(Enum.C);
77+
enumSet = enumSet.add(Enum.D);
78+
enumSet = enumSet.add(Enum.E);
79+
enumSet = enumSet.add(Enum.F);
8080
check(63, [Enum.F, Enum.E, Enum.D, Enum.C, Enum.B, Enum.A]);
8181
}
8282

@@ -107,8 +107,8 @@ void testConstructorsIntersects() {
107107
check(emptyA, emptyD);
108108
check(emptyA, emptyE);
109109

110-
EnumSet<Enum> singleA = const EnumSet<Enum>.empty() + Enum.C;
111-
EnumSet<Enum> singleB = EnumSet<Enum>.empty() + Enum.C;
110+
EnumSet<Enum> singleA = const EnumSet<Enum>.empty().add(Enum.C);
111+
EnumSet<Enum> singleB = EnumSet<Enum>.empty().add(Enum.C);
112112
EnumSet<Enum> singleC = const EnumSet<Enum>.fromRawBits(4);
113113
EnumSet<Enum> singleD = EnumSet<Enum>.fromRawBits(4);
114114
EnumSet<Enum> singleE = EnumSet<Enum>.fromValues([Enum.C]);
@@ -121,8 +121,10 @@ void testConstructorsIntersects() {
121121
check(singleA, singleE);
122122
check(singleA, singleF);
123123

124-
EnumSet<Enum> multiA = const EnumSet<Enum>.empty() + Enum.A + Enum.D + Enum.F;
125-
EnumSet<Enum> multiB = EnumSet<Enum>.empty() + Enum.A + Enum.D + Enum.F;
124+
EnumSet<Enum> multiA =
125+
const EnumSet<Enum>.empty().add(Enum.A).add(Enum.D).add(Enum.F);
126+
EnumSet<Enum> multiB =
127+
EnumSet<Enum>.empty().add(Enum.A).add(Enum.D).add(Enum.F);
126128
EnumSet<Enum> multiC = const EnumSet<Enum>.fromRawBits(41);
127129
EnumSet<Enum> multiD = EnumSet<Enum>.fromRawBits(41);
128130
EnumSet<Enum> multiE = EnumSet<Enum>.fromValues([Enum.F, Enum.A, Enum.D]);

0 commit comments

Comments
 (0)