Files
carbon-lang/toolchain/check/testdata/generic/template
Dana JansensandRichard Smith 6041e9aa9d Use a "type structure" of each impl to choose the best match (#5124)
The type structure is built for the impl lookup query for the
combination of the self type and the interface being queried. Then it is
built for each `impl` definition that is a potential candidate.

The type structures are compared to ensure they have a compatible
structure, and the `impl` declaration is not considered if they do not.

Finally, the type structures are used as a sorting key for the candidate
`impl` declarations, with the most-specified type structures (the ones
with the furthest distance to the first symbolic value) coming first in
the ordering.

See
https://docs.carbon-lang.dev/docs/design/generics/overview.html#parameterized-impl-declarations
for the design of the type structure and related ordering.

Most of the commits in this PR landed in #5158 (11ae0e27ab) by
mistake, but this includes the final changes since that PR was written.

---------

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
2025-03-21 15:27:45 +00:00
..