x/tools/gopls: renaming method of an in-use interface fails #34438
Comments
Thank you for filing a gopls issue! Please take a look at the Troubleshooting guide, and make sure that you have provided all of the relevant information here. |
In general I am not sure that is actually viable. |
I don't disagree. The only reason I tried it on the interface at all was in response to a message from gopls when I tried it on the implementation (in retrospect, I probably shouldn't have expected that to work either...). The message from gopls was
Maybe that message is the actual issue, directing users to try a thing that probably isn't reasonable. |
I guess we should think what the ideal experience is. |
Is there a workaround for doing this kind of rename? assuming a simple example like the one provided: just an interface and an implementation. |
Using the example from https://play.golang.org/p/YPivBBZLhZ8 from earlier it's not possible to rename $ gopls version
golang.org/x/tools/gopls 0.4.1
golang.org/x/tools/gopls@v0.4.1-pre2 h1:X5vb657+UV0LeFGyLzTdYti9nkyllZoLaKsebuW8p1M=
$ gopls rename -w main.go:11:13 B
gopls: renaming this method "A" to "B" would make github.com/golang/go/issues/34438.impl no longer assignable to interface X (rename github.com/golang/go/issues/34438.X.A if you intend to change both types)
$ gopls rename -w main.go:6:2 B
gopls: internal error: during renaming of abstract method func (github.com/golang/go/issues/34438.X).A() int changedMethods=false, coupled method=func (github.com/golang/go/issues/34438.impl).A() int Please file a bug report One path forward would be to allow multiple renames in the same invocation, i.e. to allow $ gopls rename -w main.go:6:2 B main.go:11:13 B |
What version of Go are you using (
go version
)?What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Minimal example:
https://play.golang.org/p/sDBH3VQY5TF
Attempt to rename the
X.A()
method usinggopls
.What did you expect to see?
X.A
, andimpl.A
should be renamedWhat did you see instead?
gopls
reports an error:The text was updated successfully, but these errors were encountered: