mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Compare ImplWitnessAccess into Self as canonical constants (#5883)
This makes all `.Self` references in a facet type canonically the same (which will remain true iff they refer to the same `Self` type in the future), removing the need to do more complex comparisons between them using the EntityName, interface, and index. This allows the comparison of types containing `.Self` references to be done correctly regardless of where the `.Self` appears, as such type expressions will all be canonically equal if they otherwise equal now, regardless of whether they are written in the context where `.Self` could have seen different `Self` facet types. In order to retain access to constraints on a base `.Self` facet type, in the case of applying `where` to an existing facet type, we: - Give the base facet type as a `RequirementBaseFacetType` constraint so that eval of `WhereExpr` can find and copy all the constraints off of it. - Introduce eager/early rewrite constraint resolution, which allows a constraint to eagerly resolve access to earlier rewrite constraints (`where .A = () and .B = .A` is eagerly transformed into `where .A = () and .B = ()`) before the full constraint resolution step. This allows use of rewrite constraints in larger type expressions, such as `where .A = () and .B = C(.A)` and `C` will know that the argument is `()`.
This commit is contained in:
@@ -333,6 +333,13 @@ auto EvalConstantInst(Context& context, SemIR::InstId inst_id,
|
||||
return ConstantEvalResult::NewSamePhase(inst);
|
||||
}
|
||||
|
||||
auto EvalConstantInst(Context& context,
|
||||
SemIR::ImplWitnessAccessSubstituted inst)
|
||||
-> ConstantEvalResult {
|
||||
return ConstantEvalResult::Existing(
|
||||
context.constant_values().Get(inst.value_id));
|
||||
}
|
||||
|
||||
auto EvalConstantInst(Context& context,
|
||||
SemIR::ImplWitnessAssociatedConstant inst)
|
||||
-> ConstantEvalResult {
|
||||
|
||||
Reference in New Issue
Block a user