Skip to content

Commit f3e41a9

Browse files
tamirdCQ Bot
authored and
CQ Bot
committed
[dart] Change operator== to accept Object
The base method[0] accepts Object, and using dynamic is apparently hostile to mockito[1], which is used downstream. [0] https://api.dart.dev/stable/2.12.0/dart-core/Object/operator_equals.html [1] dart-lang/mockito#354 Change-Id: I0cd6f1a8ad4fccf41f0671d774a0694fa2d28e6a Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/712023 API-Review: Adam Barth <[email protected]> Fuchsia-Auto-Submit: Tamir Duberstein <[email protected]> Reviewed-by: Adam Barth <[email protected]> Commit-Queue: Auto-Submit <[email protected]>
1 parent 10cf4c9 commit f3e41a9

File tree

12 files changed

+25
-25
lines changed

12 files changed

+25
-25
lines changed

docs/reference/fidl/bindings/dart-bindings.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ or every flag set (`$mask`):
125125
* `String toString()`: Returns a readable representation of the `FileMode`.
126126
* `FileMode operator |(FileMode other)`: Bitwise or operator.
127127
* `FileMode operator &(FileMode other)`: Bitwise and operator.
128-
* `bool operator(dynamic other)`: Equality operator.
128+
* `bool operator==(Object other)`: Equality operator.
129129
* `int getUnknownBits()`: Returns only the set bits that are unknown. Always
130130
returns 0 for [strict][lang-flexible] bits.
131131
* `bool hasUnknownBits()`: Returns whether this value contains any unknown bits.
@@ -203,7 +203,7 @@ The FIDL toolchain generates a `Color` class with the following methods:
203203
provided named arguments.
204204
* `List<Object> get $fields`: Returns a list of fields in declaration order.
205205
* `String toString()`: Returns a readable string of the `Color`
206-
* `bool operator==(dynamic other)`: Equality operator that performs a deep
206+
* `bool operator==(Object other)`: Equality operator that performs a deep
207207
comparison when compared to another instance of a `Color`.
208208

209209
Example usage:
@@ -241,7 +241,7 @@ As well as a `JsonValue` class with the following methods:
241241
* `String toString()`: Returns a readable string of the `JsonValue`.
242242
* `int get $ordinal`: Getter for the underlying [ordinal][union-lexicon] value.
243243
* `Object get $data`: Getter for the underlying union data.
244-
* `bool operator ==(dynamic other)`: Equality operator that performs deep
244+
* `bool operator ==(Object other)`: Equality operator that performs deep
245245
comparison when compared to another `JsonValue` of the same variant.
246246
* `fidl.UnknownRawData? get $unknownData`: Returns the bytes and handles of the
247247
unknown data if this union contains an unknown variant, or `null` otherwise.
@@ -306,7 +306,7 @@ The FIDL toolchain generates a `User` class that defines the following methods:
306306
to unknown field values (i.e. bytes and handles). The list of handles is
307307
returned in [traversal order][traversal], and is guaranteed to be empty if the
308308
table is a [value][lang-resource] type.
309-
* `bool operator ==(dynamic other)`: Equality operator that performs deep
309+
* `bool operator ==(Object other)`: Equality operator that performs deep
310310
comparison when compared to another `User`.
311311

312312
Example usage:

scripts/fxtest/lib/test_names_collector.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ class MatchableArgument {
270270
MatchableArgument._(null, MatchType.unrestricted);
271271

272272
@override
273-
bool operator ==(dynamic other) {
273+
bool operator ==(Object other) {
274274
return identical(this, other) ||
275275
(other is MatchableArgument &&
276276
runtimeType == other.runtimeType &&

sdk/dart/fidl/fidl.api

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"isRequiredPositional": true,
3535
"name": "other",
3636
"type": "SimpleFormalParameterImpl",
37-
"varType": "dynamic"
37+
"varType": "Object"
3838
}
3939
},
4040
"isAbstract": false,
@@ -4320,7 +4320,7 @@
43204320
"isRequiredPositional": true,
43214321
"name": "other",
43224322
"type": "SimpleFormalParameterImpl",
4323-
"varType": "dynamic"
4323+
"varType": "Object"
43244324
}
43254325
},
43264326
"isAbstract": false,
@@ -4442,7 +4442,7 @@
44424442
"isRequiredPositional": true,
44434443
"name": "other",
44444444
"type": "SimpleFormalParameterImpl",
4445-
"varType": "dynamic"
4445+
"varType": "Object"
44464446
}
44474447
},
44484448
"isAbstract": false,
@@ -12225,7 +12225,7 @@
1222512225
"isRequiredPositional": true,
1222612226
"name": "other",
1222712227
"type": "SimpleFormalParameterImpl",
12228-
"varType": "dynamic"
12228+
"varType": "Object"
1222912229
}
1223012230
},
1223112231
"isAbstract": false,

sdk/dart/fidl/lib/src/bits.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ abstract class Bits {
1212
int get $value;
1313

1414
@override
15-
bool operator ==(dynamic other) {
15+
bool operator ==(Object other) {
1616
if (other is Bits) {
1717
return $value == other.$value;
1818
}

sdk/dart/fidl/lib/src/struct.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ abstract class Struct {
1818
void $encode(Encoder encoder, int offset, int depth);
1919

2020
@override
21-
bool operator ==(dynamic other) {
21+
bool operator ==(Object other) {
2222
if (identical(this, other)) {
2323
return true;
2424
}
2525
if (runtimeType != other.runtimeType) {
2626
return false;
2727
}
28-
final Struct otherStruct = other;
28+
final otherStruct = other as Struct;
2929
return deepEquals($fields, otherStruct.$fields);
3030
}
3131

sdk/dart/fidl/lib/src/table.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ abstract class Table {
1818
int get hashCode => deepHash($fields.values);
1919

2020
@override
21-
bool operator ==(dynamic other) {
21+
bool operator ==(Object other) {
2222
if (identical(this, other)) {
2323
return true;
2424
}
2525
if (runtimeType != other.runtimeType) {
2626
return false;
2727
}
28-
final Table otherTable = other;
28+
final otherTable = other as Table;
2929
return deepEquals($fields, otherTable.$fields);
3030
}
3131

sdk/dart/fidl/lib/src/union.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ abstract class Union {
1616
int get hashCode => deepHash([$ordinal, $data]);
1717

1818
@override
19-
bool operator ==(dynamic other) {
19+
bool operator ==(Object other) {
2020
if (identical(this, other)) {
2121
return true;
2222
}
2323
if (runtimeType != other.runtimeType) {
2424
return false;
2525
}
26-
final Union otherUnion = other;
26+
final otherUnion = other as Union;
2727
if ($ordinal != otherUnion.$ordinal) {
2828
return false;
2929
}

sdk/dart/fuchsia_scenic_flutter/test/fuchsia_view_connection_test.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ class MockViewHolderToken extends Mock implements ViewHolderToken {
404404
int get hashCode => super.noSuchMethod(Invocation.method(#hashCode, []));
405405

406406
@override
407-
bool operator ==(dynamic other) =>
407+
bool operator ==(Object other) =>
408408
super.noSuchMethod(Invocation.method(#==, [other]));
409409
}
410410

@@ -413,7 +413,7 @@ class MockViewportCreationToken extends Mock implements ViewportCreationToken {
413413
int get hashCode => super.noSuchMethod(Invocation.method(#hashCode, []));
414414

415415
@override
416-
bool operator ==(dynamic other) =>
416+
bool operator ==(Object other) =>
417417
super.noSuchMethod(Invocation.method(#==, [other]));
418418
}
419419

@@ -422,7 +422,7 @@ class MockViewRef extends Mock implements ViewRef {
422422
int get hashCode => super.noSuchMethod(Invocation.method(#hashCode, []));
423423

424424
@override
425-
bool operator ==(dynamic other) =>
425+
bool operator ==(Object other) =>
426426
super.noSuchMethod(Invocation.method(#==, [other]));
427427
}
428428

@@ -435,7 +435,7 @@ class MockHandle extends Mock implements Handle {
435435
int get hashCode => super.noSuchMethod(Invocation.method(#hashCode, []));
436436

437437
@override
438-
bool operator ==(dynamic other) =>
438+
bool operator ==(Object other) =>
439439
super.noSuchMethod(Invocation.method(#==, [other]));
440440

441441
@override

sdk/dart/fuchsia_scenic_flutter/test/pointer_injector_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ class MockViewRef extends Mock implements ViewRef {
170170
int get hashCode => super.noSuchMethod(Invocation.method(#hashCode, []));
171171

172172
@override
173-
bool operator ==(dynamic other) =>
173+
bool operator ==(Object other) =>
174174
super.noSuchMethod(Invocation.method(#==, [other]));
175175
}
176176

sdk/testing/sl4f/client/lib/src/trace_processing/time_delta.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class TimeDelta implements Comparable<TimeDelta> {
5555
bool operator >=(TimeDelta other) => _delta >= other._delta;
5656

5757
@override
58-
bool operator ==(dynamic other) =>
58+
bool operator ==(Object other) =>
5959
other is TimeDelta && _delta == other._delta;
6060
@override
6161
int get hashCode => _delta.hashCode;

sdk/testing/sl4f/client/lib/src/trace_processing/time_point.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class TimePoint implements Comparable<TimePoint> {
3030
bool operator >=(TimePoint other) => _ticks >= other._ticks;
3131

3232
@override
33-
bool operator ==(dynamic other) =>
33+
bool operator ==(Object other) =>
3434
other is TimePoint && _ticks == other._ticks;
3535
@override
3636
int get hashCode => _ticks.hashCode;

sdk/testing/sl4f/client/sl4f.api

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7843,7 +7843,7 @@
78437843
"isRequiredPositional": true,
78447844
"name": "other",
78457845
"type": "SimpleFormalParameterImpl",
7846-
"varType": "dynamic"
7846+
"varType": "Object"
78477847
}
78487848
},
78497849
"isAbstract": false,
@@ -8195,7 +8195,7 @@
81958195
"isRequiredPositional": true,
81968196
"name": "other",
81978197
"type": "SimpleFormalParameterImpl",
8198-
"varType": "dynamic"
8198+
"varType": "Object"
81998199
}
82008200
},
82018201
"isAbstract": false,

0 commit comments

Comments
 (0)