mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Cache final impl lookup results. (#6452)
If an impl lookup finds a final result, cache that and reuse it if we perform the same lookup later. In addition to reducing repeated work, this allows us to produce the same result for repeated lookups that find a C++ operator. This isn't a great solution to that problem, as it's not clear how to extend it to behave correctly across import, but we don't have a solution for that for C++ interop in general.
This commit is contained in:
@@ -101,6 +101,9 @@ static auto BuildWitness(Context& context, SemIR::LocId loc_id,
|
||||
if (struct_value.type_id == SemIR::ErrorInst::TypeId) {
|
||||
return SemIR::ErrorInst::InstId;
|
||||
}
|
||||
// TODO: If a thunk is needed, this will build a different value each
|
||||
// time it's called, so we won't properly deduplicate repeated
|
||||
// witnesses.
|
||||
witness_value_id = CheckAssociatedFunctionImplementation(
|
||||
context,
|
||||
context.types().GetAs<SemIR::FunctionType>(struct_value.type_id),
|
||||
|
||||
Reference in New Issue
Block a user