-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/analysisinternal: TypeExpr: don't forget Variadic
The syntax generated for type func(...T) was func([]T), causing extract operations to misbehave. Fixes golang/go#63287 Change-Id: I37978a13b2b51f0802ea694b7711a7d6444384fb Reviewed-on: https://go-review.googlesource.com/c/tools/+/555458 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Alan Donovan <adonovan@google.com>
- Loading branch information
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
gopls/internal/test/marker/testdata/codeaction/extract-variadic-63287.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,28 @@ | ||
This test exercises extract on a variadic function. | ||
It is a regression test for bug #63287 in which | ||
the final paramater's "..." would go missing. | ||
|
||
-- go.mod -- | ||
module testdata | ||
go 1.18 | ||
|
||
-- a/a.go -- | ||
package a | ||
|
||
//@codeactionedit(block, "refactor.extract", out, "Extract function") | ||
|
||
func _() { | ||
var logf func(string, ...any) | ||
{ println(logf) } //@loc(block, re`{.*}`) | ||
} | ||
|
||
-- @out/a/a.go -- | ||
@@ -7 +7 @@ | ||
- { println(logf) } //@loc(block, re`{.*}`) | ||
+ { newFunction(logf) } //@loc(block, re`{.*}`) | ||
@@ -10 +10,4 @@ | ||
+func newFunction(logf func( string, ...any)) { | ||
+ println(logf) | ||
+} | ||
+ | ||
-- end -- |
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