mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 22:02:52 +01:00
Make identifying a facet type an operation on a (self+facet type) pair (#6592)
Identifying a facet type takes both a self and facet type as a pair, and then encode the self into the IdentifiedFacetType. This makes a constraint that requires some _other_ type implements an interface visible in the IdentifiedFacetType. And it will help to enable facet types with `where T impls Z` for `T` that is not `.Self` in the future. IdentifiedFacetTypes are now stored in a CanonicalValueStore instead of a RelationalValueStore as they key is the combination of self and (declared) facet type together now. When the self-type is a facet value (has type FacetType) this is most straightforward. But when it's a type we need to construct a FacetValue to construct a specific for a require decl, to replace the generic binding of the symbolic `Self`, which has type FacetType. To do so, we make a FacetValue with an empty FacetType (equivalent to TypeType). This prevents any looking for witnesses through the FacetType, which matches what you can get from a type directly, requiring witnesses to come from finding an `impl` decl. Add additional InstNamer logic for such empty facet types so they print as `<typename>.type.facet` if possible instead of as just `facet_value`.
This commit is contained in:
@@ -81,7 +81,19 @@ static auto GetSelfBinding(Context& context,
|
||||
return self_binding_id;
|
||||
}
|
||||
|
||||
auto GetSelfFacetValueForInterfaceMemberSpecific(
|
||||
// Construct a facet value that can be used for the `Self` binding of entities
|
||||
// inside an interface.
|
||||
//
|
||||
// The `interface_specific_id` is the specific of the interface around the
|
||||
// `Self`. The `generic_id` is for member of the interface that the `Self` value
|
||||
// will be for. The `self_witness_id` is an impl witness for the interface that
|
||||
// the `self_type_id` implements that interface. It should come from an impl
|
||||
// definition with the given self-type and the interface as its constraint.
|
||||
//
|
||||
// The returned facet value can be used as the `Self` value in a specific for
|
||||
// the generic member of the interface, and can appear in its specific. As such,
|
||||
// this is a building block of GetSelfSpecificForInterfaceMemberWithSelfType.
|
||||
static auto GetSelfFacetValueForInterfaceMemberSpecific(
|
||||
Context& context, SemIR::SpecificId interface_specific_id,
|
||||
SemIR::GenericId generic_id, SemIR::TypeId self_type_id,
|
||||
SemIR::InstId self_witness_id) -> SemIR::InstId {
|
||||
|
||||
Reference in New Issue
Block a user