From: Jonathan Amsterdam Date: Tue, 10 Oct 2023 19:34:42 +0000 (-0400) Subject: go/types: clarify the documentation for Func.Pkg X-Git-Tag: go1.22rc1~631 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=dacf1f1e10a6b1ed02b6b935e502ddf8585b3748;p=gostls13.git go/types: clarify the documentation for Func.Pkg Change-Id: Ia695960ba652143f4a48c1ca3495a043097acbb7 Reviewed-on: https://go-review.googlesource.com/c/go/+/534298 TryBot-Result: Gopher Robot Reviewed-by: Robert Findley Reviewed-by: Alan Donovan Run-TryBot: Jonathan Amsterdam --- diff --git a/src/cmd/compile/internal/types2/object.go b/src/cmd/compile/internal/types2/object.go index 5c0ea8ca16..075712dc9c 100644 --- a/src/cmd/compile/internal/types2/object.go +++ b/src/cmd/compile/internal/types2/object.go @@ -406,6 +406,12 @@ func (obj *Func) Origin() *Func { return obj } +// Pkg returns the package to which the function belongs. +// +// The result is nil for methods of types in the Universe scope, +// like [error.Error]. +func (obj *Func) Pkg() *Package { return obj.object.Pkg() } + // hasPtrRecv reports whether the receiver is of the form *T for the given method obj. func (obj *Func) hasPtrRecv() bool { // If a method's receiver type is set, use that as the source of truth for the receiver. diff --git a/src/go/types/object.go b/src/go/types/object.go index e47ef2ebec..17c15d48b4 100644 --- a/src/go/types/object.go +++ b/src/go/types/object.go @@ -408,6 +408,12 @@ func (obj *Func) Origin() *Func { return obj } +// Pkg returns the package to which the function belongs. +// +// The result is nil for methods of types in the Universe scope, +// like [error.Error]. +func (obj *Func) Pkg() *Package { return obj.object.Pkg() } + // hasPtrRecv reports whether the receiver is of the form *T for the given method obj. func (obj *Func) hasPtrRecv() bool { // If a method's receiver type is set, use that as the source of truth for the receiver.