fix(codegen): print parentheses correctly for ClassHeritage (#7637)

closes #7631
This commit is contained in:
Boshen 2024-12-04 06:43:32 +00:00
parent d2767bea62
commit e787e9d41a
2 changed files with 3 additions and 1 deletions

View file

@ -2185,7 +2185,7 @@ impl Gen for Class<'_> {
} }
if let Some(super_class) = self.super_class.as_ref() { if let Some(super_class) = self.super_class.as_ref() {
p.print_str(" extends "); p.print_str(" extends ");
super_class.print_expr(p, Precedence::Call, Context::empty()); super_class.print_expr(p, Precedence::Postfix, Context::empty());
if let Some(super_type_parameters) = &self.super_type_parameters { if let Some(super_type_parameters) = &self.super_type_parameters {
super_type_parameters.print(p, ctx); super_type_parameters.print(p, ctx);
} }

View file

@ -615,6 +615,8 @@ fn test_class() {
test("class Foo { static foo() {} }", "class Foo {\n\tstatic foo() {}\n}\n"); test("class Foo { static foo() {} }", "class Foo {\n\tstatic foo() {}\n}\n");
test("class Foo { static get foo() {} }", "class Foo {\n\tstatic get foo() {}\n}\n"); test("class Foo { static get foo() {} }", "class Foo {\n\tstatic get foo() {}\n}\n");
test("class Foo { static set foo(x) {} }", "class Foo {\n\tstatic set foo(x) {}\n}\n"); test("class Foo { static set foo(x) {} }", "class Foo {\n\tstatic set foo(x) {}\n}\n");
test("class Foo extends foo() {}", "class Foo extends foo() {}\n");
} }
#[test] #[test]