Skip to content

Commit 464aae7

Browse files
mateusz834gopherbot
authored andcommitted
go/printer: check whether !isTypeElem, instead of combinesWithName when ParenExpr
See discussion in CL 610115 and CL 610758. For #69206 Change-Id: I16f394cb3440106650fb64a466f2723a4dba3871 GitHub-Last-Rev: 37993b5 GitHub-Pull-Request: #69309 Reviewed-on: https://go-review.googlesource.com/c/go/+/611355 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> Reviewed-by: Robert Griesemer <[email protected]> Auto-Submit: Robert Griesemer <[email protected]>
1 parent 42d1f08 commit 464aae7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/go/printer/nodes.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ func (p *printer) parameters(fields *ast.FieldList, mode paramMode) {
380380
if closing := p.lineFor(fields.Closing); 0 < prevLine && prevLine < closing {
381381
p.print(token.COMMA)
382382
p.linebreak(closing, 0, ignore, true)
383-
} else if mode == typeTParam && fields.NumFields() == 1 && combinesWithName(fields.List[0].Type) {
383+
} else if mode == typeTParam && fields.NumFields() == 1 && combinesWithName(stripParensAlways(fields.List[0].Type)) {
384384
// A type parameter list [P T] where the name P and the type expression T syntactically
385385
// combine to another valid (value) expression requires a trailing comma, as in [P *T,]
386386
// (or an enclosing interface as in [P interface(*T)]), so that the type parameter list
@@ -411,7 +411,7 @@ func combinesWithName(x ast.Expr) bool {
411411
case *ast.BinaryExpr:
412412
return combinesWithName(x.X) && !isTypeElem(x.Y)
413413
case *ast.ParenExpr:
414-
return combinesWithName(x.X)
414+
return !isTypeElem(x.X)
415415
}
416416
return false
417417
}

0 commit comments

Comments
 (0)