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

Comments

@leitzler
Copy link
Contributor

@leitzler 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 this to the Unreleased milestone Jan 1, 2021
@gopherbot
Copy link

@gopherbot gopherbot commented Jan 1, 2021

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants