| Index: sdk/lib/_internal/compiler/implementation/deferred_load.dart
|
| diff --git a/sdk/lib/_internal/compiler/implementation/deferred_load.dart b/sdk/lib/_internal/compiler/implementation/deferred_load.dart
|
| index 84b61f4af851d4eb703f730b421a52982d59127c..7bbc086dc259526bf008c6c4135ada1f03dcf4aa 100644
|
| --- a/sdk/lib/_internal/compiler/implementation/deferred_load.dart
|
| +++ b/sdk/lib/_internal/compiler/implementation/deferred_load.dart
|
| @@ -294,7 +294,8 @@ class DeferredLoadTask extends CompilerTask {
|
| void _collectAllElementsAndConstantsResolvedFrom(
|
| Element element,
|
| Set<Element> elements,
|
| - Set<Constant> constants) {
|
| + Set<Constant> constants,
|
| + isMirrorUsage) {
|
|
|
| /// Recursively add the constant and its dependencies to [constants].
|
| void addConstants(Constant constant) {
|
| @@ -344,10 +345,11 @@ class DeferredLoadTask extends CompilerTask {
|
| }
|
| if (element.isClass) {
|
| // If we see a class, add everything its live instance members refer
|
| - // to. Static members are not relevant.
|
| + // to. Static members are not relevant, unless we are processing
|
| + // extra dependencies due to mirrors.
|
| void addLiveInstanceMember(Element element) {
|
| if (!compiler.enqueuer.resolution.isLive(element)) return;
|
| - if (!element.isInstanceMember) return;
|
| + if (!isMirrorUsage && !element.isInstanceMember) return;
|
| collectDependencies(element.implementation);
|
| }
|
| ClassElement cls = element.declaration;
|
| @@ -371,7 +373,7 @@ class DeferredLoadTask extends CompilerTask {
|
| ClassElement implementation =
|
| element.enclosingClass.implementation;
|
| _collectAllElementsAndConstantsResolvedFrom(
|
| - implementation, elements, constants);
|
| + implementation, elements, constants, isMirrorUsage);
|
| }
|
|
|
| // Other elements, in particular instance members, are ignored as
|
| @@ -414,13 +416,16 @@ class DeferredLoadTask extends CompilerTask {
|
| /// Recursively traverses the graph of dependencies from [element], mapping
|
| /// deferred imports to each dependency it needs in the sets
|
| /// [_importedDeferredBy] and [_constantsDeferredBy].
|
| - void _mapDependencies(Element element, Import import) {
|
| + void _mapDependencies(Element element, Import import,
|
| + {isMirrorUsage: false}) {
|
| Set<Element> elements = _importedDeferredBy.putIfAbsent(import,
|
| () => new Set<Element>());
|
| Set<Constant> constants = _constantsDeferredBy.putIfAbsent(import,
|
| () => new Set<Constant>());
|
|
|
| - if (elements.contains(element)) return;
|
| + // Only process elements once, unless we are doing dependencies due to
|
| + // mirrors, which are added in additional traversals.
|
| + if (!isMirrorUsage && elements.contains(element)) return;
|
| // Anything used directly by main will be loaded from the start
|
| // We do not need to traverse it again.
|
| if (import != _fakeMainImport && _mainElements.contains(element)) return;
|
| @@ -432,7 +437,7 @@ class DeferredLoadTask extends CompilerTask {
|
|
|
| // This call can modify [_importedDeferredBy] and [_constantsDeferredBy].
|
| _collectAllElementsAndConstantsResolvedFrom(
|
| - element, dependentElements, constants);
|
| + element, dependentElements, constants, isMirrorUsage);
|
|
|
| LibraryElement library = element.library;
|
| for (Element dependency in dependentElements) {
|
| @@ -458,7 +463,7 @@ class DeferredLoadTask extends CompilerTask {
|
| // So we have to filter them out here.
|
| if (element is AnalyzableElementX && !element.hasTreeElements) return;
|
| if (compiler.backend.isNeededForReflection(element)) {
|
| - _mapDependencies(element, deferredImport);
|
| + _mapDependencies(element, deferredImport, isMirrorUsage: true);
|
| }
|
| }
|
|
|
|
|