@@ -334,55 +334,21 @@ remapConcreteSubstitutionSchema(CanType concreteType,
334
334
}));
335
335
}
336
336
337
- // / When a type parameter has two concrete types, we have to unify the
338
- // / type constructor arguments.
339
- // /
340
- // / For example, suppose that we have two concrete same-type requirements:
341
- // /
342
- // / T == Foo<X.Y, Z, String>
343
- // / T == Foo<Int, A.B, W>
344
- // /
345
- // / These lower to the following two rules:
346
- // /
347
- // / T.[concrete: Foo<τ_0_0, τ_0_1, String> with {X.Y, Z}]
348
- // / T.[concrete: Foo<Int, τ_0_0, τ_0_1> with {A.B, W}]
349
- // /
350
- // / The two concrete type symbols will be added to the property bag of 'T',
351
- // / and we will eventually end up in this method, where we will generate three
352
- // / induced rules:
353
- // /
354
- // / X.Y.[concrete: Int] => X.Y
355
- // / A.B => Z
356
- // / W.[concrete: String] => W
357
- // /
358
- // / Returns the left hand side on success (it could also return the right hand
359
- // / side; since we unified the type constructor arguments, it doesn't matter).
360
- // /
361
- // / Returns true if a conflict was detected.
362
- static bool unifyConcreteTypes (
363
- Symbol lhs, Symbol rhs, RewriteContext &ctx,
364
- SmallVectorImpl<std::pair<MutableTerm, MutableTerm>> &inducedRules,
365
- bool debug) {
366
- auto lhsType = lhs.getConcreteType ();
367
- auto rhsType = rhs.getConcreteType ();
368
-
369
- if (debug) {
370
- llvm::dbgs () << " % Unifying " << lhs << " with " << rhs << " \n " ;
371
- }
372
-
373
- class Matcher : public TypeMatcher <Matcher> {
337
+ namespace {
338
+ class ConcreteTypeMatcher : public TypeMatcher <ConcreteTypeMatcher> {
374
339
ArrayRef<Term> lhsSubstitutions;
375
340
ArrayRef<Term> rhsSubstitutions;
376
341
RewriteContext &ctx;
377
342
SmallVectorImpl<std::pair<MutableTerm, MutableTerm>> &inducedRules;
378
343
bool debug;
379
344
380
345
public:
381
- Matcher (ArrayRef<Term> lhsSubstitutions,
382
- ArrayRef<Term> rhsSubstitutions,
383
- RewriteContext &ctx,
384
- SmallVectorImpl<std::pair<MutableTerm, MutableTerm>> &inducedRules,
385
- bool debug)
346
+ ConcreteTypeMatcher (ArrayRef<Term> lhsSubstitutions,
347
+ ArrayRef<Term> rhsSubstitutions,
348
+ RewriteContext &ctx,
349
+ SmallVectorImpl<std::pair<MutableTerm,
350
+ MutableTerm>> &inducedRules,
351
+ bool debug)
386
352
: lhsSubstitutions(lhsSubstitutions),
387
353
rhsSubstitutions (rhsSubstitutions),
388
354
ctx(ctx), inducedRules(inducedRules), debug(debug) {}
@@ -459,10 +425,47 @@ static bool unifyConcreteTypes(
459
425
return false ;
460
426
}
461
427
};
428
+ }
429
+
430
+ // / When a type parameter has two concrete types, we have to unify the
431
+ // / type constructor arguments.
432
+ // /
433
+ // / For example, suppose that we have two concrete same-type requirements:
434
+ // /
435
+ // / T == Foo<X.Y, Z, String>
436
+ // / T == Foo<Int, A.B, W>
437
+ // /
438
+ // / These lower to the following two rules:
439
+ // /
440
+ // / T.[concrete: Foo<τ_0_0, τ_0_1, String> with {X.Y, Z}]
441
+ // / T.[concrete: Foo<Int, τ_0_0, τ_0_1> with {A.B, W}]
442
+ // /
443
+ // / The two concrete type symbols will be added to the property bag of 'T',
444
+ // / and we will eventually end up in this method, where we will generate three
445
+ // / induced rules:
446
+ // /
447
+ // / X.Y.[concrete: Int] => X.Y
448
+ // / A.B => Z
449
+ // / W.[concrete: String] => W
450
+ // /
451
+ // / Returns the left hand side on success (it could also return the right hand
452
+ // / side; since we unified the type constructor arguments, it doesn't matter).
453
+ // /
454
+ // / Returns true if a conflict was detected.
455
+ static bool unifyConcreteTypes (
456
+ Symbol lhs, Symbol rhs, RewriteContext &ctx,
457
+ SmallVectorImpl<std::pair<MutableTerm, MutableTerm>> &inducedRules,
458
+ bool debug) {
459
+ auto lhsType = lhs.getConcreteType ();
460
+ auto rhsType = rhs.getConcreteType ();
461
+
462
+ if (debug) {
463
+ llvm::dbgs () << " % Unifying " << lhs << " with " << rhs << " \n " ;
464
+ }
462
465
463
- Matcher matcher (lhs.getSubstitutions(),
464
- rhs.getSubstitutions(),
465
- ctx, inducedRules, debug);
466
+ ConcreteTypeMatcher matcher (lhs.getSubstitutions (),
467
+ rhs.getSubstitutions (),
468
+ ctx, inducedRules, debug);
466
469
if (!matcher.match (lhsType, rhsType)) {
467
470
// FIXME: Diagnose the conflict
468
471
if (debug) {
0 commit comments