Fix accessing protected members from templates derived classes (#7780)

When evaluating a deferred member access action, the scope stack cannot
be relied on, so `LookupUnqualifiedName` cannot be used in
`GetHighestAllowedAccess` to get the `Self` type.

Instead, store the `Self` type in the `Context` when evaluating a
method, and use that in `GetHighestAllowedAccess`.
This commit is contained in:
Nicholas Bishop
2026-09-18 19:12:05 +00:00
committed by GitHub
parent 413ac55d4f
commit dbf79d5229
10 changed files with 323 additions and 80 deletions
+1 -1
View File
@@ -122,7 +122,7 @@ auto CheckCppOverloadAccess(
auto name_scope_const_id = context.constant_values().Get(
context.name_scopes().Get(parent_scope_id).inst_id());
SemIR::AccessKind allowed_access_kind =
GetHighestAllowedAccess(context, loc_id, name_scope_const_id);
GetHighestAllowedAccess(context, name_scope_const_id);
CheckAccess(context, loc_id, SemIR::LocId(overload_inst_id), function.name_id,
member_access_kind,
/*is_parent_access=*/false,