Index: pkg/compiler/lib/src/js_emitter/interceptor_stub_generator.dart |
diff --git a/pkg/compiler/lib/src/js_emitter/interceptor_stub_generator.dart b/pkg/compiler/lib/src/js_emitter/interceptor_stub_generator.dart |
index 2eabee093631d2fcf74a6d1e7a3a4329a1800287..3d3270c4de2fd8c4b765c7c24507fffd5015d213 100644 |
--- a/pkg/compiler/lib/src/js_emitter/interceptor_stub_generator.dart |
+++ b/pkg/compiler/lib/src/js_emitter/interceptor_stub_generator.dart |
@@ -217,17 +217,22 @@ class InterceptorStubGenerator { |
} else if (selector.isIndex || selector.isIndexSet) { |
// For an index operation, this code generates: |
// |
- // if (receiver.constructor == Array || typeof receiver == "string") { |
- // if (a0 >>> 0 === a0 && a0 < receiver.length) { |
- // return receiver[a0]; |
+ // if (typeof a0 === "number") { |
+ // if (receiver.constructor == Array || |
+ // typeof receiver == "string") { |
+ // if (a0 >>> 0 === a0 && a0 < receiver.length) { |
+ // return receiver[a0]; |
+ // } |
// } |
// } |
// |
// For an index set operation, this code generates: |
// |
- // if (receiver.constructor == Array && !receiver.immutable$list) { |
- // if (a0 >>> 0 === a0 && a0 < receiver.length) { |
- // return receiver[a0] = a1; |
+ // if (typeof a0 === "number") { |
+ // if (receiver.constructor == Array && !receiver.immutable$list) { |
+ // if (a0 >>> 0 === a0 && a0 < receiver.length) { |
+ // return receiver[a0] = a1; |
+ // } |
// } |
// } |
bool containsArray = classes.contains(helpers.jsArrayClass); |
@@ -270,9 +275,10 @@ class InterceptorStubGenerator { |
} |
return js.statement(''' |
- if (#) |
- if ((a0 >>> 0) === a0 && a0 < receiver.length) |
- return receiver[a0]; |
+ if (typeof a0 === "number") |
+ if (#) |
+ if ((a0 >>> 0) === a0 && a0 < receiver.length) |
+ return receiver[a0]; |
''', typeCheck); |
} else { |
jsAst.Expression typeCheck; |
@@ -285,9 +291,10 @@ class InterceptorStubGenerator { |
} |
return js.statement(r''' |
- if (# && !receiver.immutable$list && |
- (a0 >>> 0) === a0 && a0 < receiver.length) |
- return receiver[a0] = a1; |
+ if (typeof a0 === "number") |
+ if (# && !receiver.immutable$list && |
+ (a0 >>> 0) === a0 && a0 < receiver.length) |
+ return receiver[a0] = a1; |
''', typeCheck); |
} |
} |