OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2014, 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 @MirrorsUsed(targets: const ["A", "B"]) |
| 6 import 'dart:mirrors'; |
| 7 |
| 8 import 'package:expect/expect.dart'; |
| 9 |
| 10 class A { |
| 11 toString() => "A"; |
| 12 } |
| 13 |
| 14 class B { |
| 15 int x = 99; |
| 16 toString() => "B"; |
| 17 } |
| 18 |
| 19 void main() { |
| 20 var a = new A(); |
| 21 var am = reflect(a); |
| 22 for (int i = 0; i < 10; i++) { |
| 23 // Adds a probe function on the symbol. |
| 24 am.getField(#toString); |
| 25 } |
| 26 var b = new B(); |
| 27 var bm = reflect(b); |
| 28 for (int i = 0; i < 10; i++) { |
| 29 // Adds a field-cache on the mirror. |
| 30 bm.getField(#x); |
| 31 } |
| 32 // There is a cache now, but the cache should not contain 'toString' from |
| 33 // JavaScript's Object.prototype. |
| 34 var toString = bm.getField(#toString).reflectee; |
| 35 Expect.equals("B", toString()); |
| 36 } |
OLD | NEW |