Skip to content

Commit fbf2ce9

Browse files
authored
Don't write a trailing comma in extension type representation clauses. (#1518)
I guess trailing commas aren't allowed there. Who knew? Fix #1505.
1 parent c42eee5 commit fbf2ce9

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

lib/src/front_end/ast_node_visitor.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1574,7 +1574,8 @@ class AstNodeVisitor extends ThrowingAstVisitor<void> with PieceFactory {
15741574
void visitRepresentationDeclaration(RepresentationDeclaration node) {
15751575
pieces.visit(node.constructorName);
15761576

1577-
var builder = DelimitedListBuilder(this);
1577+
var builder =
1578+
DelimitedListBuilder(this, const ListStyle(commas: Commas.nonTrailing));
15781579
builder.leftBracket(node.leftParenthesis);
15791580
builder.add(pieces.build(() {
15801581
writeParameter(

test/tall/declaration/extension_type.unit

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ extension type const A.name(int a) {}
1212
extension type A<T extends int, R>(int a) {}
1313
<<<
1414
extension type A<T extends int, R>(
15-
int a,
15+
int a
1616
) {}
1717
>>> Indentation in body.
1818
extension type A(int a) {
@@ -39,15 +39,15 @@ extension type E(T i) implements I, J {}
3939
extension type LongExtensionType(LongTypeName a) {}
4040
<<<
4141
extension type LongExtensionType(
42-
LongTypeName a,
42+
LongTypeName a
4343
) {}
4444
>>> Split in representation with implements clause.
4545
extension type LongExtensionType(LongTypeName a) implements Something {
4646
method() {;}
4747
}
4848
<<<
4949
extension type LongExtensionType(
50-
LongTypeName a,
50+
LongTypeName a
5151
)
5252
implements Something {
5353
method() {

test/tall/declaration/extension_type_comment.unit

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ implements /*k*/ I1 /*l*/ , /*m*/ I2 /*n*/ { /*o*/ } /*p*/
88
extension /*b*/ type /*c*/ A
99
/*d*/ ( /*e*/
1010
@ /*f*/ override /*g*/
11-
int /*h*/ a /*i*/,
11+
int /*h*/ a /*i*/
1212
) /*j*/
1313
implements /*k*/
1414
I1 /*l*/, /*m*/
@@ -54,7 +54,7 @@ name // j
5454
@ // l
5555
required // m
5656
int // n
57-
a, // o
57+
a // o
5858
) // p
5959
implements // q
6060
I // r

test/tall/regression/1500/1505.unit

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
>>>
2+
extension type JSExportedDartFunction._(
3+
JSExportedDartFunctionRepType _jsExportedDartFunction
4+
) implements JSFunction {}
5+
<<<
6+
extension type JSExportedDartFunction._(
7+
JSExportedDartFunctionRepType _jsExportedDartFunction
8+
)
9+
implements JSFunction {}

0 commit comments

Comments
 (0)