OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 elements are not needlessly required by dart2js. | 5 // Test that elements are not needlessly required by dart2js. |
6 | 6 |
7 import 'package:async_helper/async_helper.dart'; | 7 import 'package:async_helper/async_helper.dart'; |
8 import 'package:compiler/src/common/names.dart'; | 8 import 'package:compiler/src/common/names.dart'; |
9 import 'package:compiler/src/compiler.dart'; | 9 import 'package:compiler/src/compiler.dart'; |
10 import 'package:compiler/src/elements/elements.dart'; | 10 import 'package:compiler/src/elements/elements.dart'; |
(...skipping 27 matching lines...) Expand all Loading... |
38 {bool proxyConstantComputed: false, bool deprecatedClass: false}) async { | 38 {bool proxyConstantComputed: false, bool deprecatedClass: false}) async { |
39 CompilationResult result = await runCompiler( | 39 CompilationResult result = await runCompiler( |
40 memorySourceFiles: {'main.dart': code}, options: ['--analyze-only']); | 40 memorySourceFiles: {'main.dart': code}, options: ['--analyze-only']); |
41 Expect.isTrue(result.isSuccess); | 41 Expect.isTrue(result.isSuccess); |
42 Compiler compiler = result.compiler; | 42 Compiler compiler = result.compiler; |
43 Expect.equals( | 43 Expect.equals( |
44 proxyConstantComputed, | 44 proxyConstantComputed, |
45 compiler.resolution.wasProxyConstantComputedTestingOnly, | 45 compiler.resolution.wasProxyConstantComputedTestingOnly, |
46 "Unexpected computation of proxy constant."); | 46 "Unexpected computation of proxy constant."); |
47 | 47 |
48 LibraryElement coreLibrary = compiler.commonElements.coreLibrary; | 48 LibraryElement coreLibrary = |
| 49 compiler.frontendStrategy.commonElements.coreLibrary; |
49 checkInstantiated( | 50 checkInstantiated( |
50 compiler, coreLibrary.find('_Proxy'), proxyConstantComputed); | 51 compiler, coreLibrary.find('_Proxy'), proxyConstantComputed); |
51 checkInstantiated(compiler, coreLibrary.find('Deprecated'), deprecatedClass); | 52 checkInstantiated(compiler, coreLibrary.find('Deprecated'), deprecatedClass); |
52 | 53 |
53 LibraryElement jsHelperLibrary = | 54 LibraryElement jsHelperLibrary = |
54 compiler.libraryLoader.lookupLibrary(Uris.dart__js_helper); | 55 compiler.libraryLoader.lookupLibrary(Uris.dart__js_helper); |
55 jsHelperLibrary.forEachLocalMember((Element element) { | 56 jsHelperLibrary.forEachLocalMember((Element element) { |
56 Uri uri = element.compilationUnit.script.resourceUri; | 57 Uri uri = element.compilationUnit.script.resourceUri; |
57 if (element.isClass && uri.path.endsWith('annotations.dart')) { | 58 if (element.isClass && uri.path.endsWith('annotations.dart')) { |
58 checkInstantiated(compiler, element, false); | 59 checkInstantiated(compiler, element, false); |
59 } | 60 } |
60 }); | 61 }); |
61 } | 62 } |
OLD | NEW |