@@ -748,6 +748,8 @@ static auto GetLocalConstantId(ImportRefResolver& resolver,
748
748
}
749
749
750
750
// Translates a NameId from the import IR to a local NameId.
751
+ //
752
+ // No new work is generated by calling this function.
751
753
static auto GetLocalNameId (ImportContext& context, SemIR::NameId import_name_id)
752
754
-> SemIR::NameId {
753
755
if (auto ident_id = import_name_id.AsIdentifierId (); ident_id.has_value ()) {
@@ -757,6 +759,23 @@ static auto GetLocalNameId(ImportContext& context, SemIR::NameId import_name_id)
757
759
return import_name_id;
758
760
}
759
761
762
+ // Returns the id for a local EntityName from an imported one, preserving only
763
+ // the `NameId`, the `CompileTimeBindIndex`, and whether it is a template. Other
764
+ // parts of the EntityName are not kept and are not considered part of the
765
+ // canonical EntityName (even if they are present there).
766
+ //
767
+ // No new work is generated by calling this function.
768
+ static auto GetLocalEntityNameId (ImportRefResolver& resolver,
769
+ SemIR::EntityNameId import_entity_name_id)
770
+ -> SemIR::EntityNameId {
771
+ const auto & import_entity_name =
772
+ resolver.import_entity_names ().Get (import_entity_name_id);
773
+ auto name_id = GetLocalNameId (resolver, import_entity_name.name_id );
774
+ return resolver.local_entity_names ().AddSymbolicBindingName (
775
+ name_id, SemIR::NameScopeId::None, import_entity_name.bind_index (),
776
+ import_entity_name.is_template );
777
+ }
778
+
760
779
// Gets the local constant values corresponding to an imported inst block.
761
780
static auto GetLocalInstBlockContents (ImportRefResolver& resolver,
762
781
SemIR::InstBlockId import_block_id)
@@ -1497,12 +1516,7 @@ static auto TryResolveTypedInst(ImportRefResolver& resolver,
1497
1516
return ResolveResult::Retry ();
1498
1517
}
1499
1518
1500
- const auto & import_entity_name =
1501
- resolver.import_entity_names ().Get (inst.entity_name_id );
1502
- auto name_id = GetLocalNameId (resolver, import_entity_name.name_id );
1503
- auto entity_name_id = resolver.local_entity_names ().AddSymbolicBindingName (
1504
- name_id, SemIR::NameScopeId::None, import_entity_name.bind_index (),
1505
- import_entity_name.is_template );
1519
+ auto entity_name_id = GetLocalEntityNameId (resolver, inst.entity_name_id );
1506
1520
return ResolveAsDeduplicated<SemIR::BindSymbolicName>(
1507
1521
resolver,
1508
1522
{.type_id =
@@ -2942,6 +2956,22 @@ static auto TryResolveTypedInst(ImportRefResolver& resolver,
2942
2956
GetLocalCanonicalInstBlockId (resolver, inst.elements_id , elems)});
2943
2957
}
2944
2958
2959
+ static auto TryResolveTypedInst (ImportRefResolver& resolver,
2960
+ SemIR::SymbolicBindingType inst)
2961
+ -> ResolveResult {
2962
+ auto facet_value_inst_id =
2963
+ GetLocalConstantInstId (resolver, inst.facet_value_inst_id );
2964
+ if (resolver.HasNewWork ()) {
2965
+ return ResolveResult::Retry ();
2966
+ }
2967
+
2968
+ auto entity_name_id = GetLocalEntityNameId (resolver, inst.entity_name_id );
2969
+ return ResolveAsDeduplicated<SemIR::SymbolicBindingType>(
2970
+ resolver, {.type_id = SemIR::TypeType::TypeId,
2971
+ .entity_name_id = entity_name_id,
2972
+ .facet_value_inst_id = facet_value_inst_id});
2973
+ }
2974
+
2945
2975
static auto TryResolveTypedInst (ImportRefResolver& resolver,
2946
2976
SemIR::TupleAccess inst) -> ResolveResult {
2947
2977
auto type_id = GetLocalConstantId (resolver, inst.type_id );
@@ -3290,6 +3320,9 @@ static auto TryResolveInstCanonical(ImportRefResolver& resolver,
3290
3320
case CARBON_KIND (SemIR::SymbolicBindingPattern inst): {
3291
3321
return TryResolveTypedInst (resolver, inst, constant_inst_id);
3292
3322
}
3323
+ case CARBON_KIND (SemIR::SymbolicBindingType inst): {
3324
+ return TryResolveTypedInst (resolver, inst);
3325
+ }
3293
3326
case CARBON_KIND (SemIR::TupleAccess inst): {
3294
3327
return TryResolveTypedInst (resolver, inst);
3295
3328
}
0 commit comments