Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/gopls: outgoing callhierarchy return incorrect struct field functions #43456

Closed
leitzler opened this issue Jan 1, 2021 · 1 comment
Closed
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@leitzler
Copy link
Contributor

leitzler commented Jan 1, 2021

What version of Go are you using (go version)?

$ go version
go version devel +20d0991b86 Wed Dec 30 22:51:30 2020 +0000 darwin/amd64
$ go list -m golang.org/x/tools golang.org/x/tools/gopls
golang.org/x/tools v0.0.0-20201218024724-ae774e9781d2
golang.org/x/tools/gopls v0.0.0-20201218024724-ae774e9781d2

Does this issue reproduce with the latest release?

Yes

What did you do?

Called callHierarchy/outgoingCalls from main() in:

package main

type X struct {
    A func()
    B func()
}

func main() {
    x := X{}
    x.A()
    x.B()
}

Note that the same issue applies to func's defined in an interface.

What did you expect to see?

Outgoing calls to A() and B().

What did you see instead?

Outgoing calls to A() only, but with FromRange from both A func() and B func().

@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Jan 1, 2021
@gopherbot gopherbot added this to the Unreleased milestone Jan 1, 2021
@gopherbot
Copy link

Change https://golang.org/cl/280618 mentions this issue: internal/lsp/source: return all field funcs from outgoing callhierarchy

@stamblerre stamblerre added this to Needs Triage in vscode-go: gopls by default Jan 8, 2021
@stamblerre stamblerre moved this from Needs Triage to Done in vscode-go: gopls by default Jan 8, 2021
gopherbot pushed a commit to golang/tools that referenced this issue Jan 11, 2021
Outgoing callhierarchy didn't handle different functions defined as
field in a struct as separate functions since they were declared by the
same AST node.

This change adds the identifier name to the key, so that a function
must share both declaration node and name to be considered "the same".

Fixes golang/go#43456

Change-Id: Ifbced98f2e8fc3a303834f7cefbae66829b68d27
Reviewed-on: https://go-review.googlesource.com/c/tools/+/280618
Trust: Pontus Leitzler <leitzler@gmail.com>
Run-TryBot: Pontus Leitzler <leitzler@gmail.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
@golang golang locked and limited conversation to collaborators Jan 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
No open projects
Development

No branches or pull requests

3 participants