Skip to content

Commit

Permalink
cmd/deadcode: audit for types.Alias safety
Browse files Browse the repository at this point in the history
Updates golang/go#65294

Change-Id: Ica0197fd5d931244079fdf5b8c29f1bfeed5083b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/559936
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
  • Loading branch information
adonovan committed Feb 6, 2024
1 parent 37586e4 commit 08393e0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cmd/deadcode/deadcode.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"golang.org/x/tools/go/packages"
"golang.org/x/tools/go/ssa"
"golang.org/x/tools/go/ssa/ssautil"
"golang.org/x/tools/internal/aliases"
)

//go:embed doc.go
Expand Down Expand Up @@ -385,10 +386,10 @@ func prettyName(fn *ssa.Function, qualified bool) string {
// method receiver?
if recv := fn.Signature.Recv(); recv != nil {
t := recv.Type()
if ptr, ok := t.(*types.Pointer); ok {
if ptr, ok := aliases.Unalias(t).(*types.Pointer); ok {
t = ptr.Elem()
}
buf.WriteString(t.(*types.Named).Obj().Name())
buf.WriteString(aliases.Unalias(t).(*types.Named).Obj().Name())
buf.WriteByte('.')
}

Expand Down

0 comments on commit 08393e0

Please sign in to comment.