| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 ]; // The (getter) name of Foo.field. | 82 ]; // The (getter) name of Foo.field. |
| 83 // TODO(ahe): Check for the following names, currently they are not being | 83 // TODO(ahe): Check for the following names, currently they are not being |
| 84 // recorded correctly, but are being emitted. | 84 // recorded correctly, but are being emitted. |
| 85 [ | 85 [ |
| 86 'Foo_staticMethod', // The name of Foo.staticMethod. | 86 'Foo_staticMethod', // The name of Foo.staticMethod. |
| 87 r'instanceMethod$0' | 87 r'instanceMethod$0' |
| 88 ]; // The name of Foo.instanceMethod. | 88 ]; // The name of Foo.instanceMethod. |
| 89 | 89 |
| 90 // We always include the names of some native classes. | 90 // We always include the names of some native classes. |
| 91 List<ClassElement> nativeClasses = [ | 91 List<ClassElement> nativeClasses = [ |
| 92 compiler.commonElements.intClass, | 92 compiler.resolution.commonElements.intClass, |
| 93 compiler.commonElements.doubleClass, | 93 compiler.resolution.commonElements.doubleClass, |
| 94 compiler.commonElements.numClass, | 94 compiler.resolution.commonElements.numClass, |
| 95 compiler.commonElements.stringClass, | 95 compiler.resolution.commonElements.stringClass, |
| 96 compiler.commonElements.boolClass, | 96 compiler.resolution.commonElements.boolClass, |
| 97 compiler.commonElements.nullClass, | 97 compiler.resolution.commonElements.nullClass, |
| 98 compiler.commonElements.listClass | 98 compiler.resolution.commonElements.listClass |
| 99 ]; | 99 ]; |
| 100 Iterable<String> nativeNames = nativeClasses.map(backend.namer.className); | 100 Iterable<String> nativeNames = nativeClasses.map(backend.namer.className); |
| 101 expectedNames = expectedNames.map(backend.namer.asName).toList(); | 101 expectedNames = expectedNames.map(backend.namer.asName).toList(); |
| 102 expectedNames.addAll(nativeNames); | 102 expectedNames.addAll(nativeNames); |
| 103 | 103 |
| 104 // Mirrors only work in the full emitter. We can thus be certain that the | 104 // Mirrors only work in the full emitter. We can thus be certain that the |
| 105 // emitter is the full emitter. | 105 // emitter is the full emitter. |
| 106 full.Emitter fullEmitter = backend.emitter.emitter; | 106 full.Emitter fullEmitter = backend.emitter.emitter; |
| 107 Set recordedNames = new Set() | 107 Set recordedNames = new Set() |
| 108 ..addAll(fullEmitter.recordedMangledNames) | 108 ..addAll(fullEmitter.recordedMangledNames) |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 library lib; | 205 library lib; |
| 206 | 206 |
| 207 import 'dart:mirrors'; | 207 import 'dart:mirrors'; |
| 208 | 208 |
| 209 useReflect(type) { | 209 useReflect(type) { |
| 210 print(new Symbol('Foo')); | 210 print(new Symbol('Foo')); |
| 211 print(MirrorSystem.getName(reflectClass(type).owner.qualifiedName)); | 211 print(MirrorSystem.getName(reflectClass(type).owner.qualifiedName)); |
| 212 } | 212 } |
| 213 """, | 213 """, |
| 214 }; | 214 }; |
| OLD | NEW |