| Index: lib/compiler/implementation/dart_backend/backend.dart
|
| diff --git a/lib/compiler/implementation/dart_backend/backend.dart b/lib/compiler/implementation/dart_backend/backend.dart
|
| index f64cc13d349566cde41f450b1fd8458559d471ba..24d77a7b073d6b532c7faba2a1e612ca573e54d4 100644
|
| --- a/lib/compiler/implementation/dart_backend/backend.dart
|
| +++ b/lib/compiler/implementation/dart_backend/backend.dart
|
| @@ -70,10 +70,15 @@ class DartBackend extends Backend {
|
| !isDartCoreLib(compiler, element.getLibrary());
|
|
|
| try {
|
| + Set<TypedefElement> typedefs = new Set<TypedefElement>();
|
| PlaceholderCollector collector = new PlaceholderCollector(compiler);
|
| resolvedElements.forEach((element, treeElements) {
|
| if (!shouldOutput(element)) return;
|
| + if (element is AbstractFieldElement) return;
|
| collector.collect(element, treeElements);
|
| + new ReferencedElementCollector(
|
| + compiler, element, treeElements, typedefs)
|
| + .collect();
|
| });
|
|
|
| ConflictingRenamer renamer =
|
| @@ -95,6 +100,8 @@ class DartBackend extends Backend {
|
| emitter.outputElement(element);
|
| });
|
|
|
| + typedefs.forEach(emitter.outputElement);
|
| +
|
| // Now output resolved classes with inner elements we met before.
|
| resolvedClassMembers.forEach(emitter.outputClass);
|
| compiler.assembledCode = emitter.toString();
|
| @@ -123,3 +130,35 @@ bool isDartCoreLib(Compiler compiler, LibraryElement libraryElement) {
|
| }
|
| return false;
|
| }
|
| +
|
| +/**
|
| + * Some elements are not recorded by resolver now,
|
| + * for example, typedefs or classes which are only
|
| + * used in signatures, as/is operators or in super clauses
|
| + * (just to name a few). Retraverse AST to pick those up.
|
| + */
|
| +class ReferencedElementCollector extends AbstractVisitor {
|
| + final Compiler compiler;
|
| + final Element element;
|
| + final TreeElements treeElements;
|
| + final Set<TypedefElement> typedefs;
|
| +
|
| + ReferencedElementCollector(
|
| + this.compiler,
|
| + this.element, this.treeElements,
|
| + this.typedefs);
|
| +
|
| + visitNode(Node node) { node.visitChildren(this); }
|
| +
|
| + visitTypeAnnotation(TypeAnnotation typeAnnotation) {
|
| + Element element = treeElements[typeAnnotation];
|
| + if (element !== null) {
|
| + if (element.isTypedef()) typedefs.add(element);
|
| + }
|
| + typeAnnotation.visitChildren(this);
|
| + }
|
| +
|
| + void collect() {
|
| + element.parseNode(compiler).accept(this);
|
| + }
|
| +}
|
|
|