Refactor LookupCopyImpl and LookupDestroyImpl to share logic. (#6649)

Assisted-by: Google Antigravity with Gemini 3 Flash
This commit is contained in:
Jon Ross-Perkins
2026-01-23 23:07:15 +00:00
committed by GitHub
parent a1efc4be8f
commit f5a1579d4d
4 changed files with 70 additions and 96 deletions
+4 -6
View File
@@ -262,12 +262,10 @@ auto LookupCppOperator(Context& context, SemIR::LocId loc_id, Operator op,
// If this is an operator method, the first arg will be used as self.
arg_ids.size() -
(isa<clang::CXXMethodDecl>(best_viable_fn->Function) ? 1 : 0));
if (auto fn_decl =
context.insts().TryGetAsWithId<SemIR::FunctionDecl>(result_id)) {
CheckCppOverloadAccess(context, loc_id, best_viable_fn->FoundDecl,
fn_decl->inst_id);
} else {
CARBON_CHECK(result_id == SemIR::ErrorInst::InstId);
if (result_id != SemIR::ErrorInst::InstId) {
CheckCppOverloadAccess(
context, loc_id, best_viable_fn->FoundDecl,
context.insts().GetAsKnownInstId<SemIR::FunctionDecl>(result_id));
}
return result_id;
}