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

Code before:
    }
    case CARBON_KIND(SemIR::UnboundElementType inst): {
      return TryResolveTypedInst(resolver, inst);
    }
    case CARBON_KIND(SemIR::ValueParamPattern inst): {
      return TryResolveTypedInst(resolver, inst, constant_inst_id);
    }
    case CARBON_KIND(SemIR::VarPattern inst): {
      return TryResolveTypedInst(resolver, inst, constant_inst_id);
    }
    case CARBON_KIND(SemIR::VarStorage inst): {
      return TryResolveTypedInst(resolver, inst, constant_inst_id);
    }
    case CARBON_KIND(SemIR::VtableDecl inst): {
      return TryResolveTypedInst(resolver, inst);
    }
    case CARBON_KIND(SemIR::VtablePtr inst): {
      return TryResolveTypedInst(resolver, inst);
    }
    default:
      // Produce a diagnostic to provide a source location with the CHECK
      // failure.
      resolver.local_context().TODO(
          SemIR::LocId(AddImportIRInst(resolver, inst_id)),
          llvm::formatv("TryResolveInst on {0}", untyped_constant_inst.kind())
              .str());
      CARBON_FATAL(
          "TryResolveInst on unsupported canonical instruction kind {0}",
          untyped_constant_inst.kind());
  }
}

// Tries to resolve the InstId, returning a constant when ready, or `None` if
// more has been added to the stack. A similar API is followed for all
// following TryResolveTypedInst helper functions.
//
// `const_id` is `None` unless we've tried to resolve this instruction
// before, in which case it's the previous result.
//
// TODO: Error is returned when support is missing, but that should go away.
static auto TryResolveInst(ImportRefResolver& resolver, SemIR::InstId inst_id,
                           SemIR::ConstantId const_id) -> ResolveResult {
  auto inst_const_id = resolver.import_constant_values().GetAttached(inst_id);
  if (!inst_const_id.has_value() || !inst_const_id.is_symbolic()) {
    return TryResolveInstCanonical(resolver, inst_id, const_id);
  }

  // Try to import the generic. This might add new work.
  const auto& symbolic_const =
      resolver.import_constant_values().GetSymbolicConstant(inst_const_id);
  auto generic_const_id =

Review comment (suggestion):
```suggestion
          llvm::formatv("TryResolveInst on {0}", untyped_constant_inst.kind()));
```

`TODO` shouldn't need an explicit `str()`

Code after:
    }
    case CARBON_KIND(SemIR::TuplePattern inst): {
      return TryResolveTypedInst(resolver, inst, constant_inst_id);
    }
    case CARBON_KIND(SemIR::TupleType inst): {
      return TryResolveTypedInst(resolver, inst);
    }
    case CARBON_KIND(SemIR::TupleValue inst): {
      return TryResolveTypedInst(resolver, inst);
    }
    case CARBON_KIND(SemIR::UnboundElementType inst): {
      return TryResolveTypedInst(resolver, inst);
    }
    case CARBON_KIND(SemIR::ValueParamPattern inst): {
      return TryResolveTypedInst(resolver, inst, constant_inst_id);
    }
    case CARBON_KIND(SemIR::VarPattern inst): {
      return TryResolveTypedInst(resolver, inst, constant_inst_id);
    }
    case CARBON_KIND(SemIR::VarStorage inst): {
      return TryResolveTypedInst(resolver, inst, constant_inst_id);
    }
    case CARBON_KIND(SemIR::VtableDecl inst): {
      return TryResolveTypedInst(resolver, inst);
    }
    case CARBON_KIND(SemIR::VtablePtr inst): {
      return TryResolveTypedInst(resolver, inst);
    }
    default:
      // Found a canonical instruction which needs to be resolved, but which is
      // not yet handled.
      //
      // TODO: Could we turn this into a compile-time error?
      CARBON_FATAL(
          "Missing case in TryResolveInstCanonical for instruction kind {0}",
          untyped_constant_inst.kind());
  }
}

// Tries to resolve the InstId, returning a constant when ready, or `None` if
// more has been added to the stack. A similar API is followed for all
// following TryResolveTypedInst helper functions.
//
// `const_id` is `None` unless we've tried to resolve this instruction
// before, in which case it's the previous result.
//
// TODO: Error is returned when support is missing, but that should go away.
static auto TryResolveInst(ImportRefResolver& resolver, SemIR::InstId inst_id,
                           SemIR::ConstantId const_id) -> ResolveResult {
  auto inst_const_id = resolver.import_constant_values().GetAttached(inst_id);
  if (!inst_const_id.has_value() || !inst_const_id.is_symbolic()) {