Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(556)

Unified Diff: lib/compiler/implementation/lib/interceptors.dart

Issue 10979050: Ensure that hashCode and runtimeType work on null. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix HashMap. Update bad expectation. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | lib/compiler/implementation/ssa/builder.dart » ('j') | lib/core/map.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/lib/interceptors.dart
diff --git a/lib/compiler/implementation/lib/interceptors.dart b/lib/compiler/implementation/lib/interceptors.dart
index 1cb7fc62d7a92317aafed8afc5a771b8d18adfaf..0b4d115049d58f2a13d4237545ce1bc319f8c04e 100644
--- a/lib/compiler/implementation/lib/interceptors.dart
+++ b/lib/compiler/implementation/lib/interceptors.dart
@@ -617,6 +617,7 @@ trim(receiver) {
hashCode(receiver) {
// TODO(ahe): This method shouldn't have to use JS. Update when our
// optimizations are smarter.
+ if (receiver === null) return 0;
if (receiver is num) return JS('int', r'# & 0x1FFFFFFF', receiver);
if (receiver is !String) return UNINTERCEPTED(receiver.hashCode());
int hash = 0;
@@ -651,8 +652,6 @@ isOdd(receiver) {
return (receiver & 1) === 1;
}
-get$toString(receiver) => () => toString(receiver);
-
get$runtimeType(receiver) {
if (receiver is int) {
return getOrCreateCachedRuntimeType('int');
@@ -660,9 +659,17 @@ get$runtimeType(receiver) {
return getOrCreateCachedRuntimeType('String');
} else if (receiver is double) {
return getOrCreateCachedRuntimeType('double');
+ } else if (receiver === null) {
+ return getOrCreateCachedRuntimeType('Null');
} else if (isJsArray(receiver)) {
return getOrCreateCachedRuntimeType('List');
} else {
return UNINTERCEPTED(receiver.runtimeType);
}
}
+
+// TODO(lrn): These getters should be generated added automatically for all
+// methods.
+get$toString(receiver) => () => toString(receiver);
+
+get$hashCode(receiver) => () => hashCode(receiver);
« no previous file with comments | « no previous file | lib/compiler/implementation/ssa/builder.dart » ('j') | lib/core/map.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698