mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 06:54:44 +01:00
Track and resolve the specific callee in a call to a generic function (#4395)
Add a new `specific_function` instruction that represents a generic function plus its deduced argument list as a callee in a function call. The new instruction can only appear as the immediate operand of a call instruction, so we give it a builtin placeholder type. At the end of each file, require definitions for all specific functions used in that file. Resolve the generic with the argument list to produce those specific function definitions as needed, and diagnose if the generic doesn't have a definition available. A few tests are updated in cases where they declared and used generic functions but didn't previously provide a function definition.
This commit is contained in:
@@ -1190,8 +1190,9 @@ static auto TryEvalInstInContext(EvalContext& eval_context,
|
||||
return RebuildAndValidateIfFieldsAreConstant(
|
||||
eval_context, inst,
|
||||
[&](SemIR::IntType result) {
|
||||
return ValidateIntType(eval_context.context(),
|
||||
int_type.bit_width_id, result);
|
||||
return ValidateIntType(
|
||||
eval_context.context(),
|
||||
inst_id.is_valid() ? inst_id : int_type.bit_width_id, result);
|
||||
},
|
||||
&SemIR::IntType::bit_width_id);
|
||||
}
|
||||
@@ -1207,6 +1208,10 @@ static auto TryEvalInstInContext(EvalContext& eval_context,
|
||||
},
|
||||
&SemIR::FloatType::bit_width_id);
|
||||
}
|
||||
case SemIR::SpecificFunction::Kind:
|
||||
return RebuildIfFieldsAreConstant(eval_context, inst,
|
||||
&SemIR::SpecificFunction::callee_id,
|
||||
&SemIR::SpecificFunction::specific_id);
|
||||
case SemIR::StructType::Kind:
|
||||
return RebuildIfFieldsAreConstant(eval_context, inst,
|
||||
&SemIR::StructType::fields_id);
|
||||
|
||||
Reference in New Issue
Block a user