Track initializers already seen (fixes #21439)
R=jakemac@google.com
Review URL: https://codereview.chromium.org//700733002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41499 260f80e4-7a28-3924-810f-c04153c831b5
diff --git a/pkg/polymer/lib/src/build/script_compactor.dart b/pkg/polymer/lib/src/build/script_compactor.dart
index 20d8052..16bd7c7 100644
--- a/pkg/polymer/lib/src/build/script_compactor.dart
+++ b/pkg/polymer/lib/src/build/script_compactor.dart
@@ -249,13 +249,19 @@
// Process all classes and top-level functions to include initializers,
// register custom elements, and include special fields and methods in
// custom element classes.
+ var functionsSeen = new Set<FunctionElement>();
+ var classesSeen = new Set<ClassElement>();
for (var id in entryLibraries) {
var lib = resolver.getLibrary(id);
for (var fun in _visibleTopLevelMethodsOf(lib)) {
+ if (functionsSeen.contains(fun)) continue;
+ functionsSeen.add(fun);
_processFunction(fun, id);
}
for (var cls in _visibleClassesOf(lib)) {
+ if (classesSeen.contains(cls)) continue;
+ classesSeen.add(cls);
_processClass(cls, id, recorder);
}
}
@@ -824,8 +830,7 @@
var result = [];
result.addAll(lib.units.expand((u) => u.functions));
for (var e in lib.exports) {
- var exported = e.exportedLibrary.units
- .expand((u) => u.functions).toList();
+ var exported = e.exportedLibrary.units.expand((u) => u.functions).toList();
_filter(exported, e.combinators);
result.addAll(exported);
}
diff --git a/pkg/polymer/pubspec.yaml b/pkg/polymer/pubspec.yaml
index f94eb8a..ad7a7b7 100644
--- a/pkg/polymer/pubspec.yaml
+++ b/pkg/polymer/pubspec.yaml
@@ -1,5 +1,5 @@
name: polymer
-version: 0.15.1+3
+version: 0.15.1+4
author: Polymer.dart Authors <web-ui-dev@dartlang.org>
description: >
Polymer.dart is a new type of library for the web, built on top of Web
diff --git a/pkg/polymer/test/build/script_compactor_test.dart b/pkg/polymer/test/build/script_compactor_test.dart
index 3e844d5..2f14cd4 100644
--- a/pkg/polymer/test/build/script_compactor_test.dart
+++ b/pkg/polymer/test/build/script_compactor_test.dart
@@ -245,7 +245,8 @@
'<!DOCTYPE html><html><head>'
'</head><body><div></div>',
'a|web/test.html._data':
- expectedData(['web/a.dart', 'web/b.dart', 'web/c.dart', 'web/d.dart']),
+ expectedData(['web/a.dart', 'web/b.dart', 'web/c.dart',
+ 'web/i.dart', 'web/j.dart', 'web/d.dart']),
'a|web/d.dart':
'library d;\n'
'import "package:polymer/polymer.dart";\n'
@@ -253,6 +254,7 @@
'a|web/a.dart':
'import "package:polymer/polymer.dart";\n'
+ 'export "i.dart" hide mI2;\n'
'@initMethod mA(){}\n',
'a|web/b.dart':
@@ -296,6 +298,15 @@
'@initMethod mH1(){}\n'
'@CustomTag("x-h2") class XH2 extends PolymerElement {}\n'
'@initMethod mH2(){}\n',
+
+ 'a|web/i.dart':
+ 'import "package:polymer/polymer.dart";\n'
+ '@CustomTag("x-i") class XI extends PolymerElement {}\n'
+ '@initMethod mI1(){}\n'
+ '@initMethod mI2(){}\n',
+
+ 'a|web/j.dart':
+ 'export "a.dart";\n',
}, {
'a|web/test.html':
'<!DOCTYPE html><html><head></head><body><div></div>'
@@ -308,36 +319,43 @@
import 'a.dart' as i0;
import 'b.dart' as i1;
import 'c.dart' as i2;
- import 'd.dart' as i3;
+ import 'i.dart' as i3;
+ import 'j.dart' as i4;
+ import 'd.dart' as i5;
${DEFAULT_IMPORTS.join('\n')}
- import 'e.dart' as smoke_0;
+ import 'i.dart' as smoke_0;
import 'package:polymer/polymer.dart' as smoke_1;
- import 'f.dart' as smoke_2;
- import 'g.dart' as smoke_3;
- import 'h.dart' as smoke_4;
- import 'c.dart' as smoke_5;
+ import 'e.dart' as smoke_2;
+ import 'f.dart' as smoke_3;
+ import 'g.dart' as smoke_4;
+ import 'h.dart' as smoke_5;
+ import 'c.dart' as smoke_6;
void main() {
useGeneratedCode(new StaticConfiguration(
checkedMode: false,
parents: {
- smoke_5.XC1: smoke_1.PolymerElement,
- smoke_5.XC2: smoke_1.PolymerElement,
- smoke_0.XE: smoke_1.PolymerElement,
- smoke_2.XF1: smoke_1.PolymerElement,
- smoke_3.XG2: smoke_1.PolymerElement,
- smoke_4.XH1: smoke_1.PolymerElement,
+ smoke_6.XC1: smoke_1.PolymerElement,
+ smoke_6.XC2: smoke_1.PolymerElement,
+ smoke_2.XE: smoke_1.PolymerElement,
+ smoke_3.XF1: smoke_1.PolymerElement,
+ smoke_4.XG2: smoke_1.PolymerElement,
+ smoke_5.XH1: smoke_1.PolymerElement,
+ smoke_0.XI: smoke_1.PolymerElement,
},
declarations: {
- smoke_5.XC1: {},
- smoke_5.XC2: {},
- smoke_0.XE: {},
- smoke_2.XF1: {},
- smoke_3.XG2: {},
- smoke_4.XH1: {},
+ smoke_6.XC1: {},
+ smoke_6.XC2: {},
+ smoke_2.XE: {},
+ smoke_3.XF1: {},
+ smoke_4.XG2: {},
+ smoke_5.XH1: {},
+ smoke_0.XI: {},
}));
configureForDeployment([
i0.mA,
+ i0.mI1,
+ () => Polymer.register('x-i', i0.XI),
i1.mB,
i1.mE,
i1.mF1,
@@ -348,9 +366,10 @@
() => Polymer.register('x-h1', i1.XH1),
() => Polymer.register('x-c1', i2.XC1),
() => Polymer.register('x-c2', i2.XC2),
- i3.mD,
+ i3.mI2,
+ i5.mD,
]);
- i3.main();
+ i5.main();
}
'''.replaceAll('\n ', '\n'),
}, null);