CL 410955 changes printing of unions which breaks two typeparams tests.
Use regexp matching and adjust the wanted results accordingly.
For golang/go#53279.
For golang/go#54822.
Change-Id: I7060df47d36ce3069570237dafff024aaad637a5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/428055
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
This reverts commit 5ca4cc8b9a.
Reason for revert: appears insufficient to land CL 410955.
Change-Id: If7029c9a43568e210e89d473b738400f5155715e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/410995
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Adds a function for computing the core type of a type for use within x/tools.
Updates golang/go#52940
Change-Id: I91645c0b27031506be51a5f9d53b3e125e6fd1c2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/406838
Run-TryBot: Tim King <taking@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
And fix a minor issue in copytermlist.go --
copytermlist.go replaces type names from go/types with
qualified type names. Use of token.NoPos (filled with
ast.NewIdent) however confuses the go/format printer.
As a result, while transforming
func (x *term) includes(t Type) bool
to
func (x *term) includes(t types.Type) bool
go/format printer failed to compute the end position of
the parameter list, concluded RPAREN should be in a
different line from the parameter list, added a comma,
and printed
func (x *term) includes(t types.Type,) bool
Reuse the replaced node's position instead. (not 100%
correct, but better than NoPos)
Change-Id: Ia34e11562cc80c68dcf4b921ffffd926971c2215
Reviewed-on: https://go-review.googlesource.com/c/tools/+/405536
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Robert Findley <rfindley@google.com>
The internal/typeparams directory contains an initial draft of the
documentation later published under the golang.org/x/exp/typeparams
module. Remove this draft to avoid confusion.
Change-Id: I1f40468f99c0d2885e8fc380c75669f654ba971e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/405260
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Gofmt to update doc comments to the new formatting.
(There are so many files in x/tools I am breaking up the
gofmt'ing into multiple CLs. This is the leftovers.)
For golang/go#51082.
Change-Id: Id9d440cde9de7093d2ffe06cbaa7098993823d6b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/399363
Run-TryBot: Russ Cox <rsc@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
For some use-cases, it is helpful to compute predicates between
uninstantiated generic types.
This CL implements one such predicate for types.AssignableTo, a helper
GenericAssignableTo which reports if, for generic types V and T with the
same number of type parameters, all instantiations V[A_1, ..., A_N] are
assignable to the corresponding instantiation T[A_1, ..., A_N].
For #50887
For #50447
Change-Id: I7a0550fba05666bb2375d478d5390a123e09f556
Reviewed-on: https://go-review.googlesource.com/c/tools/+/383094
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
With instantiated types, method objects are no longer unique: they may
be instantiations of methods with generic receiver. However, some
use-cases require finding the canonical method representing the method
in the source. For these use-cases, provide an OriginMethod helper.
For golang/go#50447
Change-Id: I6f8af3fb5c5eeefb11f8f3bdba54cd6692ca389f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/380554
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Tim King <taking@google.com>
This CL begins adding a guide for the new APIs introduced with Go 1.18
to support writing tools that understand generic Go code.
For now I've added a summary of the new APIs, an initial example, and
some discussion of the typeparams package. Subsequent CLs will add more
examples, and polish.
Updates golang/go#50447
Change-Id: I4ed8d7a2f43e748374d14f3f515673d69ab2d5a0
Reviewed-on: https://go-review.googlesource.com/c/tools/+/377834
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Trust: Dominik Honnef <dominik@honnef.co>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Suzy Mueller <suzmue@golang.org>
Update and expand on the package documentation for the
internal/typeparams package.
Change-Id: I2af16250580abf9e6b3a8692356faa498ba83f29
Reviewed-on: https://go-review.googlesource.com/c/tools/+/377654
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Tim King <taking@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
The IndexExprData type of internal/typeparams was redundant now
that the typeparams.IndexListExpr type has been introduced. Remove it,
and change GetIndexExprData to an UnpackIndexExpr method, symmetric with
PackIndexExpr. With the IndexListExpr type, both UnpackIndexExpr and
PackIndexExpr can be moved to common.go.
Change-Id: I6c31f52ab594175decfbd1a4cd94b60a23a1e629
Reviewed-on: https://go-review.googlesource.com/c/tools/+/377235
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Tim King <taking@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Add support to the typeutil package for hashing the new types produced
when type-checking generic code.
Change-Id: I05a213baee80c53c673442f3c28fddb26ad0b03f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/366614
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Tim King <taking@google.com>
interfaces
Now that the underlying of type parameters is their constraint
interface, a couple places in the printf analyzer need to be updated:
- We need to explicitly exclude type parameters when looking at
interfaces in isFormatter.
- We need to consider at the element type, not its underlying, when
looking at pointers to type parameters
Change-Id: I8c6843e001a98d45ff0f30df305e3536335f567e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/364678
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
A call to Underlying() was missing from the computation of a type
parameter's structural terms, resulting in incorrect results for type
parameters with defined constraints. This wasn't caught because all
analyzer tests use inlined interfaces out of convenience, and the
fallback behavior for vet analyzers using this API is to fail silently.
Fix this, and add tests that would have failed. Also update the
normalization tests to use the StructuralTerms API, and delete the
earlier NormalizeInterface API. StructuralTerms has proven to be more
useful.
For clarity, change the StructuralTerms function to accept a *TypeParam
rather than arbitrary Type, and significantly revamp its docstring.
Updates golang/go#49597
Change-Id: I8b863604655b44b943e6afbd5d22a66f44260d10
Reviewed-on: https://go-review.googlesource.com/c/tools/+/363982
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Tim King <taking@google.com>
Warn about unkeyed composite literals via literals of type parameter
type.
Updates golang/go#48704
Change-Id: Ia75139b56cb73288c133bd547d71664464015813
Reviewed-on: https://go-review.googlesource.com/c/tools/+/357756
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Tim King <taking@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Add a new package internal/typeparams/genericfeatures, factoring out the
check for usage of generics from the usesgenerics checker. For tests
operating on the standard library, this allows us to explicitly detect
usage of generics, rather than relying on a hard-coded list.
To make this work, I switched the go/ssa standard library test to use
go/packages rather than go/loader. This resulted in finding 457 packages
versus 676 (likely due to tests), but my assumption is that this is
still enough coverage.
Change-Id: I6ba32fb4068dd7f5eedb55c2081c642665ed124a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/355972
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Tim King <taking@google.com>
Add support for accepting the Go 1.18 export data version (2) to the
x/tools gcimporter, while preserving support for generic code at version
1.
For now, the exporter still outputs version 1.
For golang/go#49040
Change-Id: Ic4547e385ced72b88212d150bf16acaf200a010e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/358034
Trust: Robert Findley <rfindley@google.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
The export data format does not yet support capturing whether interfaces
are implicit, so normalize them for the purposes of comparing type
parameter constraints.
Change-Id: I678fb5f5fe6481b9a1479176ca056a31d17bbd77
Reviewed-on: https://go-review.googlesource.com/c/tools/+/355971
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Add a go:generate script to sync the term list algorithm from go/types
into the internal/typeparams package. This allows us to experiment with
the API for type sets without committing to it in go/types.
Expose this algorithm via a new NormalizeInterface function, which
returns the normal form of an interface.
Change-Id: Idfe3b485cc29f67937f8d4a447e41d477be0b8e1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/351830
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Add a new "usesgenerics" analyzer to report uses of features related to
generic programming.
This analyzer may be used to temporarily guard other analyzers until
they may be updated to support generic features.
Along the way, update the typeparams API to return the Info.Instances
map, rather than provide indirect access, so that it can be iterated.
Fixesgolang/go#48790
Change-Id: Ia3555524beff6e19f0b9101582205e26e757c8da
Reviewed-on: https://go-review.googlesource.com/c/tools/+/355009
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Tim King <taking@google.com>
Using aliases make it easier to translate code using the new APIs.
Change-Id: I9887569a3ba1d5b1434ac6cc185485433aca7090
Reviewed-on: https://go-review.googlesource.com/c/tools/+/352898
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
IndexListExpr nodes were being skipped by go/ast/inspector, due to not
having a type value. Add this value, along with a test that we can
inspect the new constructs in generic code.
Use a type alias in the typeparams package to achieve this, following
the pattern for new go/types nodes.
Change-Id: I894a9415a93806cc6dbb92cf190b2bdab368d5df
Reviewed-on: https://go-review.googlesource.com/c/tools/+/352896
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Update the internal/typeparams API proxy following CL 352615, CL
352616, and CL 353089.
Change-Id: Ib65a1876c7820945189e1dc953e1a82e98547a09
Reviewed-on: https://go-review.googlesource.com/c/tools/+/352852
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
This CL adds a new infertypeargs analyzer, which finds call exprs where
type arguments could be inferred, and suggests a quick fix to simplify
them.
Along the way, may two changes to the supporting frameworks:
- Initialized types.Info.Instances in go/packages
- Fail analysis tests run with suggested fixes if formatting the
resulting source fails.
Change-Id: Ib15e5bd7c26aa293c5fc18a4cff6bc047e9e31d2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/351552
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This is a temporary work-around to allow the x/tools TryBots to pass on
the Go repo.
Change-Id: I122dfd0f2c034add913c859136ca6c08f916dde3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/352897
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
This reverts commit 0df0ca0f43.
Reason for revert: we've tagged x/tools@v0.1.7, and want to use the new APIs again.
Change-Id: I5c6f2075833948cc21896d1746e0c51cc0712bb1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/352855
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Temporarily hide usage of the new go/types API, so that we can safely
tag x/tools@v0.1.7 without risk of further breakage when these APIs
change.
Updates golang/go#48632
Change-Id: Idba02d09644622b3d973a684a76514c86eefa17f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/352854
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Add an analyzer that checks for empty interfaces in constraint position,
that could instead use the new predeclared "any" type.
Change-Id: I6c11f74c479c2cba64b3b12e61d70d157f94393b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/351549
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This CL updates the internal/typeparams package with the new API from CL
349629, switching Info.Inferred to Info.Instances.
Change-Id: I8f98dc39c844ef8891863c08b747f63924ab1c53
Reviewed-on: https://go-review.googlesource.com/c/tools/+/351250
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
This CL adds support for the Go 1.18 export format to iexport.go. This
support is based on cmd/compile/internal/typecheck/iexport.go, though
with a different types API and adjusted to build at Go versions below
1.18.
Specifically, this CL adds support for both column details in positions,
and generic types and functions. Along the way, some minor adjustments
are made to aid in debugging and testing.
Notably, after this CL the export data version produced by
go/gcexportdata will depend on the Go version used to build.
As part of this change, TestIExportData_stdlib is unskipped for Go 1.18.
Fixesgolang/go#48392
Change-Id: I1b218e0acd4864de5c7b89706192273bc7850ffa
Reviewed-on: https://go-review.googlesource.com/c/tools/+/351029
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This CL pulls in the latest changes from go/internal/gcimporter, while
avoiding breaking the build on older go versions. To help maintain
compatibility with older Go versions while minimizing the diff with the
standard library importer, the internal/typeparams package was
significantly expanded.
I decided to use type aliases in the internal/typeparams package on Go
version >= go1.18, and placeholder types on Go version < go1.18. This
reduces the amount of copying needed in the APIs, though it might not be
the best decision if we ever decide to export this package.
Documentation was also updated to be more concise and specific to the Go
version being used.
In order to actually fix the x/tools Trybot for packages using generics
in the standard library, we need to switch from the 'typeparams' build
constraint to the 'go1.18' build constraint. This means if we make any
additional API changes in go/types we'll have to submit them with a
broken x/tools Trybot and then immediately fix the x/tools build.
Change-Id: Ifa0b1c37b89dc549ee295fa3a959f03deda86e56
Reviewed-on: https://go-review.googlesource.com/c/tools/+/349949
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
This type was renamed in CL 348609, based on discussion in the
go/ast proposal.
Change-Id: I3addcf1bb192ad03f59f599a7aec68a579178fd5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/348629
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
As discussed on both proposals to CL 348375 (#47781) and
CL 348376 (#47916), Go core changed the 'T' word to 'Type'.
Follows those changes as well.
Change-Id: I52c354cdc7494aaf3c63bfb136efa86159175314
Reviewed-on: https://go-review.googlesource.com/c/tools/+/348509
Reviewed-by: Robert Findley <rfindley@google.com>
Trust: Robert Findley <rfindley@google.com>
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
This fixes the build when run with -tags=typeparams.
Change-Id: I94861e7f46e396804740a8e3c24f164380903a69
Reviewed-on: https://go-review.googlesource.com/c/tools/+/343129
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Current tip Go runtime (7eaabae84d) haven't (actually removed)
implements *types.Named.TArgs() method.
Calculate and make targs using named.NumTArgs().
Change-Id: Ib6a61cf2f8da644f533891f9bbb30179f8a7df5c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/342229
Reviewed-by: Robert Findley <rfindley@google.com>
Trust: Robert Findley <rfindley@google.com>
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Recent changes to the go/ast APIs for type parameters have broken the
internal/typeparams package when built with -tags=typeparams.
Fix this by adjusting the internal/typeparams API. Also update a few
tests accordingly.
Bump the build constraint used by the internal/typeparams package to
go1.18, as we are no longer compatible with the 1.17 typeparams API. It
is no long possible to opt in to type parameter specific functionality
1.17, which is fine as the dev.typeparams branch has moved to 1.18.
Even after these fixes, not all x/tools tests pass with go1.18. Some
completion tests are failing due to finding 'any' in types.Universe.
Change-Id: I5f92870aaf7853e531e3a154987f98520a52d70c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/339349
Trust: Robert Findley <rfindley@google.com>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Use the typeparams helper package to fix AST rewriting in go/ast/astutil
when encountering the new ListExpr type.
This is liable to break in the future when the go/ast API changes, but
at least it will be easy to find by virtue of using internal/typeparams.
Fixesgolang/vscode-go#1551
Change-Id: Id34bbcdede9024ed9818bef6d73a19e993dd76a8
Reviewed-on: https://go-review.googlesource.com/c/tools/+/326131
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Tools like gopls will want to add additional features to support working
with generic code, but need to continue to compile at older Go versions
that don't support type parameters.
This CL contains an initial draft of a helper library that may be used
to interrogate generic type information from go/ast and go/types without
having to guard the calling code with a build constraint.
I will use this library to implement some generics features for gopls.
Once we're confident in the API, it could potentially be exported as
x/tools/go/typeparams.
Change-Id: I0ad3050b57cf8d8e8dda7d350d18f5e50f4105ff
Reviewed-on: https://go-review.googlesource.com/c/tools/+/317451
Trust: Robert Findley <rfindley@google.com>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>