gopls: fix build at older Go versions
Fix the pre-1.18 build knowingly broken by CL 481695.
Change-Id: If47309d22a3b5c61b395955a8edc18f83db998dc
Reviewed-on: https://go-review.googlesource.com/c/tools/+/490835
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
diff --git a/gopls/internal/lsp/source/invertifcondition.go b/gopls/internal/lsp/source/invertifcondition.go
index 20c0676..2b11485 100644
--- a/gopls/internal/lsp/source/invertifcondition.go
+++ b/gopls/internal/lsp/source/invertifcondition.go
@@ -14,6 +14,7 @@
"golang.org/x/tools/go/analysis"
"golang.org/x/tools/go/ast/astutil"
"golang.org/x/tools/gopls/internal/lsp/safetoken"
+ "golang.org/x/tools/internal/typeparams"
)
// invertIfCondition is a singleFileFixFunc that inverts an if/else statement
@@ -130,7 +131,7 @@
oldText := string(src[condStart.Offset:condEnd.Offset])
switch expr := cond.(type) {
- case *ast.Ident, *ast.ParenExpr, *ast.CallExpr, *ast.StarExpr, *ast.IndexExpr, *ast.IndexListExpr, *ast.SelectorExpr:
+ case *ast.Ident, *ast.ParenExpr, *ast.CallExpr, *ast.StarExpr, *ast.IndexExpr, *typeparams.IndexListExpr, *ast.SelectorExpr:
newText := "!" + oldText
if oldText == "true" {
newText = "false"
diff --git a/gopls/internal/lsp/testdata/summary.txt.golden b/gopls/internal/lsp/testdata/summary.txt.golden
index c4d5174..d61d355 100644
--- a/gopls/internal/lsp/testdata/summary.txt.golden
+++ b/gopls/internal/lsp/testdata/summary.txt.golden
@@ -12,7 +12,7 @@
FoldingRangesCount = 2
ImportCount = 8
SemanticTokenCount = 3
-SuggestedFixCount = 65
+SuggestedFixCount = 76
FunctionExtractionCount = 27
MethodExtractionCount = 6
DefinitionsCount = 46