]> Cypherpunks repositories - gostls13.git/commitdiff
go/types: clarify the documentation for Func.Pkg
authorJonathan Amsterdam <jba@google.com>
Tue, 10 Oct 2023 19:34:42 +0000 (15:34 -0400)
committerJonathan Amsterdam <jba@google.com>
Tue, 10 Oct 2023 22:48:41 +0000 (22:48 +0000)
Change-Id: Ia695960ba652143f4a48c1ca3495a043097acbb7
Reviewed-on: https://go-review.googlesource.com/c/go/+/534298
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>

src/cmd/compile/internal/types2/object.go
src/go/types/object.go

index 5c0ea8ca167a5c3d9520b6964f77d090eddc5dd8..075712dc9ccfeaaa0abdf46fd64d451e309734a1 100644 (file)
@@ -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.
index e47ef2ebecd7fa85a4bcc6d72970f70b5f43c33c..17c15d48b4f2264475ac535b523ba8ed243160c0 100644 (file)
@@ -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.