Fix SDK errors due to inconsistent inheritance of Operator==.
The informal spec for strong mode top level inference
(https://github.com/dart-lang/sdk/pull/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 <vegorov@google.com>
diff --git a/runtime/lib/double.dart b/runtime/lib/double.dart
index 9b053c0..4c88b4e 100644
--- a/runtime/lib/double.dart
+++ b/runtime/lib/double.dart
@@ -54,7 +54,7 @@
double operator -() native "Double_flipSignBit";
- bool operator ==(other) {
+ bool operator ==(Object other) {
return (other is num) && _equal(other.toDouble());
}
diff --git a/runtime/lib/function.dart b/runtime/lib/function.dart
index dee3666..ebaa3ec 100644
--- a/runtime/lib/function.dart
+++ b/runtime/lib/function.dart
@@ -5,7 +5,7 @@
// part of "core_patch.dart";
class _Closure implements Function {
- bool operator ==(other) native "Closure_equals";
+ bool operator ==(Object other) native "Closure_equals";
int get hashCode {
if (_hash == null) {
diff --git a/runtime/lib/integers.dart b/runtime/lib/integers.dart
index 37bb589..46562e6 100644
--- a/runtime/lib/integers.dart
+++ b/runtime/lib/integers.dart
@@ -124,7 +124,7 @@
bool _greaterThanFromInteger(int other)
native "Integer_greaterThanFromInteger";
- bool operator ==(other) {
+ bool operator ==(Object other) {
if (other is num) {
return other._equalToInteger(this);
}
diff --git a/runtime/vm/compiler/method_recognizer.h b/runtime/vm/compiler/method_recognizer.h
index f3eb930..67ae5b3 100644
--- a/runtime/vm/compiler/method_recognizer.h
+++ b/runtime/vm/compiler/method_recognizer.h
@@ -158,7 +158,7 @@
V(_Double, >=, Double_greaterEqualThan, Bool, 0x4260c184) \
V(_Double, <, Double_lessThan, Bool, 0x365d1eba) \
V(_Double, <=, Double_lessEqualThan, Bool, 0x74b5eb64) \
- V(_Double, ==, Double_equal, Bool, 0x7ec67775) \
+ V(_Double, ==, Double_equal, Bool, 0x613492fc) \
V(_Double, +, Double_add, Double, 0x53994370) \
V(_Double, -, Double_sub, Double, 0x3b69d466) \
V(_Double, *, Double_mul, Double, 0x2bb9bd5d) \
@@ -225,7 +225,7 @@
V(_IntegerImplementation, _greaterThanFromInteger, \
Integer_greaterThanFromInt, Bool, 0x4a50ed58) \
V(_IntegerImplementation, >, Integer_greaterThan, Bool, 0x6599a6e1) \
- V(_IntegerImplementation, ==, Integer_equal, Bool, 0x6d56616e) \
+ V(_IntegerImplementation, ==, Integer_equal, Bool, 0x58abc487) \
V(_IntegerImplementation, _equalToInteger, Integer_equalToInteger, Bool, \
0x063be842) \
V(_IntegerImplementation, <, Integer_lessThan, Bool, 0x365d1eba) \
@@ -472,7 +472,7 @@
V(_Double, >=, Double_greaterEqualThan, 0x4260c184) \
V(_Double, <, Double_lessThan, 0x365d1eba) \
V(_Double, <=, Double_lessEqualThan, 0x74b5eb64) \
- V(_Double, ==, Double_equal, 0x7ec67775) \
+ V(_Double, ==, Double_equal, 0x613492fc) \
V(_Double, +, Double_add, 0x53994370) \
V(_Double, -, Double_sub, 0x3b69d466) \
V(_Double, *, Double_mul, 0x2bb9bd5d) \
@@ -486,7 +486,7 @@
V(_IntegerImplementation, |, Integer_bitOr, 0x22d38a06) \
V(_IntegerImplementation, ^, Integer_bitXor, 0x79078347) \
V(_IntegerImplementation, >, Integer_greaterThan, 0x6599a6e1) \
- V(_IntegerImplementation, ==, Integer_equal, 0x6d56616e) \
+ V(_IntegerImplementation, ==, Integer_equal, 0x58abc487) \
V(_IntegerImplementation, <, Integer_lessThan, 0x365d1eba) \
V(_IntegerImplementation, <=, Integer_lessEqualThan, 0x74b5eb64) \
V(_IntegerImplementation, >=, Integer_greaterEqualThan, 0x4260c184) \
diff --git a/sdk/lib/core/uri.dart b/sdk/lib/core/uri.dart
index dd4fe11..ef20c8d 100644
--- a/sdk/lib/core/uri.dart
+++ b/sdk/lib/core/uri.dart
@@ -2689,7 +2689,7 @@
return sb.toString();
}
- bool operator ==(other) {
+ bool operator ==(Object other) {
if (identical(this, other)) return true;
if (other is Uri) {
Uri uri = other;