-
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: change signature via renaming 'func'
More for testing and debugging than anything else, allow changing signatures by invoking a renaming on the 'func' keyword. For now, this is still restricted to parameter permutation or removal. For golang/go#38028 Change-Id: I62e387cc7d7f46fc892b7b20050d99fac6800e3f Reviewed-on: https://go-review.googlesource.com/c/tools/+/631296 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alan Donovan <adonovan@google.com>
- Loading branch information
Showing
8 changed files
with
319 additions
and
21 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
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
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 test checks basic functionality for renaming (=changing) a function | ||
signature. | ||
|
||
-- go.mod -- | ||
module example.com | ||
|
||
go 1.20 | ||
|
||
-- a/a.go -- | ||
package a | ||
|
||
//@rename(Foo, "func(i int, s string)", unchanged) | ||
//@rename(Foo, "func(s string, i int)", reverse) | ||
//@rename(Foo, "func(s string)", dropi) | ||
//@rename(Foo, "func(i int)", drops) | ||
//@rename(Foo, "func()", dropboth) | ||
//@renameerr(Foo, "func(i int, s string, t bool)", "not yet supported") | ||
//@renameerr(Foo, "func(i string)", "not yet supported") | ||
//@renameerr(Foo, "func(i int, s string) int", "not yet supported") | ||
|
||
func Foo(i int, s string) { //@loc(Foo, "func") | ||
} | ||
|
||
func _() { | ||
Foo(0, "hi") | ||
} | ||
-- @dropboth/a/a.go -- | ||
@@ -12 +12 @@ | ||
-func Foo(i int, s string) { //@loc(Foo, "func") | ||
+func Foo() { //@loc(Foo, "func") | ||
@@ -16 +16 @@ | ||
- Foo(0, "hi") | ||
+ Foo() | ||
-- @dropi/a/a.go -- | ||
@@ -12 +12 @@ | ||
-func Foo(i int, s string) { //@loc(Foo, "func") | ||
+func Foo(s string) { //@loc(Foo, "func") | ||
@@ -16 +16 @@ | ||
- Foo(0, "hi") | ||
+ Foo("hi") | ||
-- @drops/a/a.go -- | ||
@@ -12 +12 @@ | ||
-func Foo(i int, s string) { //@loc(Foo, "func") | ||
+func Foo(i int) { //@loc(Foo, "func") | ||
@@ -16 +16 @@ | ||
- Foo(0, "hi") | ||
+ Foo(0) | ||
-- @reverse/a/a.go -- | ||
@@ -12 +12 @@ | ||
-func Foo(i int, s string) { //@loc(Foo, "func") | ||
+func Foo(s string, i int) { //@loc(Foo, "func") | ||
@@ -16 +16 @@ | ||
- Foo(0, "hi") | ||
+ Foo("hi", 0) | ||
-- @unchanged/a/a.go -- |
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
Oops, something went wrong.