@@ -152,39 +152,38 @@ Symbol RewriteContext::mergeAssociatedTypes(Symbol lhs, Symbol rhs,
152
152
// / [P2].T => [P2:T]
153
153
// / [P1:T].[P1] => [P1:T]
154
154
// / [P2:T].[P1] => [P2:T]
155
- // / <T> .[P1] => <T>
156
- // / <T> .[P2] => <T>
157
- // / <T> .T => <T> .[P1:T]
158
- // / <T> .[P2:T] => <T> .[P1:T]
155
+ // / τ_0_0 .[P1] => τ_0_0
156
+ // / τ_0_0 .[P2] => τ_0_0
157
+ // / τ_0_0 .T => τ_0_0 .[P1:T]
158
+ // / τ_0_0 .[P2:T] => τ_0_0 .[P1:T]
159
159
// /
160
160
// / The completion procedure ends up adding an infinite series of rules of the
161
161
// / form
162
162
// /
163
- // / <T> .[P1:T].[P2] => <T> .[P1:T]
164
- // / <T> .[P1:T].[P2:T] => <T> .[P1:T].[P1:T]
163
+ // / τ_0_0 .[P1:T].[P2] => τ_0_0 .[P1:T]
164
+ // / τ_0_0 .[P1:T].[P2:T] => τ_0_0 .[P1:T].[P1:T]
165
165
// /
166
- // / <T> .[P1:T].[P1:T].[P2] => <T> .[P1:T].[P1:T]
167
- // / <T> .[P1:T].[P1:T].[P2:T] => <T> .[P1:T].[P1:T].[P1:T]
166
+ // / τ_0_0 .[P1:T].[P1:T].[P2] => τ_0_0 .[P1:T].[P1:T]
167
+ // / τ_0_0 .[P1:T].[P1:T].[P2:T] => τ_0_0 .[P1:T].[P1:T].[P1:T]
168
168
// /
169
- // / <T> .[P1:T].[P1:T].[P1:T].[P2] => <T> .[P1:T].[P1:T].[P1.T]
170
- // / <T> .[P1:T].[P1:T].[P1:T].[P2:T] => <T> .[P1:T].[P1:T].[P1:T].[P1.T]
169
+ // / τ_0_0 .[P1:T].[P1:T].[P1:T].[P2] => τ_0_0 .[P1:T].[P1:T].[P1.T]
170
+ // / τ_0_0 .[P1:T].[P1:T].[P1:T].[P2:T] => τ_0_0 .[P1:T].[P1:T].[P1:T].[P1.T]
171
171
// /
172
172
// / The difficulty here stems from the fact that an arbitrary sequence of
173
- // / [P1:T] following a <T> is known to conform to P2, but P1:T itself
173
+ // / [P1:T] following a τ_0_0 is known to conform to P2, but P1:T itself
174
174
// / does not conform to P2.
175
175
// /
176
176
// / We use a heuristic to compute a completion in this case by using
177
177
// / merged associated type terms.
178
178
// /
179
179
// / The key is the following rewrite rule:
180
180
// /
181
- // / <T> .[P2:T] => <T> .[P1:T]
181
+ // / τ_0_0 .[P2:T] => τ_0_0 .[P1:T]
182
182
// /
183
- // / When we add this rule, we introduce a new merged symbol [P1&P2:T] in
184
- // / a pair of new rules :
183
+ // / When we add this rule, we introduce a new merged symbol [P1&P2:T] and
184
+ // / a new rule :
185
185
// /
186
- // / <T>.[P1:T] => <T>.[P1&P2:T]
187
- // / <T>.[P2:T] => <T>.[P1&P2:T]
186
+ // / τ_0_0.[P1:T] => τ_0_0.[P1&P2:T]
188
187
// /
189
188
// / We also look for any existing rules of the form [P1:T].[Q] => [P1:T]
190
189
// / or [P2:T].[Q] => [P2:T], and introduce a new rule:
@@ -194,15 +193,13 @@ Symbol RewriteContext::mergeAssociatedTypes(Symbol lhs, Symbol rhs,
194
193
// / In the above example, we have such a rule for Q == P1 and Q == P2, so
195
194
// / in total we end up adding the following four rules:
196
195
// /
197
- // / <T>.[P1:T] => <T>.[P1&P2:T]
198
- // / <T>.[P2:T] => <T>.[P1&P2:T]
196
+ // / τ_0_0.[P1:T] => τ_0_0.[P1&P2:T]
199
197
// / [P1&P2:T].[P1] => [P1&P2:T]
200
198
// / [P1&P2:T].[P2] => [P1&P2:T]
201
199
// /
202
200
// / Intuitively, since the conformance requirements on the merged term
203
- // / are not prefixed by the root <T>, they apply at any level; we've
204
- // / "tied off" the recursion, and now the rewrite system has a confluent
205
- // / completion.
201
+ // / are not prefixed by the root τ_0_0, they apply at any level; we've
202
+ // / "tied off" the recursion, and the rewrite system is now convergent.
206
203
void RewriteSystem::processMergedAssociatedTypes () {
207
204
if (MergedAssociatedTypes.empty ())
208
205
return ;
@@ -220,7 +217,7 @@ void RewriteSystem::processMergedAssociatedTypes() {
220
217
// X.[P1:T] => X.[P1&P2:T]
221
218
// X.[P2:T] => X.[P1&P2:T]
222
219
if (Debug.contains (DebugFlags::Merge)) {
223
- llvm::dbgs () << " ## Associated type merge candidate " ;
220
+ llvm::dbgs () << " ## Processing associated type merge candidate " ;
224
221
llvm::dbgs () << lhs << " => " << rhs << " \n " ;
225
222
}
226
223
@@ -237,9 +234,6 @@ void RewriteSystem::processMergedAssociatedTypes() {
237
234
// Add the rule X.[P1:T] => X.[P1&P2:T].
238
235
addRule (rhs, mergedTerm);
239
236
240
- // Add the rule X.[P2:T] => X.[P1&P2:T].
241
- addRule (lhs, mergedTerm);
242
-
243
237
// Collect new rules here so that we're not adding rules while traversing
244
238
// the trie.
245
239
SmallVector<std::pair<MutableTerm, MutableTerm>, 2 > inducedRules;
0 commit comments