Repository: carbon-language/carbon-lang
File: toolchain/check/context.h (C/C++)

Code before:
  // the elements of `block_args`. Returns an instruction referring to the
  // result value.
  auto AddConvergenceBlockWithArgAndPush(
      Parse::NodeId node_id, std::initializer_list<SemIR::InstId> block_args)
      -> SemIR::InstId;

  // Sets the constant value of a block argument created as the result of a
  // branch.  `select_id` should be a `BlockArg` that selects between two
  // values. `cond_id` is the condition, `if_false` is the value to use if the
  // condition is false, and `if_true` is the value to use if the condition is
  // true.  We don't track enough information in the `BlockArg` inst for
  // `TryEvalInst` to do this itself.
  auto SetBlockArgResultBeforeConstantUse(SemIR::InstId select_id,
                                          SemIR::InstId cond_id,
                                          SemIR::InstId if_true,
                                          SemIR::InstId if_false) -> void;

  // Returns whether the current position in the current block is reachable.
  auto is_current_position_reachable() -> bool;

  // Returns the type ID for a constant is a type value, i.e. it is a value of
  // type `TypeType`.
  //
  // Facet values are also types, but can not be passed here. They should be
  // converted to a type through an `as type` conversion, that is, to a value of
  // type `TypeType`.
  auto GetTypeIdForTypeConstant(SemIR::ConstantId constant_id) -> SemIR::TypeId;

  // Returns the type ID for an instruction whose constant value is a type
  // value, i.e. it is a value of type `TypeType`.
  //
  // Instructions whose values are facet values (see `FacetValue`) also produce
  // a type value, but they can not be passed here. They should be converted to
  // a type through an `as type` conversion, such as to a `FacetAccessType`
  // instruction whose value is of type `TypeType`.
  auto GetTypeIdForTypeInst(SemIR::InstId inst_id) -> SemIR::TypeId {
    return GetTypeIdForTypeConstant(constant_values().Get(inst_id));
  }

  // Attempts to complete the type `type_id`. Returns `true` if the type is
  // complete, or `false` if it could not be completed. A complete type has
  // known object and value representations. Returns `true` if the type is
  // symbolic.
  //
  // Avoid calling this where possible, as it can lead to coherence issues.
  // However, it's important that we use it during monomorphization, where we
  // don't want to trigger a request for more monomorphization.
  // TODO: Remove the other call to this function.
  auto TryToCompleteType(SemIR::TypeId type_id, SemIRLoc loc,
                         BuildDiagnosticFn diagnoser = nullptr) -> bool;


Review comment (suggestion):
Facets are not types, unless they're of type `type`.

Code after:
  // Gets a function type. The returned type will be complete.
  auto GetFunctionType(SemIR::FunctionId fn_id, SemIR::SpecificId specific_id)
      -> SemIR::TypeId;

  // Gets the type of an associated function with the `Self` parameter bound to
  // a particular value. The returned type will be complete.
  auto GetFunctionTypeWithSelfType(SemIR::InstId interface_function_type_id,
                                   SemIR::InstId self_id) -> SemIR::TypeId;

  // Gets a generic class type, which is the type of a name of a generic class,
  // such as the type of `Vector` given `class Vector(T:! type)`. The returned
  // type will be complete.
  auto GetGenericClassType(SemIR::ClassId class_id,
                           SemIR::SpecificId enclosing_specific_id)
      -> SemIR::TypeId;

  // Gets a generic interface type, which is the type of a name of a generic
  // interface, such as the type of `AddWith` given
  // `interface AddWith(T:! type)`. The returned type will be complete.
  auto GetGenericInterfaceType(SemIR::InterfaceId interface_id,
                               SemIR::SpecificId enclosing_specific_id)
      -> SemIR::TypeId;

  // Gets the facet type corresponding to a particular interface.
  auto GetInterfaceType(SemIR::InterfaceId interface_id,
                        SemIR::SpecificId specific_id) -> SemIR::TypeId;

  // Returns a pointer type whose pointee type is `pointee_type_id`.
  auto GetPointerType(SemIR::TypeId pointee_type_id) -> SemIR::TypeId;

  // Returns a struct type with the given fields.
  auto GetStructType(SemIR::StructTypeFieldsId fields_id) -> SemIR::TypeId;

  // Returns a tuple type with the given element types.
  auto GetTupleType(llvm::ArrayRef<SemIR::TypeId> type_ids) -> SemIR::TypeId;

  // Returns an unbound element type.
  auto GetUnboundElementType(SemIR::TypeId class_type_id,
                             SemIR::TypeId element_type_id) -> SemIR::TypeId;

  // Adds an exported name.
  auto AddExport(SemIR::InstId inst_id) -> void { exports_.push_back(inst_id); }

  auto Finalize() -> void;

  // True if the current file is an impl file.
  auto IsImplFile() -> bool {
    return sem_ir_->import_irs().Get(SemIR::ImportIRId::ApiForImpl).sem_ir !=
           nullptr;
  }