Set the value of .Self in a where to that of the outer .Self. (#2344)

Prior to this change, declarations like `let N:! X(.Self) where .(X(.Self).Y) == 5;` have the surprising behavior of the two `.Self` expressions resolving to two different symbolic values. Fix this by forcing the inner one to have the same symbolic value as the outer one, albeit with a different type.
This commit is contained in:
Richard Smith
2022-10-25 11:59:42 -07:00
committed by GitHub
parent c68cced1fb
commit bc7bf325d6
8 changed files with 69 additions and 44 deletions
+3 -1
View File
@@ -430,6 +430,9 @@ void Value::Print(llvm::raw_ostream& out) const {
for (const LookupContext& ctx : constraint.lookup_contexts()) {
out << combine << *ctx.context;
}
if (constraint.lookup_contexts().empty()) {
out << "Type";
}
out << " where ";
llvm::ListSeparator sep(" and ");
for (const RewriteConstraint& rewrite :
@@ -447,7 +450,6 @@ void Value::Print(llvm::raw_ostream& out) const {
}
for (const EqualityConstraint& equality :
constraint.equality_constraints()) {
// TODO: Skip cases matching something in `rewrite_constraints()`.
out << sep;
llvm::ListSeparator equal(" == ");
for (Nonnull<const Value*> value : equality.values) {