internal/lsp: fix panic in builtin completions

Fixes golang/go#38091

Change-Id: I88ac6d3413de3dd9d235e2f2fca9b4a3f7127e0a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/227026
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Rohan Challa <rohan@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Rebecca Stambler 2020-04-02 13:31:57 -04:00
parent 0a46fa39b0
commit 9fc00b0a7f
4 changed files with 10 additions and 1 deletions

View File

@ -59,6 +59,9 @@ func (c *completer) builtinArgType(obj types.Object, call *ast.CallExpr, parentI
switch obj.Name() {
case "append":
if parentInf.objType == nil {
break
}
inf.objType = parentInf.objType
// Check if we are completing the variadic append() param.

View File

@ -17,3 +17,4 @@ func _() {
// Don't add "..." to append() argument.
bar(append()) //@snippet("))", appendStrings, "aStrings", "aStrings")
}
}

View File

@ -0,0 +1,5 @@
package append
func _() {
_ = append(a, struct) //@complete(")")
}

View File

@ -1,6 +1,6 @@
-- summary --
CodeLensCount = 2
CompletionsCount = 237
CompletionsCount = 238
CompletionSnippetCount = 75
UnimportedCompletionsCount = 11
DeepCompletionsCount = 5