You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Pkg() methods of all implementations of types.Object (named entities) return the
package that declared that entity... except one. PkgName's Pkg method returns the
object that is imported. For example:
package main
import foo "fmt"
var _ foo.Stringer
The object 'foo' is a PkgName, whose Pkg() returns not "main" but
"fmt". This is lossy, since it's impossible to get from foo to
"main" via the API, and inconsistent with all other objects, making it much
harder for clients to use. (Essentially, they must pass around a pair of (*Package,
Object) in lieu of Object because the Pkg() method is not to be trusted.)
I think PkgName should have a new method, ImportedPackage() that returns the package
that was imported, as distinct from the importing package that logically contains the
identifier.
(go/ssa and oracle will need to be audited, among others. If you send me a CL for
go/types, I'll take care of the rest.)
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: