From 3de3440fb9b2d7f8a14b33f96fcfcee8eb61ec55 Mon Sep 17 00:00:00 2001 From: Rob Findley Date: Thu, 27 May 2021 22:27:55 -0400 Subject: [PATCH] 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 Run-TryBot: Robert Findley TryBot-Result: Go Bot Reviewed-by: Robert Griesemer --- src/go/ast/ast.go | 6 +----- src/go/types/resolver.go | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/go/ast/ast.go b/src/go/ast/ast.go index c87529ec77d..337c87fd797 100644 --- a/src/go/ast/ast.go +++ b/src/go/ast/ast.go @@ -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 } diff --git a/src/go/types/resolver.go b/src/go/types/resolver.go index f67fc65cd18..114647a2fff 100644 --- a/src/go/types/resolver.go +++ b/src/go/types/resolver.go @@ -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")