1
0
mirror of https://github.com/golang/go synced 2024-11-18 18:44:42 -07:00
The Go programming language
Go to file
Alan Donovan 9a9fb35468 go.types/go/types: document primary vs. secondary Package distinction.
And: add accessor to get the primary from a secondary Package.

This change documents a surprising fact about the current
go/types resolver implementation, namely that each ast.ImportSpec
    import "fmt"
creates a new ("secondary") Package object for fmt with the
same String, Name, Path and Scope as the canonical ("primary")
fmt package, but with a different identity.

This change also adds an accessor Package.Primary() that
returns the primary package associated with a secondary
package object, if any.

IMHO the current design is wrong, and the resolver should not
create secondary packages at all.  Even if a package is
imported under a non-default name, as in
    import f "fmt"
    ...
    f.Print
we should just regard f as a reference to the existing package
"fmt", not as the defining identifier for a secondary package.
What we would lose by such a change (the connection of the two
f's in 'f.Print' and 'import f "fmt"') seems a small price to
pay.

This CL is thus just a minimal change to permit clients to
make progress under the status quo.

R=r, gri, crawshaw
CC=golang-dev
https://golang.org/cl/13626043
2013-09-10 14:11:17 -04:00
cmd go.tools/oracle: restore edits lost in rev aa9b649bccd9 (botched merge) 2013-09-09 21:31:33 -04:00
dashboard go.tools/dashboard: implement dashboard using vcs package. 2013-08-27 21:52:18 -07:00
go go.types/go/types: document primary vs. secondary Package distinction. 2013-09-10 14:11:17 -04:00
godoc go.tools/cmd/godoc: don't list factory functions under types in builtin package 2013-08-28 09:39:02 +10:00
gotype go.tools/gotype: fix build 2013-07-19 07:52:43 -07:00
importer go.tools/importer: add unit test of LoadInitialPackages. 2013-09-10 10:39:51 -04:00
oracle go.tools/oracle: describe: query content of lvalues, not their address. 2013-09-09 21:06:25 -04:00
pointer go.tools/oracle: describe: query content of lvalues, not their address. 2013-09-09 21:06:25 -04:00
ssa go.tools/ssa/interp: implement unary negation of complex numbers. 2013-09-10 12:08:55 -04:00
.hgignore go.empty: prototype for new subrepository 2012-01-25 14:45:13 -05:00
AUTHORS go.empty: prototype for new subrepository 2012-01-25 14:45:13 -05:00
codereview.cfg go.empty: prototype for new subrepository 2012-01-25 14:45:13 -05:00
CONTRIBUTORS go.empty: prototype for new subrepository 2012-01-25 14:45:13 -05:00
LICENSE LICENSE: add 2012-03-17 15:20:58 +11:00
PATENTS go.empty: add PATENTS file to the subrepo. 2012-04-16 11:24:04 +10:00
README go.tools: provide the right README 2013-05-17 12:55:10 -07:00

This subrepository holds the source for various packages and tools that support
the Go programming language.

Although at least some of the tools themselves will be included in binary Go distributions,
the packages from which they are built are of little interest to most Go programmers.

To submit changes to this repository, see http://golang.org/doc/contribute.html.