Skip to content

Commit ba2417f

Browse files
committed
Fix SDK errors due to inconsistent inheritance of Operator==.
The informal spec for strong mode top level inference (#28218) says "If there are multiple overridden/implemented methods, and any two of them have non-equal types (declared or inferred) for a parameter position which is being inferred for the overriding method, it is an error." This CL fixes several SDK errors that arise from this rule. For example, the classes _Closure, Function, and Object contained members declared as follows: class _Closure implements Function { bool operator ==(other) ... } class Function { bool operator ==(Object other) ... } class Object { bool operator ==(other) ... } The type of Object's operator == was (dynamic) -> bool; the type of Function's operator == was (Object) -> bool; therefore the type of _Closure's operator == (which overrides both, since _Closure extends Object and implements Function) cannot be inferred and must be specified. A similar situation exists for _Double and _IntegerImplementation (both implement num, which declares operator == to have type (Object) -> bool), and _Uri (which implements Uri, which declares operator == to have type (Object) -> bool). This CL fixes the error by specifying the type explicitly in the classes _Closure, _Double, _IntegerImplementation, and _Uri. Change-Id: I91f7ceef8549399d438ba4be8c408493b3f338db Reviewed-on: https://dart-review.googlesource.com/28100 Reviewed-by: Vyacheslav Egorov <[email protected]>
1 parent 50865e9 commit ba2417f

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

runtime/lib/double.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class _Double implements double {
5454

5555
double operator -() native "Double_flipSignBit";
5656

57-
bool operator ==(other) {
57+
bool operator ==(Object other) {
5858
return (other is num) && _equal(other.toDouble());
5959
}
6060

runtime/lib/function.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// part of "core_patch.dart";
66

77
class _Closure implements Function {
8-
bool operator ==(other) native "Closure_equals";
8+
bool operator ==(Object other) native "Closure_equals";
99

1010
int get hashCode {
1111
if (_hash == null) {

runtime/lib/integers.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ abstract class _IntegerImplementation implements int {
124124
bool _greaterThanFromInteger(int other)
125125
native "Integer_greaterThanFromInteger";
126126

127-
bool operator ==(other) {
127+
bool operator ==(Object other) {
128128
if (other is num) {
129129
return other._equalToInteger(this);
130130
}

runtime/vm/compiler/method_recognizer.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ namespace dart {
158158
V(_Double, >=, Double_greaterEqualThan, Bool, 0x4260c184) \
159159
V(_Double, <, Double_lessThan, Bool, 0x365d1eba) \
160160
V(_Double, <=, Double_lessEqualThan, Bool, 0x74b5eb64) \
161-
V(_Double, ==, Double_equal, Bool, 0x7ec67775) \
161+
V(_Double, ==, Double_equal, Bool, 0x613492fc) \
162162
V(_Double, +, Double_add, Double, 0x53994370) \
163163
V(_Double, -, Double_sub, Double, 0x3b69d466) \
164164
V(_Double, *, Double_mul, Double, 0x2bb9bd5d) \
@@ -225,7 +225,7 @@ namespace dart {
225225
V(_IntegerImplementation, _greaterThanFromInteger, \
226226
Integer_greaterThanFromInt, Bool, 0x4a50ed58) \
227227
V(_IntegerImplementation, >, Integer_greaterThan, Bool, 0x6599a6e1) \
228-
V(_IntegerImplementation, ==, Integer_equal, Bool, 0x6d56616e) \
228+
V(_IntegerImplementation, ==, Integer_equal, Bool, 0x58abc487) \
229229
V(_IntegerImplementation, _equalToInteger, Integer_equalToInteger, Bool, \
230230
0x063be842) \
231231
V(_IntegerImplementation, <, Integer_lessThan, Bool, 0x365d1eba) \
@@ -472,7 +472,7 @@ namespace dart {
472472
V(_Double, >=, Double_greaterEqualThan, 0x4260c184) \
473473
V(_Double, <, Double_lessThan, 0x365d1eba) \
474474
V(_Double, <=, Double_lessEqualThan, 0x74b5eb64) \
475-
V(_Double, ==, Double_equal, 0x7ec67775) \
475+
V(_Double, ==, Double_equal, 0x613492fc) \
476476
V(_Double, +, Double_add, 0x53994370) \
477477
V(_Double, -, Double_sub, 0x3b69d466) \
478478
V(_Double, *, Double_mul, 0x2bb9bd5d) \
@@ -486,7 +486,7 @@ namespace dart {
486486
V(_IntegerImplementation, |, Integer_bitOr, 0x22d38a06) \
487487
V(_IntegerImplementation, ^, Integer_bitXor, 0x79078347) \
488488
V(_IntegerImplementation, >, Integer_greaterThan, 0x6599a6e1) \
489-
V(_IntegerImplementation, ==, Integer_equal, 0x6d56616e) \
489+
V(_IntegerImplementation, ==, Integer_equal, 0x58abc487) \
490490
V(_IntegerImplementation, <, Integer_lessThan, 0x365d1eba) \
491491
V(_IntegerImplementation, <=, Integer_lessEqualThan, 0x74b5eb64) \
492492
V(_IntegerImplementation, >=, Integer_greaterEqualThan, 0x4260c184) \

sdk/lib/core/uri.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2689,7 +2689,7 @@ class _Uri implements Uri {
26892689
return sb.toString();
26902690
}
26912691

2692-
bool operator ==(other) {
2692+
bool operator ==(Object other) {
26932693
if (identical(this, other)) return true;
26942694
if (other is Uri) {
26952695
Uri uri = other;

0 commit comments

Comments
 (0)