Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1499)

Unified Diff: sdk/lib/_internal/compiler/implementation/dart_backend/backend.dart

Issue 224723009: Emit classes that are only referenced by type literals. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Adjust test expectations. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/co19/co19-dart2dart.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/dart_backend/backend.dart
diff --git a/sdk/lib/_internal/compiler/implementation/dart_backend/backend.dart b/sdk/lib/_internal/compiler/implementation/dart_backend/backend.dart
index f8bd7101e9b4a85184fa371266211f6da5a4986a..fdd9050f60c1a6978796d02fbd4160bbd335da95 100644
--- a/sdk/lib/_internal/compiler/implementation/dart_backend/backend.dart
+++ b/sdk/lib/_internal/compiler/implementation/dart_backend/backend.dart
@@ -45,6 +45,8 @@ class DartBackend extends Backend {
Map<Element, TreeElements> get resolvedElements =>
compiler.enqueuer.resolution.resolvedElements;
+ final Set<ClassElement> usedTypeLiterals = new Set<ClassElement>();
+
/**
* Tells whether it is safe to remove type declarations from variables,
* functions parameters. It becomes not safe if:
@@ -297,6 +299,16 @@ class DartBackend extends Backend {
}
}
});
+ Set<ClassElement> emitNoMembersFor = new Set<ClassElement>();
+ usedTypeLiterals.forEach((ClassElement element) {
+ if (shouldOutput(element)) {
+ if (!topLevelElements.contains(element)) {
+ // The class is only referenced by type literals.
+ emitNoMembersFor.add(element);
+ }
+ addClass(element);
+ }
+ });
// Add synthesized constructors to classes with no resolved constructors,
// but which originally had any constructor. That should prevent
@@ -306,6 +318,7 @@ class DartBackend extends Backend {
NextClassElement:
for (ClassElement classElement in classMembers.keys) {
+ if (emitNoMembersFor.contains(classElement)) continue;
for (Element member in classMembers[classElement]) {
if (member.isConstructor()) continue NextClassElement;
}
@@ -381,7 +394,7 @@ class DartBackend extends Backend {
// Emit XML for AST instead of the program.
for (final topLevel in sortedTopLevels) {
- if (topLevel.isClass()) {
+ if (topLevel.isClass() && !emitNoMembersFor.contains(topLevel)) {
// TODO(antonm): add some class info.
sortedClassMembers[topLevel].forEach(outputElement);
} else {
@@ -453,6 +466,14 @@ class DartBackend extends Backend {
return new Future.value();
}
+ void registerTypeLiteral(Element element,
+ Enqueuer enqueuer,
+ TreeElements elements) {
+ if (element.isClass()) {
+ usedTypeLiterals.add(element);
+ }
+ }
+
void registerStaticSend(Element element, Node node) {
if (useMirrorHelperLibrary) {
mirrorRenamer.registerStaticSend(element, node);
« no previous file with comments | « no previous file | tests/co19/co19-dart2dart.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698