Skip to content

go/types: guarantee sorting of named type methods #61298

@findleyr

Description

@findleyr

Certain libraries such as x/tools/go/types/objectpath rely on a well-defined sorting of methods on Named types. To enforce this definition, the objectpath package sorts, but as seen in #58668 (comment) that can be quite expensive.

We can fix that particular issue outside of go/types, but it would be nice to commit to a fixed ordering of methods in the go/types API. IIRC the ordering is currently deterministic and in source order (as defined by the input file slice), but this is not documented. We should document and preserve this behavior, or pick a different stable sort.

CC @griesemer @adonovan

Metadata

Metadata

Assignees

Labels

FrozenDueToAgeNeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.early-in-cycleA change that should be done early in the 3 month dev cycle.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions