mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 17:51:05 +01:00
Support list initialization of C++ classes that is performed via a constructor call. (#6660)
The general strategy here is to import the constructor with a signature that directly matches the argument. The intent is that the imported function will eventually be usable directly as the `ImplicitAs.Convert` function in a generated `impl`. For initialization from a tuple, for example `(1, 2)`, we import the selected constructor with a signature that takes a tuple pattern: `fn Class.Class((a: i32, b: i32)) -> Class;` In order to support that, this PR also adds support in general for tuple patterns in function signatures. It turns out the implementation was already very close to allowing this. Assisted-by: Gemini 3 Pro via Antigravity
This commit is contained in:
@@ -163,7 +163,8 @@ auto PerformCppOverloadResolution(Context& context, SemIR::LocId loc_id,
|
||||
CARBON_CHECK(best_viable_fn->Function);
|
||||
CARBON_CHECK(!best_viable_fn->RewriteKind);
|
||||
SemIR::InstId result_id = ImportCppFunctionDecl(
|
||||
context, loc_id, best_viable_fn->Function, arg_exprs.size());
|
||||
context, loc_id, best_viable_fn->Function,
|
||||
{.num_params = static_cast<int32_t>(arg_exprs.size())});
|
||||
if (result_id != SemIR::ErrorInst::InstId) {
|
||||
CheckCppOverloadAccess(
|
||||
context, loc_id, best_viable_fn->FoundDecl,
|
||||
|
||||
Reference in New Issue
Block a user