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

Code before:
// Returns a pointer type whose pointee type is `pointee_type_id`.
auto GetPointerType(Context& context, SemIR::TypeInstId pointee_type_id)
    -> SemIR::TypeId;

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

// Returns a tuple type with the given element types.
auto GetTupleType(Context& context, llvm::ArrayRef<SemIR::InstId> type_inst_ids)
    -> SemIR::TypeId;

// Returns a pattern type with the given scrutinee type.
auto GetPatternType(Context& context, SemIR::TypeId scrutinee_type_id)
    -> SemIR::TypeId;

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

// Given a facet value or a type value, get the canonical facet value if
// possible, or return the canonical value of the input type expression if it
// has no canonical facet value.
//
// A facet value can be appear in two ways: as a facet value of type FacetType,
// or through an `as type` conversion which has type TypeType but still refers
// to the original facet value. While both have canonical values of their own,
// in cases that want to work with the facet value when possible, this collapses
// the two cases back together by undoing the `as type` conversion.
//
// This extra canonicalization step is important for constant comparison of
// facet values, when the `as type` conversion is not required to compare as a
// different value.
//
// For type expressions other than `<facet value> as type`, the canonical type
// value is returned.
auto GetCanonicalFacetOrTypeValue(Context& context, SemIR::InstId inst_id)
    -> SemIR::InstId;
auto GetCanonicalFacetOrTypeValue(Context& context, SemIR::ConstantId const_id)
    -> SemIR::ConstantId;

}  // namespace Carbon::Check

#endif  // CARBON_TOOLCHAIN_CHECK_TYPE_H_


Review comment (suggestion):
```suggestion
// A facet value can be appear in two ways: as a facet value of type `FacetType`,
// or through an `as type` conversion which has type `TypeType` but still refers
```

Code after:
// Returns a pointer type whose pointee type is `pointee_type_id`.
auto GetPointerType(Context& context, SemIR::TypeInstId pointee_type_id)
    -> SemIR::TypeId;

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

// Returns a tuple type with the given element types.
auto GetTupleType(Context& context, llvm::ArrayRef<SemIR::InstId> type_inst_ids)
    -> SemIR::TypeId;

// Returns a pattern type with the given scrutinee type.
auto GetPatternType(Context& context, SemIR::TypeId scrutinee_type_id)
    -> SemIR::TypeId;

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

// Given a facet value or a type value, get the canonical facet value if
// possible, or return the canonical value of the input type expression if it
// has no canonical facet value.
//
// A facet value can be appear in two ways: as a facet value of type
// `FacetType`, or through an `as type` conversion which has type `TypeType` but
// still refers to the original facet value. While both have canonical values of
// their own, in cases that want to work with the facet value when possible,
// this collapses the two cases back together by undoing the `as type`
// conversion.
//
// This extra canonicalization step is important for constant comparison of
// facet values, when the `as type` conversion is not required to compare as a
// different value.
//
// For type expressions other than `<facet value> as type`, the canonical type
// value is returned.
auto GetCanonicalFacetOrTypeValue(Context& context, SemIR::InstId inst_id)
    -> SemIR::InstId;
auto GetCanonicalFacetOrTypeValue(Context& context, SemIR::ConstantId const_id)
    -> SemIR::ConstantId;

}  // namespace Carbon::Check

#endif  // CARBON_TOOLCHAIN_CHECK_TYPE_H_