Skip to content

Commit 4212eb4

Browse files
committed
[Format] Dont treat LBrace after extends/implements as initializer list
This extends the fix in llvm#106242 for other derived class types.
1 parent 069b841 commit 4212eb4

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

clang/lib/Format/UnwrappedLineParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4042,7 +4042,7 @@ void UnwrappedLineParser::parseRecord(bool ParseAsExpr) {
40424042
}
40434043

40444044
auto IsListInitialization = [&] {
4045-
if (!ClassName || IsDerived)
4045+
if (!ClassName || IsDerived || JSPastExtendsOrImplements)
40464046
return false;
40474047
assert(FormatTok->is(tok::l_brace));
40484048
const auto *Prev = FormatTok->getPreviousNonComment();

clang/unittests/Format/FormatTestJS.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,12 +579,17 @@ TEST_F(FormatTestJS, GoogScopes) {
579579
"});");
580580
}
581581

582-
TEST_F(FormatTestJS, GoogAnonymousClass) {
582+
TEST_F(FormatTestJS, ClassExtends) {
583583
verifyFormat("a = class extends goog.structs.a {\n"
584584
" a() {\n"
585585
" return 0;\n"
586586
" }\n"
587587
"};");
588+
verifyFormat("a = class Foo extends goog.structs.a {\n"
589+
" a() {\n"
590+
" return 0;\n"
591+
" }\n"
592+
"};");
588593
}
589594

590595
TEST_F(FormatTestJS, IIFEs) {

0 commit comments

Comments
 (0)