| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library mirror_test; | 5 library mirror_test; |
| 6 | 6 |
| 7 @MirrorsUsed(targets: "mirror_test") | 7 @MirrorsUsed(targets: "mirror_test") |
| 8 import 'dart:mirrors'; | 8 import 'dart:mirrors'; |
| 9 | 9 |
| 10 import 'package:expect/expect.dart'; | 10 import 'package:expect/expect.dart'; |
| 11 | 11 |
| 12 class A { | 12 class A { |
| 13 factory A( | 13 factory A( |
| 14 String /// 01: static type warning | 14 String //# 01: static type warning |
| 15 x) = B; | 15 x) = B; |
| 16 A._(); | 16 A._(); |
| 17 } | 17 } |
| 18 | 18 |
| 19 class B extends A { | 19 class B extends A { |
| 20 var x; | 20 var x; |
| 21 B(int x) : super._(), this.x = x; | 21 B(int x) : super._(), this.x = x; |
| 22 } | 22 } |
| 23 | 23 |
| 24 main() { | 24 main() { |
| 25 var cm = reflectClass(A); | 25 var cm = reflectClass(A); |
| 26 // The type-annotation in A's constructor must be ignored. | 26 // The type-annotation in A's constructor must be ignored. |
| 27 var b = cm.newInstance(const Symbol(''), [499]).reflectee; | 27 var b = cm.newInstance(const Symbol(''), [499]).reflectee; |
| 28 Expect.equals(499, b.x); | 28 Expect.equals(499, b.x); |
| 29 Expect.throws(() => cm.newInstance(const Symbol(''), ["str"]), | 29 Expect.throws(() => cm.newInstance(const Symbol(''), ["str"]), |
| 30 (e) => e is TypeError); | 30 (e) => e is TypeError); |
| 31 } | 31 } |
| OLD | NEW |