Model type expressions as regions (#4698)

This is a precondition for enabling the new pattern-matching subsystem
to support binding patterns that have `if` expressions in the type
position.

---------

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
This commit is contained in:
Geoff Romer
2024-12-19 21:41:06 +00:00
committed by GitHub
co-authored by Richard Smith
parent 95c9634c60
commit a112cbde5c
504 changed files with 5699 additions and 8719 deletions
+3 -6
View File
@@ -141,12 +141,9 @@ auto MatchContext::EmitPatternMatch(Context& context,
case SemIR::BindingPattern::Kind:
case SemIR::SymbolicBindingPattern::Kind: {
CARBON_CHECK(kind_ == MatchKind::Callee);
auto binding_pattern = pattern.inst.As<SemIR::AnyBindingPattern>();
auto cache_entry =
context.bind_name_cache().Lookup(binding_pattern.entity_name_id);
// The cached bind_name should only be used once.
auto bind_name_id =
std::exchange(cache_entry.value(), SemIR::InstId::Invalid);
auto [bind_name_id, type_expr_id] =
context.bind_name_map().Lookup(entry.pattern_id).value();
context.InsertHere(type_expr_id);
auto bind_name = context.insts().GetAs<SemIR::AnyBindName>(bind_name_id);
CARBON_CHECK(!bind_name.value_id.is_valid());
bind_name.value_id = entry.scrutinee_id;