@@ -241,10 +241,38 @@ public static void main(String[] args) {
241
241
242
242
/**
243
243
* If one file defines a name and another uses it as a namespace, we have the
244
- * Constants.COLLDING_PROVIDE_ALIAS_POSTFIX workaround. In partial mode, Clutz can't see all
244
+ * Constants.COLLIDING_PROVIDE_ALIAS_POSTFIX workaround. In partial mode, Clutz can't see all
245
245
* definitions of a name, so the list of names that require aliases must be passed as an input.
246
+ * Also Closure Library uses some names as both classes and namespases. For example,
247
+ * `goog.ui.Component` is not only a class but also a namespace in `goog.ui.Component.EventType`.
248
+ * See https://github.com/google/closure-library/blob/master/closure/goog/ui/component.js
246
249
*/
247
- private Set <String > collidingProvides = new LinkedHashSet <>();
250
+ private Set <String > collidingProvides =
251
+ Sets .newHashSet (
252
+ "goog.ui.AdvancedTooltip" ,
253
+ "goog.ui.AnimatedZippy" ,
254
+ "goog.ui.Checkbox" ,
255
+ "goog.ui.ColorPicker" ,
256
+ "goog.ui.Component" ,
257
+ "goog.ui.Container" ,
258
+ "goog.ui.Control" ,
259
+ "goog.ui.Dialog" ,
260
+ "goog.ui.FilteredMenu" ,
261
+ "goog.ui.HoverCard" ,
262
+ "goog.ui.Menu" ,
263
+ "goog.ui.MenuItem" ,
264
+ "goog.ui.ModalPopup" ,
265
+ "goog.ui.Ratings" ,
266
+ "goog.ui.ScrollFloater" ,
267
+ "goog.ui.SliderBase" ,
268
+ "goog.ui.SplitPane" ,
269
+ "goog.ui.TableSorter" ,
270
+ "goog.ui.Textarea" ,
271
+ "goog.ui.TriStateMenuItem" ,
272
+ "goog.ui.Zippy" ,
273
+ "goog.ui.editor.AbstractDialog" ,
274
+ "goog.ui.editor.LinkDialog" ,
275
+ "goog.ui.tree.BaseNode" );
248
276
249
277
DeclarationGenerator (Options opts ) {
250
278
this .opts = opts ;
@@ -397,7 +425,7 @@ String generateDeclarations(
397
425
legacyNamespaceReexportMap =
398
426
new LegacyNamespaceReexportMapBuilder ()
399
427
.build (compiler .getParsedInputs (), opts .depgraph .getGoogProvides ());
400
- collidingProvides = opts .collidingProvides ;
428
+ collidingProvides . addAll ( opts .collidingProvides ) ;
401
429
}
402
430
403
431
unknownType = compiler .getTypeRegistry ().getNativeType (JSTypeNative .UNKNOWN_TYPE );
@@ -487,7 +515,7 @@ String produceDts(Depgraph depgraph) {
487
515
rewrittenProvides .add (rewritenProvide );
488
516
}
489
517
if (needsAlias (shadowedProvides , provide , symbol )) {
490
- emitName += Constants .COLLDING_PROVIDE_ALIAS_POSTFIX ;
518
+ emitName += Constants .COLLIDING_PROVIDE_ALIAS_POSTFIX ;
491
519
}
492
520
if (symbol == null ) {
493
521
// Sometimes goog.provide statements are used as pure markers for dependency management, or
@@ -833,7 +861,7 @@ private void processExternSymbols() {
833
861
boolean isDefault = isDefaultExport (symbol );
834
862
String emitName = symbol .getName ();
835
863
if (needsAlias (shadowedSymbols , symbol .getName (), symbol )) {
836
- emitName += Constants .COLLDING_PROVIDE_ALIAS_POSTFIX ;
864
+ emitName += Constants .COLLIDING_PROVIDE_ALIAS_POSTFIX ;
837
865
}
838
866
839
867
// There is nothing to emit for a namespace, because all its symbols will be visited later,
@@ -1458,6 +1486,9 @@ private TreeWalker(
1458
1486
1459
1487
private String getAbsoluteName (ObjectType objectType ) {
1460
1488
String name = objectType .getDisplayName ();
1489
+ if (collidingProvides .contains (name )) {
1490
+ name += Constants .COLLIDING_PROVIDE_ALIAS_POSTFIX ;
1491
+ }
1461
1492
// Names that do not have a namespace '.' are either platform names in the top level
1462
1493
// namespace like `Object` or `Element`, or they are unqualified `goog.provide`s, e.g.
1463
1494
// `goog.provide('Toplevel')`. In both cases they will be found with the naked name.
@@ -1486,7 +1517,7 @@ private void walk(TypedVar symbol, String emitName) {
1486
1517
// Since closure inlines all aliases before this step, check against
1487
1518
// the type name.
1488
1519
if (!isAliasedClassOrInterface (symbol , ftype )) {
1489
- visitClassOrInterface (getUnqualifiedName (symbol ), ftype );
1520
+ visitClassOrInterface (getUnqualifiedName (emitName ), ftype );
1490
1521
} else {
1491
1522
if (KNOWN_CLASS_ALIASES .containsKey (symbol .getName ())) {
1492
1523
visitKnownTypeValueAlias (
0 commit comments