@@ -625,4 +625,37 @@ public void testAddSingletonGetter() {
625
625
"$jscomp.inherits(Subclass, Example);" ,
626
626
"goog.addSingletonGetter(Subclass);" ));
627
627
}
628
+
629
+ @ Test
630
+ public void testNonQnameConstructor_doesntPolluteListOfAssignments () {
631
+ // Reproduce a pretty bad bug caused by accidentally reading/writing 'null' keys from a map.
632
+ test (
633
+ lines (
634
+ "const ns = {};" ,
635
+ "/** @constructor */" ,
636
+ "ns['NOT_A_NAME'] = function() {};" ,
637
+ "ns['NOT_A_NAME'].staticMethod = function() { alert(1); }" ,
638
+ "" ,
639
+ "/** @constructor */" ,
640
+ "const Example = function() {}" ,
641
+ "" ,
642
+ "/** @constructor @extends {Example} */" ,
643
+ "function Subclass() {}" ,
644
+ "$jscomp.inherits(Subclass, Example);" ),
645
+ lines (
646
+ "const ns = {};" ,
647
+ "/** @constructor */" ,
648
+ "ns['NOT_A_NAME'] = function() {};" ,
649
+ "ns['NOT_A_NAME'].staticMethod = function() { alert(1); }" ,
650
+ "" ,
651
+ "/** @constructor */" ,
652
+ "const Example = function() {}" ,
653
+ "" ,
654
+ "/** @constructor @extends {Example} */" ,
655
+ "function Subclass() {}" ,
656
+ "$jscomp.inherits(Subclass, Example);" ,
657
+ // TODO(b/293320792) - stop producing this assignment, there's no
658
+ // actual Example.staticMethod.
659
+ "Subclass.staticMethod = Example.staticMethod;" ));
660
+ }
628
661
}
0 commit comments