mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Add CallAction to allow deferring calls (#7682)
Calls with template callee or args can now be deferred via an
InstAction. This allows code like this to check:
```carbon
import Cpp inline '''
template<typename T>
struct C {};
''';
fn F(generic T: type) {
let unused c: Cpp.C(T) = Cpp.C(T).C();
}
```
This commit is contained in:
@@ -579,6 +579,19 @@ static auto GetConstantValue(EvalContext& eval_context,
|
||||
return inst_id;
|
||||
}
|
||||
|
||||
static auto GetConstantValue(EvalContext& eval_context,
|
||||
SemIR::MetaInstBlockId inst_block_id, Phase* phase)
|
||||
-> SemIR::MetaInstBlockId {
|
||||
auto inst_ids = eval_context.inst_blocks().Get(inst_block_id);
|
||||
llvm::SmallVector<SemIR::InstId> new_inst_ids;
|
||||
for (auto inst_id : inst_ids) {
|
||||
new_inst_ids.push_back(
|
||||
GetConstantValue(eval_context, SemIR::MetaInstId{inst_id}, phase));
|
||||
}
|
||||
|
||||
return eval_context.inst_blocks().Add(new_inst_ids);
|
||||
}
|
||||
|
||||
static auto GetConstantValue(EvalContext& eval_context,
|
||||
SemIR::TypeInstId inst_id, Phase* phase)
|
||||
-> SemIR::TypeInstId {
|
||||
@@ -1070,8 +1083,8 @@ template <typename IdT>
|
||||
requires SemIR::Internal::IsIdKindType<IdT> &&
|
||||
SameAsOneOf<IdT, SemIR::IdAndKind::NoneType, SemIR::DestInstId,
|
||||
SemIR::EntityNameId, SemIR::InstBlockId, SemIR::InstId,
|
||||
SemIR::MetaInstId, SemIR::StructTypeFieldsId,
|
||||
SemIR::TypeInstId>
|
||||
SemIR::MetaInstId, SemIR::MetaInstBlockId,
|
||||
SemIR::StructTypeFieldsId, SemIR::TypeInstId>
|
||||
static auto ResolveSpecificDeclForArg(EvalContext& /*eval_context*/, IdT /*id*/)
|
||||
-> void {
|
||||
// These id types have a GetConstantValue() overload but that overload
|
||||
|
||||
Reference in New Issue
Block a user