023911ca70
The code to check if a candidate object matches our candidate inference had become complicated, messy, and in some cases incorrect. The main source of the complexity is the "derived" expected and candidate types. When considering a candidate object "foo", we also consider "&foo", "foo()", and "*foo", as appropriate. On the expected side of things, when completing the a variadic function parameter we expect either the variadic slice type and the scalar element type. The code had grown organically to handle the expanding concerns, but that resulted in confused code that didn't handle the interplay between the various facets of candidate inference. For example, we were inappropriately invoking func candidates when completing variadic args: func foo(...func()) func bar() {} foo(bar<>) // oops - expanded to "bar()" and we weren't type matching functions properly as builtin args: func myMap() map[string]int { ... } delete(myM<>) // we weren't preferring (or invoking) "myMap()" We also had methods like "typeMatches" which took both a "candidate" object and a "candType" type, which doesn't make sense because the candidate contains the type already. Now instead we explicitly iterate over all the derived candidate and expected types so they are treated the same. There are still some warts left but I think this is a step in the right direction. Change-Id: If84a84b34a8fb771a32231f7ab64ca192f611b3d Reviewed-on: https://go-review.googlesource.com/c/tools/+/218877 Run-TryBot: Muir Manders <muir@mnd.rs> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com> |
||
---|---|---|
benchmark/parse | ||
blog | ||
cmd | ||
container/intsets | ||
cover | ||
go | ||
godoc | ||
gopls | ||
imports | ||
internal | ||
playground | ||
present | ||
refactor | ||
txtar | ||
.gitattributes | ||
.gitignore | ||
AUTHORS | ||
codereview.cfg | ||
CONTRIBUTING.md | ||
CONTRIBUTORS | ||
go.mod | ||
go.sum | ||
LICENSE | ||
PATENTS | ||
README.md |
Go Tools
This subrepository holds the source for various packages and tools that support the Go programming language.
Some of the tools, godoc
and vet
for example, are included in binary Go
distributions.
Others, including the Go guru
and the test coverage tool, can be fetched with
go get
.
Packages include a type-checker for Go and an implementation of the Static Single Assignment form (SSA) representation for Go programs.
Download/Install
The easiest way to install is to run go get -u golang.org/x/tools/...
. You can
also manually git clone the repository to $GOPATH/src/golang.org/x/tools
.
Report Issues / Send Patches
This repository uses Gerrit for code changes. To learn how to submit changes to this repository, see https://golang.org/doc/contribute.html.
The main issue tracker for the tools repository is located at https://github.com/golang/go/issues. Prefix your issue with "x/tools/(your subdir):" in the subject line, so it is easy to find.