-
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.
gopls/internal/golang: don't lose ... when split/joining variadics
We wrap the last argument f(x...) in an explicit Ellipsis to record that it was a variadic call, and add the "..." back with corresponding logic when creating the edits. Fixes golang/go#70519 Change-Id: I1fdfa5f3ccb000c9622f856ed7703b31d7911620 Reviewed-on: https://go-review.googlesource.com/c/tools/+/631335 Auto-Submit: Alan Donovan <adonovan@google.com> Reviewed-by: Robert Findley <rfindley@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
- Loading branch information
Showing
3 changed files
with
78 additions
and
1 deletion.
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
55 changes: 55 additions & 0 deletions
55
gopls/internal/test/marker/testdata/codeaction/splitlines-variadic.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,55 @@ | ||
This is a regression test for #70519, in which the ellipsis | ||
of a variadic call would go missing after split/join lines. | ||
|
||
-- go.mod -- | ||
module example.com | ||
go 1.18 | ||
|
||
-- a/a.go -- | ||
package a | ||
|
||
var a, b, c []any | ||
func f(any, any, ...any) | ||
|
||
func _() { | ||
f(a, b, c...) //@codeaction("a", "refactor.rewrite.splitLines", result=split) | ||
|
||
f( | ||
a, | ||
b, | ||
c..., /*@codeaction("c", "refactor.rewrite.joinLines", result=joined)*/ | ||
) | ||
} | ||
|
||
-- @split/a/a.go -- | ||
package a | ||
|
||
var a, b, c []any | ||
func f(any, any, ...any) | ||
|
||
func _() { | ||
f( | ||
a, | ||
b, | ||
c..., | ||
) //@codeaction("a", "refactor.rewrite.splitLines", result=split) | ||
|
||
f( | ||
a, | ||
b, | ||
c..., /*@codeaction("c", "refactor.rewrite.joinLines", result=joined)*/ | ||
) | ||
} | ||
|
||
-- @joined/a/a.go -- | ||
package a | ||
|
||
var a, b, c []any | ||
func f(any, any, ...any) | ||
|
||
func _() { | ||
f(a, b, c...) //@codeaction("a", "refactor.rewrite.splitLines", result=split) | ||
|
||
f(a, b, c..., /*@codeaction("c", "refactor.rewrite.joinLines", result=joined)*/) | ||
} | ||
|