]> Cypherpunks repositories - gostls13.git/commit
all: clean up code with token.IsExported
authorDaniel Martí <mvdan@mvdan.cc>
Mon, 15 Apr 2019 14:10:50 +0000 (23:10 +0900)
committerBrad Fitzpatrick <bradfitz@golang.org>
Tue, 16 Apr 2019 14:43:48 +0000 (14:43 +0000)
commit9b968df17782f21cc0af14c9d3c0bcf4cf3f911f
tree0240ff2603a12a7f9206b27967b8a60b992110cb
parentb39d0eab902cb6b90aa99bcf11ca622c00219c7c
all: clean up code with token.IsExported

A handful of packages were reimplementing IsExported, so use
token.IsExported instead. This caused the deps test to fail for net/rpc.
However, net/rpc deals with Go types, and go/token is light and fairly
low-level in terms of Go tooling packages, so that's okay.

While at it, replace all uses of ast.IsExported with token.IsExported.
This is more consistent, and also means that the import graphs are
leaner. A couple of files no longer need to import go/ast, for example.

We can't get rid of cmd/compile/internal/types.IsExported, as the
compiler can only depend on go/token as of Go 1.4. However, gc used
different implementations in a couple of places, so consolidate the use
of types.IsExported there.

Finally, we can't get rid of the copied IsExported implementation in
encoding/gob, as go/token depends on it as part of a test. That test
can't be an external test either, so there's no easy way to break the
import cycle.

Overall, this removes about forty lines of unnecessary code.

Change-Id: I86a475b7614261e6a7b0b153d5ca02b9f64a7b2d
Reviewed-on: https://go-review.googlesource.com/c/go/+/172037
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
12 files changed:
src/cmd/api/goapi.go
src/cmd/compile/internal/gc/dump.go
src/cmd/compile/internal/gc/iexport.go
src/cmd/doc/main.go
src/go/build/deps_test.go
src/go/doc/exports.go
src/go/doc/reader.go
src/go/internal/gcimporter/bimport.go
src/go/types/object.go
src/net/http/response_test.go
src/net/rpc/server.go
src/reflect/all_test.go