Skip to content

Commit 740b9de

Browse files
Closure Teamcopybara-github
authored andcommitted
Add InlineAndCollapseProperties test case for renaming class expression inner names. Currently incorrectly handled.
PiperOrigin-RevId: 789819554
1 parent a4aee39 commit 740b9de

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

test/com/google/javascript/jscomp/InlineAndCollapsePropertiesTest.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3563,6 +3563,40 @@ class Baz extends Bar {
35633563
""");
35643564
}
35653565

3566+
@Test
3567+
public void testClassExpressionWithInnerClassName() {
3568+
test(
3569+
"""
3570+
const OuterName = class InnerName {
3571+
static sf1 = 1;
3572+
static sf2 = InnerName.sf1;
3573+
static sf3 = this.sf2;
3574+
3575+
static {
3576+
Object.defineProperties(InnerName.prototype, {bar: {value: 1}});
3577+
InnerName.sf2++;
3578+
this.sf3++;
3579+
}
3580+
};
3581+
""",
3582+
// TODO: b/435685153 - Resolve the incorrect InnerName rewrite to OuterName.
3583+
// Incorrectly replaces InnerName with OuterName. OuterName will not yet be defined when
3584+
// referenced from the static field initializer and static initialization block.
3585+
"""
3586+
const OuterName = class InnerName {
3587+
static sf1 = 1;
3588+
static sf2 = OuterName.sf1;
3589+
static sf3 = this.sf2;
3590+
3591+
static {
3592+
Object.defineProperties(OuterName.prototype, {bar:{value:1}});
3593+
OuterName.sf2++;
3594+
this.sf3++;
3595+
}
3596+
};
3597+
""");
3598+
}
3599+
35663600
@Test
35673601
public void testCommaCallAliasing1() {
35683602
test(

0 commit comments

Comments
 (0)