Handle ParameterizedClassType in ExportNameScopeToCpp (#8123)

This is a step towards being able to export methods of parameterized
classes. When exporting such a method, the decl context should be a
`ClassTemplateSpecializationDecl`. Thread the scope's specific ID down
from `MapInstIdToClangDeclOrType` and call `ExportClassSpecificToCpp` to
create this context.

Also add a `context.TODO` to prevent too much code from being exercised
with methods of parameterized classes after getting the parent scope, as
that would lead to various test crashes.

The user-visible effect of this change is that the somewhat mysterious
"TODO: non-class non-namespace name scope" error is replaced with "TODO:
support exporting member functions of parameterized classes".

---------

Co-authored-by: Geoff Romer <gromer@google.com>
This commit is contained in:
Nicholas BishopandGeoff Romer authored and GitHub committed 2026-11-12 23:12:38 +00:00
1 parent f0e3d04d00
commit 54728e47fe
7 files changed
+322 -258

No files matched your search

+2 -1
View File
@@ -234,7 +234,8 @@ auto CarbonExternalASTSource::MapInstIdToClangDeclOrType(LookupResult lookup)
auto callee = GetCallee(context_->sem_ir(), target_inst_id);
if (auto* callee_function = std::get_if<SemIR::CalleeFunction>(&callee)) {
return GetOrExportFunctionToCpp(*context_, SemIR::LocId(target_inst_id),
callee_function->function_id);
callee_function->function_id,
lookup.specific_id);
} else if (auto param_class_type =
context_->insts().TryGetAs<SemIR::ParameterizedClassType>(
type_inst_id)) {