mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 08:14:43 +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:
@@ -35,6 +35,7 @@ auto GetExprCategory(const File& file, InstId inst_id) -> ExprCategory {
|
||||
case Namespace::Kind:
|
||||
case OutParamPattern::Kind:
|
||||
case RefParamPattern::Kind:
|
||||
case RequirementBaseFacetType::Kind:
|
||||
case RequirementEquivalent::Kind:
|
||||
case RequirementImpls::Kind:
|
||||
case RequirementRewrite::Kind:
|
||||
@@ -124,6 +125,7 @@ auto GetExprCategory(const File& file, InstId inst_id) -> ExprCategory {
|
||||
case LookupImplWitness::Kind:
|
||||
case ImplWitness::Kind:
|
||||
case ImplWitnessAccess::Kind:
|
||||
case ImplWitnessAccessSubstituted::Kind:
|
||||
case ImplWitnessTable::Kind:
|
||||
case ImplWitnessTablePlaceholder::Kind:
|
||||
case ImportCppDecl::Kind:
|
||||
|
||||
Reference in New Issue
Block a user