Commit Graph

6151 Commits

Author SHA1 Message Date
Bryan C. Mills 182bbdcec9 go/pointer: skip TestInput on 32-bit platforms
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>
2021-11-02 20:34:09 +00:00
Alexander Yastrebov f6440c8244 x/tools: print check misses concatenated strings
Fixes golang/go#30436

Change-Id: I5b843e65b2188040a1ea5f17e1756b57babb0c22
GitHub-Last-Rev: 3ee8e1838c9dab095af0b8afa8177132ec8fdeea
GitHub-Pull-Request: golang/tools#344
Reviewed-on: https://go-review.googlesource.com/c/tools/+/356830
Trust: Tim King <taking@google.com>
Trust: Zvonimir Pavlinovic <zpavlinovic@google.com>
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>
2021-11-02 19:48:11 +00:00
Robert Findley bb4add04dd go/analysis/passes/printf: refactor and simplify matchArgType
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>
2021-11-02 18:22:55 +00:00
Robert Findley 1ba8fdbde1 go/analysis/passes/errorsas: avoid type param on RHS of type decl
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>
2021-11-02 18:19:06 +00:00
Robert Findley 058ed05631 go/analysis/passes/copylock: find locks via type parameters
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>
2021-11-02 15:54:27 +00:00
Zvonimir Pavlinovic ebc40b3621 go/pointer: replace use of deprecated CreateTestMainPackage API
Change-Id: I464fc09d9bfa3f05f2e2f2d3c982c27a28e97e8d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/356513
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Zvonimir Pavlinovic <zpavlinovic@google.com>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-11-02 15:50:20 +00:00
Bryan C. Mills 4d06874119 internal/testenv: treat dragonfly-amd64 as a slow machine
Updates golang/go#45216

Change-Id: I9e714582c4d8c3c7ce7571359d7f9bbe2c6c9497
Reviewed-on: https://go-review.googlesource.com/c/tools/+/360735
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-11-02 15:33:01 +00:00
Tim King ee08195410 go/types/typeutil: Callee supports generics
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>
2021-11-01 19:56:50 +00:00
zhouguangyuan e8bb37349d go/types/objectpath: fix testcase for the fix of TypeName.IsAlias
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>
2021-11-01 18:01:07 +00:00
zhouguangyuan b7d65fba09 go/types/objectpath: comment some testcase temporarily for the fix of TypeName.IsAlias
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>
2021-11-01 15:20:08 +00:00
Robert Findley 42daa65d96 go/analysis/passes/stringintconv: add support for type parameters
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>
2021-11-01 13:54:03 +00:00
Jonathan Amsterdam 513e3fb6ba cmd/godoc: deprecate and point to cmd/pkgsite
Fixes golang/go#49212.

Change-Id: I335749bfecc60f582968af601d9fa030f038e2be
Reviewed-on: https://go-review.googlesource.com/c/tools/+/349051
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2021-11-01 13:50:47 +00:00
Peter Weinberger 351c04c5a1 /internal/lsp/source: apply directory filters to workspace symbols
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.

Fixes golang/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>
2021-10-30 12:32:06 +00:00
Guodong Li a6c6f4bc02 go/analysis/passes/nilfunc: add typeparams test
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>
2021-10-30 00:47:26 +00:00
Tim King a2be0cdcd9 go/analysis/passes/tests: update for generics
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>
2021-10-29 21:19:39 +00:00
Robert Findley 4d2571be91 go/analysis/passes/testinggoroutine: update for generics
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>
2021-10-29 19:36:18 +00:00
Robert Findley 96715ada81 internal/lsp: check for invalid URIs in definition
URI.Filename() panics on non-file URIs. Just pass UnknownKind to
beginFileRequest to allow handling template files.

Fixes golang/go#49223

Change-Id: Ic2add49d3d0c04855bf25583712102a50fb425ed
Reviewed-on: https://go-review.googlesource.com/c/tools/+/359734
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-10-29 19:33:54 +00:00
Robert Findley 170abddb9d go/analysis/passes/stdmethods: add tests with generic receivers
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>
2021-10-29 19:32:59 +00:00
Zvonimir Pavlinovic d6a9af8af0 godoc/analysis: remove deprecated analysis package
Change-Id: I862cae902ea2ff7ed36722d536039cc617200de6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/358954
Trust: Zvonimir Pavlinovic <zpavlinovic@google.com>
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2021-10-29 00:04:41 +00:00
Jack You e7eb6f6a64 go/analysis/passes/unusedresult: add test for typeparams
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>
2021-10-28 18:48:25 +00:00
Zvonimir Pavlinovic c8ad2e1325 go/analysis/passes/ctrlflow: add typeparams test
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>
2021-10-28 16:24:52 +00:00
KimMachineGun 8de2a7fd17 go/analysis/passes/sortslice: add missing functions using empty interface
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>
2021-10-28 02:36:02 +00:00
Robert Griesemer 9cd58b0b94 x/tools/cmd/stringer: adjust generics tests
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>
2021-10-28 00:09:41 +00:00
Robert Findley 7b0b504c04 go/analysis/passes/ifaceassert: add a typeparams test
For golang/go#48704

