| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 import "package:expect/expect.dart"; |
| 6 |
| 7 class A { |
| 8 noSuchMethod(_) => 'foo'; |
| 9 get hashCode => 42; |
| 10 } |
| 11 |
| 12 // Keep that list empty to make the inferrer infer an empty element |
| 13 // type. |
| 14 var a = []; |
| 15 var b = [new A(), new Object()]; |
| 16 |
| 17 main() { |
| 18 // The following [hashCode] call will create a selector whose |
| 19 // receiver type is empty. This used to make dart2js generate a |
| 20 // [noSuchMethod] handler for [hashCode] on the Object class, which |
| 21 // would override the actual implementation. |
| 22 Expect.throws(() => a[0].hashCode, (e) => e is RangeError); |
| 23 |
| 24 // This code calls the [hashCode] method put on the [Object] class, |
| 25 // which used to be a [noSuchMethod] handler method. |
| 26 Expect.isTrue(b[1].hashCode is int); |
| 27 |
| 28 // Sanity checks. |
| 29 Expect.equals(42, b[0].hashCode); |
| 30 Expect.equals('foo', b[0].foo()); |
| 31 |
| 32 // Prevent optimizations on the [b] variable. |
| 33 b.clear(); |
| 34 } |
| OLD | NEW |