Index: sdk/lib/_internal/lib/js_mirrors.dart |
diff --git a/sdk/lib/_internal/lib/js_mirrors.dart b/sdk/lib/_internal/lib/js_mirrors.dart |
index d5db7e5f505c54dafa04c3d37eddaf99847fd051..8911a689052d16f099f2a8ed153d56ba3b311d55 100644 |
--- a/sdk/lib/_internal/lib/js_mirrors.dart |
+++ b/sdk/lib/_internal/lib/js_mirrors.dart |
@@ -677,6 +677,26 @@ class JsInstanceMirror extends JsObjectMirror implements InstanceMirror { |
return JSInvocationMirror.invokeFromMirror(invocation, reflectee); |
} |
+ operator ==(other) { |
+ return other is JsInstanceMirror && |
+ identical(reflectee, other.reflectee); |
+ } |
+ |
+ int get hashCode { |
+ // If the reflectee is a built-in type, use the base-level hashCode to |
+ // preserve the illusion that, e.g. doubles, with the same value are |
+ // identical. Otherwise, use the primitive identity hash to maintain |
+ // correctness even if a user-defined hashCode returns different values for |
+ // successive invocations. |
+ var h = ((JS('bool', 'typeof # != "object"', reflectee)) || |
+ (reflectee == null)) |
+ ? reflectee.hashCode |
+ : Primitives.objectHashCode(reflectee); |
+ // Avoid hash collisions with the reflectee. This constant is in Smi range |
+ // and happens to be the inner padding from RFC 2104. |
+ return h ^ 0x36363636; |
+ } |
+ |
String toString() => 'InstanceMirror on ${Error.safeToString(reflectee)}'; |
// TODO(ahe): Remove this method from the API. |