From 06e31437b9cd5a001412639999b05f3a6b13dcbc Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Thu, 9 Jul 2026 15:34:55 -0400 Subject: [PATCH] Some slight tweaks to comments in/on WitnessQueryMatchesInterface (#7475) I attempted the TODO as stated but we can't remove the `.Self` from the LHS of a rewrite right now, without causing evaluation to run and potentially find a concrete value to replace the access with, which then breaks the association with the associated constant. There's a separate TODO about that in SubstPeriodSelfInFacetType. --- toolchain/check/impl.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/toolchain/check/impl.cpp b/toolchain/check/impl.cpp index 3a078cf79537..576227382879 100644 --- a/toolchain/check/impl.cpp +++ b/toolchain/check/impl.cpp @@ -390,7 +390,8 @@ auto AddImpl(Context& context, const SemIR::Impl& impl, return impl_id; } -// Returns whether the `LookupImplWitness` of `witness_id` matches `interface`. +// Returns whether the `LookupImplWitness` of `witness_id` is for the same +// specific interface as the impl decl's `impl_interface`. static auto WitnessQueryMatchesInterface( Context& context, SemIR::LocId loc_id, SemIR::InstId impl_self, SemIR::InstId access_witness_id, @@ -401,12 +402,8 @@ static auto WitnessQueryMatchesInterface( context.specific_interfaces().Get(lookup.query_specific_interface_id); // The `impl_interface` comes from an IdentifiedFacetType so it has `.Self` - // replaced. The access comes from a rewrite constraint, which do not have - // `.Self` replaced, so we need to do that here. - // - // TODO: Do this more eagerly as soon as we know the full decl before we - // construct the witness table from it? We do replace `.Self` in the facet - // type, but we don't replace the designators. + // replaced. The access comes from the LHS of a rewrite constraint, which do + // not have `.Self` replaced, so we need to do that here. access_interface = SubstPeriodSelf(context, loc_id, access_interface, context.constant_values().Get(impl_self)); return access_interface == impl_interface;