Repository: carbon-language/carbon-lang
File: toolchain/check/import_ref.cpp (C++)

Code before:
  const auto& import_scope =
      context.import_name_scopes().Get(import_named_constraint.scope_id);

  // Push a block so that we can add scoped instructions to it.
  context.local_context().inst_block_stack().Push();
  InitializeNameScopeAndImportRefs(context, import_scope, new_scope,
                                   new_named_constraint.first_owning_decl_id,
                                   SemIR::NameId::None,
                                   new_named_constraint.parent_scope_id);
  new_scope.set_is_interface_definition();
  new_named_constraint.body_block_id =
      context.local_context().inst_block_stack().Pop();
  new_named_constraint.self_param_id = self_param_id;

  CARBON_CHECK(import_scope.extended_scopes().empty(),
               "Interfaces don't currently have extended scopes to support.");
}

static auto TryResolveTypedInst(ImportRefResolver& resolver,
                                SemIR::NamedConstraintDecl inst,
                                SemIR::ConstantId named_constraint_const_id)
    -> ResolveResult {
  const auto& import_named_constraint =
      resolver.import_named_constraints().Get(inst.named_constraint_id);

  SemIR::NamedConstraintId named_constraint_id = SemIR::NamedConstraintId::None;
  if (!named_constraint_const_id.has_value()) {
    auto import_specific_id = SemIR::SpecificId::None;
    if (auto import_generic_named_constraint_type =
            resolver.import_types().TryGetAs<SemIR::GenericNamedConstraintType>(
                inst.type_id)) {
      import_specific_id =
          import_generic_named_constraint_type->enclosing_specific_id;
    }
    auto specific_data = GetLocalSpecificData(resolver, import_specific_id);
    if (resolver.HasNewWork()) {
      // This is the end of the first phase. Don't make a new interface yet if
      // we already have new work.
      return ResolveResult::Retry();
    }

    // On the second phase, create a forward declaration of the interface.
    auto enclosing_specific_id =
        GetOrAddLocalSpecific(resolver, import_specific_id, specific_data);
    std::tie(named_constraint_id, named_constraint_const_id) =
        MakeNamedConstraintDecl(resolver, import_named_constraint,
                                enclosing_specific_id);
  } else {
    // On the third phase, compute the interface ID from the constant value of
    // the declaration.
    auto named_constraint_const_inst = resolver.local_insts().Get(

Review comment (suggestion):
Could use `auto` here, since the RHS makes it pretty clear what the type is.

Code after:
  const auto& import_scope =
      context.import_name_scopes().Get(import_named_constraint.scope_id);

  // Push a block so that we can add scoped instructions to it.
  context.local_context().inst_block_stack().Push();
  InitializeNameScopeAndImportRefs(context, import_scope, new_scope,
                                   new_named_constraint.first_owning_decl_id,
                                   SemIR::NameId::None,
                                   new_named_constraint.parent_scope_id);
  new_scope.set_is_interface_definition();
  new_named_constraint.body_block_id =
      context.local_context().inst_block_stack().Pop();
  new_named_constraint.self_param_id = self_param_id;

  CARBON_CHECK(import_scope.extended_scopes().empty(),
               "Interfaces don't currently have extended scopes to support.");
}

static auto TryResolveTypedInst(ImportRefResolver& resolver,
                                SemIR::NamedConstraintDecl inst,
                                SemIR::ConstantId named_constraint_const_id)
    -> ResolveResult {
  const auto& import_named_constraint =
      resolver.import_named_constraints().Get(inst.named_constraint_id);

  auto named_constraint_id = SemIR::NamedConstraintId::None;
  if (!named_constraint_const_id.has_value()) {
    auto import_specific_id = SemIR::SpecificId::None;
    if (auto import_generic_named_constraint_type =
            resolver.import_types().TryGetAs<SemIR::GenericNamedConstraintType>(
                inst.type_id)) {
      import_specific_id =
          import_generic_named_constraint_type->enclosing_specific_id;
    }
    auto specific_data = GetLocalSpecificData(resolver, import_specific_id);
    if (resolver.HasNewWork()) {
      // This is the end of the first phase. Don't make a new interface yet if
      // we already have new work.
      return ResolveResult::Retry();
    }

    // On the second phase, create a forward declaration of the interface.
    auto enclosing_specific_id =
        GetOrAddLocalSpecific(resolver, import_specific_id, specific_data);
    std::tie(named_constraint_id, named_constraint_const_id) =
        MakeNamedConstraintDecl(resolver, import_named_constraint,
                                enclosing_specific_id);
  } else {
    // On the third phase, compute the interface ID from the constant value of
    // the declaration.
    auto named_constraint_const_inst = resolver.local_insts().Get(