| 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 /// Test that the @MirrorsUsed annotation suppress hints and that only | 5 /// Test that the @MirrorsUsed annotation suppress hints and that only |
| 6 /// requested elements are retained for reflection. | 6 /// requested elements are retained for reflection. |
| 7 library dart2js.test.mirrors_used_test; | 7 library dart2js.test.mirrors_used_test; |
| 8 | 8 |
| 9 import 'package:expect/expect.dart'; | 9 import 'package:expect/expect.dart'; |
| 10 import "package:async_helper/async_helper.dart"; | 10 import "package:async_helper/async_helper.dart"; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 } | 116 } |
| 117 } | 117 } |
| 118 Expect.equals( | 118 Expect.equals( |
| 119 1, fooConstantCount, | 119 1, fooConstantCount, |
| 120 "The type literal 'Foo' is duplicated or missing."); | 120 "The type literal 'Foo' is duplicated or missing."); |
| 121 })); | 121 })); |
| 122 } | 122 } |
| 123 | 123 |
| 124 const MEMORY_SOURCE_FILES = const <String, String> { | 124 const MEMORY_SOURCE_FILES = const <String, String> { |
| 125 'main.dart': """ | 125 'main.dart': """ |
| 126 @MirrorsUsed(targets: const [Foo], override: '*') | 126 // The repeated constant value for symbols and targets used to crash dart2js in |
| 127 // host-checked mode, and could potentially lead to other problems. |
| 128 @MirrorsUsed(symbols: 'Foo', targets: 'Foo', override: '*') |
| 127 import 'dart:mirrors'; | 129 import 'dart:mirrors'; |
| 128 | 130 |
| 129 import 'library.dart'; | 131 import 'library.dart'; |
| 130 | 132 |
| 131 class Foo { | 133 class Foo { |
| 132 int field; | 134 int field; |
| 133 instanceMethod() {} | 135 instanceMethod() {} |
| 134 static staticMethod() {} | 136 static staticMethod() {} |
| 135 } | 137 } |
| 136 | 138 |
| 137 unusedFunction() { | 139 unusedFunction() { |
| 138 } | 140 } |
| 139 | 141 |
| 140 main() { | 142 main() { |
| 141 useReflect(Foo); | 143 useReflect(Foo); |
| 142 } | 144 } |
| 143 """, | 145 """, |
| 144 'library.dart': """ | 146 'library.dart': """ |
| 145 library lib; | 147 library lib; |
| 146 | 148 |
| 147 import 'dart:mirrors'; | 149 import 'dart:mirrors'; |
| 148 | 150 |
| 149 useReflect(type) { | 151 useReflect(type) { |
| 150 print(new Symbol('Foo')); | 152 print(new Symbol('Foo')); |
| 151 print(MirrorSystem.getName(reflectClass(type).owner.qualifiedName)); | 153 print(MirrorSystem.getName(reflectClass(type).owner.qualifiedName)); |
| 152 } | 154 } |
| 153 """, | 155 """, |
| 154 }; | 156 }; |
| OLD | NEW |