@@ -437,8 +437,8 @@ struct GenericSignatureBuilder::Implementation {
437
437
// / Equivalence classes that are not currently being used.
438
438
std::vector<void *> FreeEquivalenceClasses;
439
439
440
- // / The roots of the rewrite tree, keyed on the canonical types of the
441
- // / anchors .
440
+ // / The roots of the rewrite tree, keyed on the canonical, dependent
441
+ // / types .
442
442
DenseMap<CanType, std::unique_ptr<RewriteTreeNode>> RewriteTreeRoots;
443
443
444
444
// / The generation number for the term-rewriting system, which is
@@ -2291,7 +2291,7 @@ Type EquivalenceClass::getAnchor(
2291
2291
for (auto member : members) {
2292
2292
auto anchorType =
2293
2293
builder.getCanonicalTypeParameter (
2294
- member->getDependentType (genericParams));
2294
+ member->getDependentType (genericParams));
2295
2295
2296
2296
#ifndef NDEBUG
2297
2297
// Check that we get consistent results from all of the anchors.
@@ -3740,13 +3740,8 @@ Type GenericSignatureBuilder::getCanonicalTypeParameter(Type type) {
3740
3740
GenericTypeParamType::get (initialPath.getBase ()->Depth ,
3741
3741
initialPath.getBase ()->Index ,
3742
3742
getASTContext ());
3743
- auto initialEquivClass =
3744
- resolveEquivalenceClass (genericParamType,
3745
- ArchetypeResolutionKind::WellFormed);
3746
- if (!initialEquivClass) return nullptr ;
3747
3743
3748
3744
unsigned startIndex = 0 ;
3749
- auto equivClass = initialEquivClass;
3750
3745
Type currentType = genericParamType;
3751
3746
SmallVector<AssociatedTypeDecl *, 4 > path (initialPath.getPath ().begin (),
3752
3747
initialPath.getPath ().end ());
@@ -3783,30 +3778,20 @@ Type GenericSignatureBuilder::getCanonicalTypeParameter(Type type) {
3783
3778
genericParamType =
3784
3779
GenericTypeParamType::get (newBase->Depth , newBase->Index ,
3785
3780
getASTContext ());
3786
- initialEquivClass =
3787
- resolveEquivalenceClass (genericParamType,
3788
- ArchetypeResolutionKind::WellFormed);
3789
- assert (initialEquivClass && " Must have an equivalence class" );
3790
3781
}
3791
3782
3792
3783
// Move back to the beginning; we may have opened up other rewrites.
3793
3784
simplified = true ;
3794
3785
startIndex = 0 ;
3795
3786
currentType = genericParamType;
3796
- equivClass = initialEquivClass;
3797
3787
continue ;
3798
3788
}
3799
3789
}
3800
3790
3801
3791
// If we've hit the end of the path, we're done.
3802
3792
if (startIndex >= path.size ()) break ;
3803
3793
3804
- // FIXME: It would be nice if there were a better way to get the equivalence
3805
- // class of a named nested type.
3806
3794
currentType = DependentMemberType::get (currentType, path[startIndex++]);
3807
- equivClass =
3808
- resolveEquivalenceClass (currentType, ArchetypeResolutionKind::WellFormed);
3809
- if (!equivClass) break ;
3810
3795
} while (true );
3811
3796
3812
3797
return formDependentType (genericParamType, path);
@@ -4914,21 +4899,21 @@ GenericSignatureBuilder::addSameTypeRequirementBetweenArchetypes(
4914
4899
equivClass->sameTypeConstraints .end (),
4915
4900
equivClass2->sameTypeConstraints .begin (),
4916
4901
equivClass2->sameTypeConstraints .end ());
4902
+ }
4917
4903
4918
- // Combine the rewrite rules.
4919
- if (auto rewriteRoot2 = Impl->getOrCreateRewriteTreeRoot (anchor2)) {
4920
- if (auto rewriteRoot1 = Impl->getOrCreateRewriteTreeRoot (anchor1)) {
4921
- // Merge the second rewrite tree into the first.
4922
- if (rewriteRoot2->mergeInto (rewriteRoot1))
4923
- ++Impl->RewriteGeneration ;
4924
- Impl->RewriteTreeRoots .erase (anchor2);
4925
- } else {
4926
- // Take the second rewrite tree and make it the first.
4927
- auto root2Entry = Impl->RewriteTreeRoots .find (anchor2);
4928
- auto root2Ptr = std::move (root2Entry->second );
4929
- Impl->RewriteTreeRoots .erase (root2Entry);
4930
- (void )Impl->RewriteTreeRoots .insert ({anchor1, std::move (root2Ptr)});
4931
- }
4904
+ // Combine the rewrite rules.
4905
+ if (auto rewriteRoot2 = Impl->getOrCreateRewriteTreeRoot (anchor2)) {
4906
+ if (auto rewriteRoot1 = Impl->getOrCreateRewriteTreeRoot (anchor1)) {
4907
+ // Merge the second rewrite tree into the first.
4908
+ if (rewriteRoot2->mergeInto (rewriteRoot1))
4909
+ ++Impl->RewriteGeneration ;
4910
+ Impl->RewriteTreeRoots .erase (anchor2);
4911
+ } else {
4912
+ // Take the second rewrite tree and make it the first.
4913
+ auto root2Entry = Impl->RewriteTreeRoots .find (anchor2);
4914
+ auto root2Ptr = std::move (root2Entry->second );
4915
+ Impl->RewriteTreeRoots .erase (root2Entry);
4916
+ (void )Impl->RewriteTreeRoots .insert ({anchor1, std::move (root2Ptr)});
4932
4917
}
4933
4918
}
4934
4919
0 commit comments