go/ast: remove FuncDecl.IsMethod for Go 1.17

The IsMethod method was added to FuncDecl in the process of working on
support for type parameters, but is now only used in one place. It also
didn't go through the proposal process. Remove it for 1.17.

Also clean up a doc comment that mentioned type parameters.

Fixes #46297

Change-Id: I432bdd626324f613baf059540b7c5436985b2b16
Reviewed-on: https://go-review.googlesource.com/c/go/+/323369
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-05-27 22:27:55 -04:00 committed by Robert Findley
parent 639acdc833
commit 3de3440fb9
2 changed files with 2 additions and 6 deletions

View file

@ -259,7 +259,7 @@ func (f *FieldList) End() token.Pos {
return token.NoPos
}
// NumFields returns the number of (type) parameters or struct fields represented by a FieldList.
// NumFields returns the number of parameters or struct fields represented by a FieldList.
func (f *FieldList) NumFields() int {
n := 0
if f != nil {
@ -973,10 +973,6 @@ type (
}
)
func (f *FuncDecl) IsMethod() bool {
return f.Recv.NumFields() != 0
}
// Pos and End implementations for declaration nodes.
func (d *BadDecl) Pos() token.Pos { return d.From }

View file

@ -383,7 +383,7 @@ func (check *Checker) collectObjects() {
info := &declInfo{file: fileScope, fdecl: d.decl}
name := d.decl.Name.Name
obj := NewFunc(d.decl.Name.Pos(), pkg, name, nil)
if !d.decl.IsMethod() {
if d.decl.Recv.NumFields() == 0 {
// regular function
if d.decl.Recv != nil {
check.error(d.decl.Recv, _BadRecv, "method is missing receiver")