-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gopls/internal/lsp/analysis: fix stubmethods with variadic parameters
Fix the stubmethods code action when matching against calls of variadic functions, and add a regression test. Additionally, reinstate panic recovery for code actions that were migrated from convenience analyzers. I do not have confidence that this is the only such panic. Fixes golang/go#61693 Change-Id: Id2642a13d3f793de27c0d7ebfa665428d671c56f Reviewed-on: https://go-review.googlesource.com/c/tools/+/514755 Run-TryBot: Robert Findley <rfindley@google.com> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Peter Weinberger <pjw@google.com>
- Loading branch information
Showing
3 changed files
with
85 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
gopls/internal/regtest/marker/testdata/stubmethods/issue61693.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
This test exercises stub methods functionality with variadic parameters. | ||
|
||
In golang/go#61693 stubmethods was panicking in this case. | ||
|
||
-- go.mod -- | ||
module mod.com | ||
|
||
go 1.18 | ||
-- main.go -- | ||
package main | ||
|
||
type C int | ||
|
||
func F(err ...error) {} | ||
|
||
func _() { | ||
var x error | ||
F(x, C(0)) //@suggestedfix(re"C.0.", re"missing method Error", "quickfix", stub) | ||
} | ||
-- @stub/main.go -- | ||
package main | ||
|
||
type C int | ||
|
||
// Error implements error. | ||
func (C) Error() string { | ||
panic("unimplemented") | ||
} | ||
|
||
func F(err ...error) {} | ||
|
||
func _() { | ||
var x error | ||
F(x, C(0)) //@suggestedfix(re"C.0.", re"missing method Error", "quickfix", stub) | ||
} |