This test was already memory-hungry to begin with, and apparently the
switch to go/packages in CL 356513 pushed it over the edge of the
32-bit address space (at least with the default GOGC setting). Rather
than trying to precisely tune it to skim under the 32-bit limit,
let's just skip the test on platforms with insufficient address space.
Updates golang/go#14113
Updates golang/go#48547
Change-Id: Iab99e9ce70a98034194d7c7ad7df7a545ac95ef3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/360837
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Do a pass a cleaning up the matchArgType and matchArgTypeInternal
functions:
- Remove the 'typ' argument from matchArgType, since external callers
must pass nil. It must have predated matchArgTypeInternal.
- Remove the `if false` blocks that were placeholders for the *verbose
flag. It has been three years, so seems safe to delete this dead
code. This also means we don't do any reporting via matchArgType,
which is cleaner.
- Extract the types.Info lookup of the arg type into matchArgType; it
doesn't make sense in recursive calls to matchArgType.
- Compare against types.Typ[types.Invalid] directly, rather than
comparing against the type string "invalid type".
- Remove an unused pass argument from isConvertibleToString.
- Remove the now unused 'pass' and 'arg' arguments from
matchArgTypeInternal.
Change-Id: I52232a881090e40943e4c4c377ae8436512232b1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/360154
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: Michael Matloob <matloob@golang.org>
With CL 360758, this will be a type-checker error.
Change-Id: Ic37c4bc671b707751fe22100bb525c91b5d5a5f2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/360834
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>
Add support for finding incorrect usage of locks via type parameters. It
would probably be fine not to do this, since using locks explicitly via
type parameters should be exceedingly rare. However, it was
straightforward to add, and is consistent with other analyzers.
Updates golang/go#48704
Change-Id: I329a2fa9f11c6bbb491d49afde7fabce8299cbdf
Reviewed-on: https://go-review.googlesource.com/c/tools/+/360234
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>
Adds support for finding the Callee if it is a generic function.
Generic methods happen to already work without this change.
Updating this so that they are consistent.
For golang/go#48704
Change-Id: I649ec746e350db4a0086ed31535b2e14baa32314
Reviewed-on: https://go-review.googlesource.com/c/tools/+/359974
Run-TryBot: Tim King <taking@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Trust: Zvonimir Pavlinovic <zpavlinovic@google.com>
For CL 359656
For golang/go#49213
Change-Id: Ib2c5d8fa60702baf07530226322a0a113af6b9e8
Reviewed-on: https://go-review.googlesource.com/c/tools/+/360335
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
For CL 359656
For golang/go#49213
Change-Id: I3ae7abe8acc0d8816e2029aa55e8bbaee1e05c94
Reviewed-on: https://go-review.googlesource.com/c/tools/+/360334
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Check for potentially invalid string int conversions via type
parameters.
Updates golang/go#48704
Change-Id: I0269857f3245909cf60c78c6dd624c1c0090c22d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/359294
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>
Apply Options.DirectoryFilters when searching for workspace symbols.
The natural way to implement it would lead to an import loop, so
the working code was moved from cache to source.
Fixesgolang/go#48939
Change-Id: Iccf32bc8327ba7845505a6a3de621db8946063f5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/359514
Run-TryBot: Peter Weinberger <pjw@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Peter Weinberger <pjw@google.com>
Reviewed-by: Suzy Mueller <suzmue@golang.org>
testdata/src/typeparams is similar to testdata/src/a but
uses type parameters.
For golang/go#48704
Change-Id: I2d49190b606d6cdcfe79af5f29bba1117b07b94a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/359894
Run-TryBot: Guodong Li <guodongli@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Guodong Li <guodongli@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Warn about Test functions that contain type parameters.
For golang/go#48704
Change-Id: I3f6852613482ec6f33e5650a014564915f11b920
Reviewed-on: https://go-review.googlesource.com/c/tools/+/359494
Run-TryBot: Tim King <taking@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Tim King <taking@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Update the testinggoroutine analyzer to find bad calls via instantiated
function calls.
For golang/go#48704
Change-Id: I39ef43090a0e5dd04dfe094376517ac25441ad27
Reviewed-on: https://go-review.googlesource.com/c/tools/+/359401
Trust: Robert Findley <rfindley@google.com>
Trust: Zvonimir Pavlinovic <zpavlinovic@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
Ensure that the logic for detecting incorrect signatures of standard
methods applies to methods on generic types.
For golang/go#48704
Change-Id: I1862238ad1ff013137b12674fbc0068a7e8a3c60
Reviewed-on: https://go-review.googlesource.com/c/tools/+/359409
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>
This CL adds a test for unused results inside a function using generics.
Update golang/go#48704
Change-Id: I3703cd6bbc40142b4a667d3cd069ea0721a045ec
GitHub-Last-Rev: 1c6db19cf61e9ac444305e9155c19ff0db8927f4
GitHub-Pull-Request: golang/tools#345
Reviewed-on: https://go-review.googlesource.com/c/tools/+/357411
Reviewed-by: Tim King <taking@google.com>
Run-TryBot: Tim King <taking@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Robert Findley <rfindley@google.com>
This CL adds a test for the assign pass that involves use of generics.
Updates golang/go#48704
Change-Id: I19d27932f0d326e2456b6714f76de01d46f1b1e3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/357777
Trust: Zvonimir Pavlinovic <zpavlinovic@google.com>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Add missing functions using empty interface in `sort` package.
Change-Id: Ic39bc55897705b08d3739a993b30d4b4e9a77baf
GitHub-Last-Rev: 1cfb9149456ebe6489299564e53666cdafcf49de
GitHub-Pull-Request: golang/tools#318
Reviewed-on: https://go-review.googlesource.com/c/tools/+/319689
Reviewed-by: Tim King <taking@google.com>
Trust: Tim King <taking@google.com>
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Tim King <taking@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Per the issue below, a lone type parameter is not permitted
on the the RHS of a type declaration, at least for Go 1.18.
Slightly modified the generics tests so that they pass for
now.
For golang/go#45639.
Change-Id: I3c5dc0ff65bfdc268c372e5e3fdfe00a8547f17e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/359274
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Peter Weinberger <pjw@google.com>
assertions
Change-Id: I5e47a3070c2c91f18134980a3bcd32964f1df1a3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/358616
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 shifts that exceed the width of a type in the type parameter
type set.
For golang/go#48704
Change-Id: If16650b0c7214415f650884014eda9690d8da11a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/357758
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>
This CL adds a test for the cgocall pass that involves use of generics.
Updates golang/go#48704
Change-Id: I521708d607c5f32ca24fe370b7d6436147bae6a5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/358695
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Trust: Zvonimir Pavlinovic <zpavlinovic@google.com>
testdata/src/typeparams is similar to testdata/src/a but
uses type parameters.
For golang/go#48704
Change-Id: Id6911e0e18b31a0de917835e4bf83c50adea1599
Reviewed-on: https://go-review.googlesource.com/c/tools/+/358694
Reviewed-by: Robert Findley <rfindley@google.com>
Trust: Guodong Li <guodongli@google.com>
LSP clients tells gopls which token types it supports using
SemanticTokensClientCapabilites, and when gopls ran into an unsupported
token type it still did send that token with the first supported type
(i.e. encoded token type 0).
This change makes gopls omit tokens where the token type isn't one of
the client supported ones.
Change-Id: Ic3b6eeb56d67e773e75365660d301f5332f3ab44
Reviewed-on: https://go-review.googlesource.com/c/tools/+/358874
Trust: Pontus Leitzler <leitzler@gmail.com>
Run-TryBot: Pontus Leitzler <leitzler@gmail.com>
Reviewed-by: Peter Weinberger <pjw@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
testdata/src/typeparams is similar to testdata/src/a but
uses type parameters.
For golang/go#48704
Change-Id: I91b101bda6e1da5b2de6830896a4b13508f31322
Reviewed-on: https://go-review.googlesource.com/c/tools/+/358696
Trust: Guodong Li <guodongli@google.com>
Run-TryBot: Guodong Li <guodongli@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Update a couple places where we should initialize the
types.Info.Instances map:
- The unitchecker may be used with analyzers that expect the Instances
map to be populated.
- go/ssa will eventually support instances.
Change-Id: Id3dafe57430e5710ee91215a9586b09a87470b15
Reviewed-on: https://go-review.googlesource.com/c/tools/+/357757
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 placeholder support for importing/exporting constant kind in the Go
1.18 export data format.
Also eliminate the redundant iimport.iexportVersion field.
For golang/go#45837
Change-Id: I94dbcadde0fae55788ce1a139a2760276f644630
Reviewed-on: https://go-review.googlesource.com/c/tools/+/358035
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 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>
To enable removing subscripts from go/types without breaking x/tools
tests, temporarily normalize test hover strings to strip subscripts.
Change-Id: I373122150e9ca889e2dcbc77875fe1b0dbbe3e15
Reviewed-on: https://go-review.googlesource.com/c/tools/+/358014
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>
MustCopyFileTree is used to construct a module representation based on
a real directory tree and its output consumers (e.g. Export) assume the
output contains only files that belong to the module. If the real
directory contains nested module directories, they need to be trimmed
to satisfy the assumption.
This CL implements this trimming logic - a directory containing go.mod
is excluded from copying if the directory is not the top-level directory.
Change-Id: Ib09d4d74e120b502e338a021042d4d5e00719f23
Reviewed-on: https://go-review.googlesource.com/c/tools/+/358037
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
If the selected region is a block statement, gopls
does not return a valid function extraction. This
change adjusts the range to be the statements inside
of the selected block statement.
Fixesgolang/go#48963
Change-Id: I9b1fb5005f961f30c1fa0333cd1f2050ed5eedef
Reviewed-on: https://go-review.googlesource.com/c/tools/+/357615
Trust: Suzy Mueller <suzmue@golang.org>
Run-TryBot: Suzy Mueller <suzmue@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
When given an archive, NewReader can figure out the size of the export
data and there is no need to read the entire file, which includes
object code for the package in addition to export data.
We could make the same change in gcimporter.Import but choose not to,
as the function has no users.
Fixesgolang/go#48954
Change-Id: I11e8e448c3133465f0e6ab01b3532da3732387af
Reviewed-on: https://go-review.googlesource.com/c/tools/+/357209
Trust: Dominik Honnef <dominik@honnef.co>
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 adds a test for the assign pass that involves use of generics.
Update golang/go#48704
Change-Id: I1aa51aed24d63d42b6b0150d64925b97dfd59a92
Reviewed-on: https://go-review.googlesource.com/c/tools/+/357412
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Trust: Cherry Mui <cherryyz@google.com>
This link for "more information" just points to the same doc.
Change-Id: Ib9fee88d5dc9225a91547bd9e7c677e8989ca1a8
Reviewed-on: https://go-review.googlesource.com/c/tools/+/357369
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Trust: Rebecca Stambler <rstambler@golang.org>
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
As discussed in golang/go#46586, the gcimporter spends large portion of
time just validating fake lines.
Fix this by only setting the lines we need. Benchcmd results for
TestImportStdLib:
name old time/op new time/op delta
TestImportStdLib 1.11s ±40% 0.57s ±58% -48.17% (p=0.000 n=18+18)
name old user-time/op new user-time/op delta
TestImportStdLib 1.24s ±46% 0.71s ±61% -42.84% (p=0.000 n=18+18)
name old sys-time/op new sys-time/op delta
TestImportStdLib 249ms ±64% 139ms ±47% -44.19% (p=0.000 n=19+18)
name old peak-RSS-bytes new peak-RSS-bytes delta
TestImportStdLib 80.1MB ±24% 86.6MB ±13% +8.06% (p=0.001 n=20+20)
Fixesgolang/go#46586
Change-Id: I5ef99ea9f242fc80d2d17750a8d9b28f7fc71245
Reviewed-on: https://go-review.googlesource.com/c/tools/+/357291
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>
When we add a view, we should check if we already have a view for the
given folder.
Updates golang/go#48844
Change-Id: I0de27d420e2b4df3b33b913ae27b108bab6b7d12
Reviewed-on: https://go-review.googlesource.com/c/tools/+/356933
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Now that the compiler no longer includes subscripts in its export data,
we can remove support for parsing them in the gcimporter.
Make this change, as well as add support for exporting the new names to
iexport.go (tests fail if these changes are made in separate CLs). This
proved a bit tricky to debug, so along the way add some hooks for easier
tracing of import/export.
Fix a bug in iimport.go where rparams were being shadowed, and fix the
export tests to actually compare methods.
Change-Id: Ie08aa5e5ee971d357d352b8f4a4673f6d2a38779
Reviewed-on: https://go-review.googlesource.com/c/tools/+/356534
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>