You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
go/types: Interface.Method and ExplicitMethod are not ordered by Id, contra docs #81875
The docs for types.Interface.Method say "The methods are ordered by their unique Id"; so do those for ExplicitMethod. But since https://go.dev/cl/461677 they're actually sorted with exported names before unexported ones. They differ when an interface has unexported methods from more than one package, which happens when it embeds an interface from another package:
package q
typeIinterface{ a() }
package p
import"q"typeJinterface {
q.Ib()
}
Program (type-checks both packages and prints the methods of J):
Interface.Method yields q.a before p.b, although "p.b" < "q.a". MethodSet, whose documentation also promises Id order, does sort by Id.
They can also differ for exported versus unexported names, when a package path
sorts before an exported name (e.g. path "M", methods Z and a: Id order is M.a, Z, but Interface.Method yields Z first). That's rare in practice.
I'm not sure whether it's safe the order back; we may need to just document the actual order.
Activity
gabyhelp commentedon Sep 30, 2026
Related Issues
Related Code Changes
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
dmitshur commentedon Oct 5, 2026
CC @griesemer, @mrkfrmn.
gopherbot commentedon Oct 8, 2026
Change https://go.dev/cl/847325 mentions this issue:
go/types, types2: document actual Interface.Method ordergo/types, types2: document actual Interface.Method order