Skip to content

Commit 3de3440

Browse files
committed
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 golang#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>
1 parent 639acdc commit 3de3440

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

src/go/ast/ast.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ func (f *FieldList) End() token.Pos {
259259
return token.NoPos
260260
}
261261

262-
// NumFields returns the number of (type) parameters or struct fields represented by a FieldList.
262+
// NumFields returns the number of parameters or struct fields represented by a FieldList.
263263
func (f *FieldList) NumFields() int {
264264
n := 0
265265
if f != nil {
@@ -973,10 +973,6 @@ type (
973973
}
974974
)
975975

976-
func (f *FuncDecl) IsMethod() bool {
977-
return f.Recv.NumFields() != 0
978-
}
979-
980976
// Pos and End implementations for declaration nodes.
981977

982978
func (d *BadDecl) Pos() token.Pos { return d.From }

src/go/types/resolver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ func (check *Checker) collectObjects() {
383383
info := &declInfo{file: fileScope, fdecl: d.decl}
384384
name := d.decl.Name.Name
385385
obj := NewFunc(d.decl.Name.Pos(), pkg, name, nil)
386-
if !d.decl.IsMethod() {
386+
if d.decl.Recv.NumFields() == 0 {
387387
// regular function
388388
if d.decl.Recv != nil {
389389
check.error(d.decl.Recv, _BadRecv, "method is missing receiver")

0 commit comments

Comments
 (0)