@@ -260,10 +260,38 @@ public static void main(String[] args) {
260
260
261
261
/**
262
262
* If one file defines a name and another uses it as a namespace, we have the
263
- * Constants.COLLDING_PROVIDE_ALIAS_POSTFIX workaround. In partial mode, Clutz can't see all
263
+ * Constants.COLLIDING_PROVIDE_ALIAS_POSTFIX workaround. In partial mode, Clutz can't see all
264
264
* definitions of a name, so the list of names that require aliases must be passed as an input.
265
+ * Also Closure Library uses some names as both classes and namespases. For example,
266
+ * `goog.ui.Component` is not only a class but also a namespace in `goog.ui.Component.EventType`.
267
+ * See https://github.com/google/closure-library/blob/master/closure/goog/ui/component.js
265
268
*/
266
- private Set <String > collidingProvides = new LinkedHashSet <>();
269
+ private Set <String > collidingProvides =
270
+ Sets .newHashSet (
271
+ "goog.ui.AdvancedTooltip" ,
272
+ "goog.ui.AnimatedZippy" ,
273
+ "goog.ui.Checkbox" ,
274
+ "goog.ui.ColorPicker" ,
275
+ "goog.ui.Component" ,
276
+ "goog.ui.Container" ,
277
+ "goog.ui.Control" ,
278
+ "goog.ui.Dialog" ,
279
+ "goog.ui.FilteredMenu" ,
280
+ "goog.ui.HoverCard" ,
281
+ "goog.ui.Menu" ,
282
+ "goog.ui.MenuItem" ,
283
+ "goog.ui.ModalPopup" ,
284
+ "goog.ui.Ratings" ,
285
+ "goog.ui.ScrollFloater" ,
286
+ "goog.ui.SliderBase" ,
287
+ "goog.ui.SplitPane" ,
288
+ "goog.ui.TableSorter" ,
289
+ "goog.ui.Textarea" ,
290
+ "goog.ui.TriStateMenuItem" ,
291
+ "goog.ui.Zippy" ,
292
+ "goog.ui.editor.AbstractDialog" ,
293
+ "goog.ui.editor.LinkDialog" ,
294
+ "goog.ui.tree.BaseNode" );
267
295
268
296
DeclarationGenerator (Options opts ) {
269
297
this .opts = opts ;
@@ -416,7 +444,7 @@ String generateDeclarations(
416
444
legacyNamespaceReexportMap =
417
445
new LegacyNamespaceReexportMapBuilder ()
418
446
.build (compiler .getParsedInputs (), opts .depgraph .getGoogProvides ());
419
- collidingProvides = opts .collidingProvides ;
447
+ collidingProvides . addAll ( opts .collidingProvides ) ;
420
448
}
421
449
422
450
unknownType = compiler .getTypeRegistry ().getNativeType (JSTypeNative .UNKNOWN_TYPE );
@@ -512,7 +540,7 @@ String produceDts(Depgraph depgraph) {
512
540
rewrittenProvides .add (rewritenProvide );
513
541
}
514
542
if (needsAlias (shadowedProvides , provide , symbol )) {
515
- emitName += Constants .COLLDING_PROVIDE_ALIAS_POSTFIX ;
543
+ emitName += Constants .COLLIDING_PROVIDE_ALIAS_POSTFIX ;
516
544
}
517
545
if (symbol == null ) {
518
546
// Sometimes goog.provide statements are used as pure markers for dependency management, or
@@ -858,7 +886,7 @@ private void processExternSymbols() {
858
886
boolean isDefault = isDefaultExport (symbol );
859
887
String emitName = symbol .getName ();
860
888
if (needsAlias (shadowedSymbols , symbol .getName (), symbol )) {
861
- emitName += Constants .COLLDING_PROVIDE_ALIAS_POSTFIX ;
889
+ emitName += Constants .COLLIDING_PROVIDE_ALIAS_POSTFIX ;
862
890
}
863
891
864
892
// There is nothing to emit for a namespace, because all its symbols will be visited later,
@@ -1485,6 +1513,9 @@ private TreeWalker(
1485
1513
1486
1514
private String getAbsoluteName (ObjectType objectType ) {
1487
1515
String name = objectType .getDisplayName ();
1516
+ if (collidingProvides .contains (name )) {
1517
+ name += Constants .COLLIDING_PROVIDE_ALIAS_POSTFIX ;
1518
+ }
1488
1519
// Names that do not have a namespace '.' are either platform names in the top level
1489
1520
// namespace like `Object` or `Element`, or they are unqualified `goog.provide`s, e.g.
1490
1521
// `goog.provide('Toplevel')`. In both cases they will be found with the naked name.
@@ -1513,7 +1544,7 @@ private void walk(TypedVar symbol, String emitName) {
1513
1544
// Since closure inlines all aliases before this step, check against
1514
1545
// the type name.
1515
1546
if (!isAliasedClassOrInterface (symbol , ftype )) {
1516
- visitClassOrInterface (getUnqualifiedName (symbol ), ftype );
1547
+ visitClassOrInterface (getUnqualifiedName (emitName ), ftype );
1517
1548
} else {
1518
1549
if (KNOWN_CLASS_ALIASES .containsKey (symbol .getName ())) {
1519
1550
visitKnownTypeValueAlias (
0 commit comments