Index: runtime/lib/mirrors_impl.dart |
diff --git a/runtime/lib/mirrors_impl.dart b/runtime/lib/mirrors_impl.dart |
index 62e72d972f7711eb73b4d897dd16c1f5324fd459..adef590c0fe46cad91c3577d45dd4602c6b8e0e2 100644 |
--- a/runtime/lib/mirrors_impl.dart |
+++ b/runtime/lib/mirrors_impl.dart |
@@ -283,7 +283,18 @@ class _LocalInstanceMirrorImpl extends _LocalObjectMirrorImpl |
identical(_reflectee, other._reflectee); |
} |
- int get hashCode => _reflectee.hashCode; |
+ int get hashCode { |
+ // If the reflectee is a double or bignum, use the base hashCode to preserve |
+ // the illusion that boxed numbers with the same value are identical. If the |
+ // reflectee is a Smi, use the base hashCode because Object.hashCode does |
+ // not work for non-heap objects. Otherwise, use Object.hashCode to maintain |
+ // correctness even if a user-defined hashCode returns different values for |
+ // successive invocations. |
+ return _reflectee is num ? _reflectee.hashCode : _identityHash(_reflectee); |
+ } |
+ |
+ static _identityHash(reflectee) |
+ native "InstanceMirror_identityHash"; |
_invoke(reflectee, functionName, positionalArguments) |
native 'InstanceMirror_invoke'; |