mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: sort method sets using package height
Also, when statically building itabs, compare *types.Sym instead of name alone so that method sets with duplicate non-exported methods are handled correctly. Fixes #24693. Change-Id: I2db8a3d6e80991a71fef5586a15134b6de116269 Reviewed-on: https://go-review.googlesource.com/105039 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
parent
07029254a0
commit
49ed4cbe85
7 changed files with 90 additions and 3 deletions
|
|
@ -1390,6 +1390,8 @@ func genfun(t, it *types.Type) []*obj.LSym {
|
|||
sigs := imethods(it)
|
||||
methods := methods(t)
|
||||
out := make([]*obj.LSym, 0, len(sigs))
|
||||
// TODO(mdempsky): Short circuit before calling methods(t)?
|
||||
// See discussion on CL 105039.
|
||||
if len(sigs) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
|
@ -1397,7 +1399,7 @@ func genfun(t, it *types.Type) []*obj.LSym {
|
|||
// both sigs and methods are sorted by name,
|
||||
// so we can find the intersect in a single pass
|
||||
for _, m := range methods {
|
||||
if m.name.Name == sigs[0].name.Name {
|
||||
if m.name == sigs[0].name {
|
||||
out = append(out, m.isym.Linksym())
|
||||
sigs = sigs[1:]
|
||||
if len(sigs) == 0 {
|
||||
|
|
@ -1406,6 +1408,10 @@ func genfun(t, it *types.Type) []*obj.LSym {
|
|||
}
|
||||
}
|
||||
|
||||
if len(sigs) != 0 {
|
||||
Fatalf("incomplete itab")
|
||||
}
|
||||
|
||||
return out
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue