mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 06:21:04 +01:00
Make FacetAccessType evaluate to SymbolicBindingType for type-of a BindSymbolicName (#6115)
The SymbolicBindingType refers to the type value that will be substituted in for the BindSymbolicName, but holds onto the EntityNameId from the BindSymbolicName instead of (or in addition to, for now) the instruction. The EntityNameId will be used to look in the ScopeStack to find the witnesses either from the BindSymbolicName instruction, or other instructions that specify `impls` constraints against the EntityName. This will allow us to have the `T` in `I(T)` resolve to a `.Self` reference in the type so that we get type equality with the binding's type: `T:! I(.Self)`.
This commit is contained in:
@@ -1208,8 +1208,10 @@ static auto PerformBuiltinConversion(
|
||||
} else {
|
||||
type_inst_id = context.types().GetAsTypeInstId(value_id);
|
||||
|
||||
// Shortcut for lossless round trips through a FacetAccessType when
|
||||
// converting back to the type of its original facet value.
|
||||
// Shortcut for lossless round trips through a FacetAccessType (which
|
||||
// evaluates to SymbolicBindingType when wrapping a symbolic binding) when
|
||||
// converting back to the type of the original symbolic binding facet
|
||||
// value.
|
||||
//
|
||||
// In the case where the FacetAccessType wraps a BindSymbolicName with the
|
||||
// exact facet type that we are converting to, the resulting FacetValue
|
||||
@@ -1219,16 +1221,10 @@ static auto PerformBuiltinConversion(
|
||||
//
|
||||
// TODO: This instruction is going to become a `SymbolicBindingType`, so
|
||||
// we'll need to handle that instead.
|
||||
auto const_type_inst_id =
|
||||
sem_ir.constant_values().GetConstantTypeInstId(type_inst_id);
|
||||
if (auto facet_access_type_inst =
|
||||
sem_ir.insts().TryGetAs<SemIR::FacetAccessType>(
|
||||
const_type_inst_id)) {
|
||||
auto facet_value_inst_id = facet_access_type_inst->facet_value_inst_id;
|
||||
if (sem_ir.insts().Get(facet_value_inst_id).type_id() ==
|
||||
target.type_id) {
|
||||
return facet_value_inst_id;
|
||||
}
|
||||
auto facet_value_inst_id =
|
||||
GetCanonicalFacetOrTypeValue(context, type_inst_id);
|
||||
if (sem_ir.insts().Get(facet_value_inst_id).type_id() == target.type_id) {
|
||||
return facet_value_inst_id;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user