Skip to content

Commit c6b5780

Browse files
committed
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 <[email protected]> TryBot-Result: Gopher Robot <[email protected]> gopls-CI: kokoro <[email protected]> Reviewed-by: Alan Donovan <[email protected]>
1 parent 7590fe4 commit c6b5780

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

gopls/internal/lsp/source/invertifcondition.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"golang.org/x/tools/go/analysis"
1515
"golang.org/x/tools/go/ast/astutil"
1616
"golang.org/x/tools/gopls/internal/lsp/safetoken"
17+
"golang.org/x/tools/internal/typeparams"
1718
)
1819

1920
// invertIfCondition is a singleFileFixFunc that inverts an if/else statement
@@ -130,7 +131,7 @@ func invertCondition(fset *token.FileSet, cond ast.Expr, src []byte) ([]byte, er
130131
oldText := string(src[condStart.Offset:condEnd.Offset])
131132

132133
switch expr := cond.(type) {
133-
case *ast.Ident, *ast.ParenExpr, *ast.CallExpr, *ast.StarExpr, *ast.IndexExpr, *ast.IndexListExpr, *ast.SelectorExpr:
134+
case *ast.Ident, *ast.ParenExpr, *ast.CallExpr, *ast.StarExpr, *ast.IndexExpr, *typeparams.IndexListExpr, *ast.SelectorExpr:
134135
newText := "!" + oldText
135136
if oldText == "true" {
136137
newText = "false"

gopls/internal/lsp/testdata/summary.txt.golden

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ DiagnosticsCount = 39
1212
FoldingRangesCount = 2
1313
ImportCount = 8
1414
SemanticTokenCount = 3
15-
SuggestedFixCount = 65
15+
SuggestedFixCount = 76
1616
FunctionExtractionCount = 27
1717
MethodExtractionCount = 6
1818
DefinitionsCount = 46

0 commit comments

Comments
 (0)