| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 ]; // The (getter) name of Foo.field. | 77 ]; // The (getter) name of Foo.field. |
| 78 // TODO(ahe): Check for the following names, currently they are not being | 78 // TODO(ahe): Check for the following names, currently they are not being |
| 79 // recorded correctly, but are being emitted. | 79 // recorded correctly, but are being emitted. |
| 80 [ | 80 [ |
| 81 'Foo_staticMethod', // The name of Foo.staticMethod. | 81 'Foo_staticMethod', // The name of Foo.staticMethod. |
| 82 r'instanceMethod$0' | 82 r'instanceMethod$0' |
| 83 ]; // The name of Foo.instanceMethod. | 83 ]; // The name of Foo.instanceMethod. |
| 84 | 84 |
| 85 // We always include the names of some native classes. | 85 // We always include the names of some native classes. |
| 86 List<Element> nativeClasses = [ | 86 List<Element> nativeClasses = [ |
| 87 compiler.coreClasses.intClass, | 87 compiler.commonElements.intClass, |
| 88 compiler.coreClasses.doubleClass, | 88 compiler.commonElements.doubleClass, |
| 89 compiler.coreClasses.numClass, | 89 compiler.commonElements.numClass, |
| 90 compiler.coreClasses.stringClass, | 90 compiler.commonElements.stringClass, |
| 91 compiler.coreClasses.boolClass, | 91 compiler.commonElements.boolClass, |
| 92 compiler.coreClasses.nullClass, | 92 compiler.commonElements.nullClass, |
| 93 compiler.coreClasses.listClass | 93 compiler.commonElements.listClass |
| 94 ]; | 94 ]; |
| 95 JavaScriptBackend backend = compiler.backend; | 95 JavaScriptBackend backend = compiler.backend; |
| 96 Iterable<String> nativeNames = nativeClasses.map(backend.namer.className); | 96 Iterable<String> nativeNames = nativeClasses.map(backend.namer.className); |
| 97 expectedNames = expectedNames.map(backend.namer.asName).toList(); | 97 expectedNames = expectedNames.map(backend.namer.asName).toList(); |
| 98 expectedNames.addAll(nativeNames); | 98 expectedNames.addAll(nativeNames); |
| 99 | 99 |
| 100 // Mirrors only work in the full emitter. We can thus be certain that the | 100 // Mirrors only work in the full emitter. We can thus be certain that the |
| 101 // emitter is the full emitter. | 101 // emitter is the full emitter. |
| 102 full.Emitter fullEmitter = backend.emitter.emitter; | 102 full.Emitter fullEmitter = backend.emitter.emitter; |
| 103 Set recordedNames = new Set() | 103 Set recordedNames = new Set() |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 library lib; | 180 library lib; |
| 181 | 181 |
| 182 import 'dart:mirrors'; | 182 import 'dart:mirrors'; |
| 183 | 183 |
| 184 useReflect(type) { | 184 useReflect(type) { |
| 185 print(new Symbol('Foo')); | 185 print(new Symbol('Foo')); |
| 186 print(MirrorSystem.getName(reflectClass(type).owner.qualifiedName)); | 186 print(MirrorSystem.getName(reflectClass(type).owner.qualifiedName)); |
| 187 } | 187 } |
| 188 """, | 188 """, |
| 189 }; | 189 }; |
| OLD | NEW |