1
0
mirror of https://github.com/golang/go synced 2024-11-11 23:20:24 -07:00

[dev.typeparams] go/types: adjust logic for method expression arg naming

CL 325369 improved this logic in types2. Port this improvement back to
go/types.

Change-Id: I5f859cbffd88bb3db09a81c2389269f7bd0869f9
Reviewed-on: https://go-review.googlesource.com/c/go/+/330069
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
Rob Findley 2021-06-22 10:13:54 -04:00 committed by Robert Findley
parent 541612b974
commit 62095c66e0

View File

@ -587,16 +587,15 @@ func (check *Checker) selector(x *operand, e *ast.SelectorExpr) {
if sig.params != nil {
params = sig.params.vars
}
// Be consistent about named/unnamed parameters.
needName := true
for _, param := range params {
if param.Name() == "" {
needName = false
break
}
}
// Be consistent about named/unnamed parameters. This is not needed
// for type-checking, but the newly constructed signature may appear
// in an error message and then have mixed named/unnamed parameters.
// (An alternative would be to not print parameter names in errors,
// but it's useful to see them; this is cheap and method expressions
// are rare.)
name := ""
if needName {
if len(params) > 0 && params[0].name != "" {
// name needed
name = sig.recv.name
if name == "" {
name = "_"