Change-Id: I94cc071e6e38f5b60c7b62c41cb65120bdc9720a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/358619
Trust: Robert Findley <rfindley@google.com>
Trust: Zvonimir Pavlinovic <zpavlinovic@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: Zvonimir Pavlinovic <zpavlinovic@google.com>
2021-10-27 19:33:43 +00:00
Robert Findley 58ba5e4062 go/analysis/passes/internal/analysisutil: add a test for generic type
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>
2021-10-27 19:33:38 +00:00
Robert Findley 1b02aa2bfe go/analysis/passes/shift: update for generics
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>
2021-10-27 19:33:07 +00:00
Rebecca Stambler 08f2e89cd5 gopls/api-diff: fix api-diff command for Go 1.18
Also add some better error reporting.

Change-Id: I9363ac324fc8ad89ccc77491a9e6399506ec8dcb
Reviewed-on: https://go-review.googlesource.com/c/tools/+/356930
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-10-27 16:48:55 +00:00
Robert Findley d5520c2912 internal/lsp/source: check for nil objects in call hierarchy
Fixes golang/go#49125

Change-Id: Id91415377240ab87aeaddb9d668281509d073510
Reviewed-on: https://go-review.googlesource.com/c/tools/+/358549
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>
2021-10-27 16:11:50 +00:00
Sean Liao e1e2965795 all: update install commands to go install pkg@version
Updates golang/go#43684
Updates golang/go#49101

Change-Id: I2f0c7920bcd6ce0429f1b7bdda3747bf376775f2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/357714
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Trust: Rebecca Stambler <rstambler@golang.org>
Trust: Peter Weinberger <pjw@google.com>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-10-27 02:41:01 +00:00
Zvonimir Pavlinovic 591e12a7fb go/analysis/passes/cgocall: add typeparams test
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>
2021-10-26 22:24:36 +00:00
Guodong Li 26dbf47d51 go/analysis/passes/lostcancel: add typeparams test
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>
2021-10-26 22:00:36 +00:00
Rebecca Stambler 96266072c4 all: update dependencies post-release
Change-Id: I1c48c94a133b6543a26a1803220c5c0fbbcc821e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/357035
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-10-26 18:40:06 +00:00
Pontus Leitzler 244f92ec88 internal/lsp: do not send semantic tokens that client doesn't support
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>
2021-10-26 18:33:39 +00:00
Guodong Li c4ead46007 go/analysis/passes/httpresponse: fix a testing issue
Fixes golang/go#49160

Change-Id: Ie22f45626df37b4d701feedaf0ba4516505bfbfe
Reviewed-on: https://go-review.googlesource.com/c/tools/+/358698
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-10-26 15:46:18 +00:00
Guodong Li 903c757bd1 go/analysis/passes/httpresponse: add typeparams test
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>
2021-10-26 02:02:46 +00:00
Robert Findley f916b54a17 go/analysis,go/ssa: initialize the types.Info.Instances map
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>
2021-10-25 21:11:49 +00:00
Robert Findley 1050b5ce2e go/analysis/passes/composite: update for generics
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>
2021-10-25 21:11:43 +00:00
emahiro 5a40697724 tools/gopls: use `go install` instead of `go get`
Fixes: golang/go#49114
Change-Id: I39c5bee4168862af2aa5a29a96d45cad3e0dd9f1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/358074
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Nooras Saba‎ <saba@golang.org>
Trust: Robert Findley <rfindley@google.com>
Trust: Peter Weinberger <pjw@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
2021-10-25 20:40:31 +00:00
Robert Findley bcc6fa839d internal/typeparams: guard against generics in stdlib tests
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>
2021-10-25 20:36:35 +00:00
Robert Findley fc8b4caee7 go/internal/gcimporter: stub support importing/exporting constant kind
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>
2021-10-25 14:51:39 +00:00
Robert Findley 18096c5ad9 go/internal/gcimporter: add support for the Go 1.18 export data version
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>
2021-10-25 14:51:03 +00:00
Robert Findley affba5001c internal/lsp: temporarily strip subscripts from generic hover
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>
2021-10-23 12:53:38 +00:00
Hana 316ba0b740 go/packages/packagestest: skip nested module directories in copying
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>
2021-10-22 20:09:16 +00:00
Suzy Mueller 6f2254e651 internal/lsp: adjust extract function range if block statement
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.

Fixes golang/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>
2021-10-22 02:18:41 +00:00
Dominik Honnef baf4e38fc7 go/gcexportdata: limit reader to the export data section of the archive
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.

Fixes golang/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>
2021-10-21 19:57:13 +00:00
Zvonimir Pavlinovic 4100dac8a1 go/analysis/passes/deepequalerrors: add typeparams test
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>
2021-10-21 17:03:18 +00:00
Amelia Downs 9b675d0446 gopls/doc: remove bad gopls cli link
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>
2021-10-20 20:41:51 +00:00
Robert Findley cbf1d01b28 go/internal/gcimporter: avoid setting unnecessary lines in fakeFileSet
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)

Fixes golang/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>
2021-10-20 18:48:51 +00:00
Rebecca Stambler 4ea6123e07 internal/lsp: don't add multiple views for the same folder
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>
2021-10-19 23:27:41 +00:00
Robert Findley 81f084edce go/internal/gcimporter: remove support for type parameters subscripts
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>
2021-10-19 23:13:35 +00:00