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

@@ -205,13 +205,6 @@ library "[[@TEST_NAME]]";
import Cpp;
class GenericClass(T: type) {
// CHECK:STDERR: ╭─┤ fail_todo_call_generic_class_constructor.carbon:[[@LINE+7]]:3
// CHECK:STDERR: -> │ fn GenericClass(_: T) -> Self {
// CHECK:STDERR: · ━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━
// CHECK:STDERR: · ┗━━┫ error: semantics TODO: `non-class non-namespace name scope`
// CHECK:STDERR: · ┃ [SemanticsTodo]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
fn GenericClass(_: T) -> Self {
return {};
}
@@ -122,11 +122,12 @@ library "[[@TEST_NAME]]";
import Cpp;
class EnclosingA(T: type) {
// CHECK:STDERR: ╭─┤ fail_todo_enclosing_generic.carbon:[[@LINE+7]]:3
// CHECK:STDERR: ╭─┤ fail_todo_enclosing_generic.carbon:[[@LINE+8]]:3
// CHECK:STDERR: -> │ fn MemberF[U: type](x: T, y: U);
// CHECK:STDERR: · ━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━
// CHECK:STDERR: · ┗━━┫ error: semantics TODO: `non-class non-namespace name scope`
// CHECK:STDERR: · ┃ [SemanticsTodo]
// CHECK:STDERR: · ┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// CHECK:STDERR: · ┗━━┫ error: semantics TODO:
// CHECK:STDERR: · ┃ `support exporting member functions of parameterized classes`
// CHECK:STDERR: · ┃ [SemanticsTodo]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
fn MemberF[U: type](x: T, y: U);