@@ -69,7 +69,6 @@ namespace {
69
69
typedef EquivalenceClass::DerivedSameTypeComponent DerivedSameTypeComponent;
70
70
typedef GenericSignatureBuilder::DelayedRequirement DelayedRequirement;
71
71
typedef GenericSignatureBuilder::ResolvedType ResolvedType;
72
- typedef GenericSignatureBuilder::UnresolvedType GSBUnresolvedType;
73
72
typedef GenericSignatureBuilder::RequirementRHS RequirementRHS;
74
73
} // end anonymous namespace
75
74
@@ -547,20 +546,6 @@ void GenericSignatureBuilder::Implementation::deallocateEquivalenceClass(
547
546
++NumEquivalenceClassesFreed;
548
547
}
549
548
550
- namespace {
551
- // / Retrieve the type described by the given unresolved tyoe.
552
- Type getUnresolvedType (GSBUnresolvedType type,
553
- TypeArrayView<GenericTypeParamType> genericParams) {
554
- if (auto concrete = type.dyn_cast <Type>())
555
- return concrete;
556
-
557
- if (auto pa = type.dyn_cast <PotentialArchetype *>())
558
- return pa->getDependentType (genericParams);
559
-
560
- return Type ();
561
- }
562
- }
563
-
564
549
#pragma mark Requirement sources
565
550
566
551
#ifndef NDEBUG
@@ -6006,8 +5991,7 @@ void GenericSignatureBuilder::checkConformanceConstraints(
6006
5991
namespace swift {
6007
5992
bool operator <(const DerivedSameTypeComponent &lhs,
6008
5993
const DerivedSameTypeComponent &rhs) {
6009
- return compareDependentTypes (getUnresolvedType (lhs.anchor , {}),
6010
- getUnresolvedType (rhs.anchor , {})) < 0 ;
5994
+ return compareDependentTypes (lhs.type , rhs.type ) < 0 ;
6011
5995
}
6012
5996
} // namespace swift
6013
5997
@@ -6117,17 +6101,18 @@ static void computeDerivedSameTypeComponents(
6117
6101
auto &components = equivClass->derivedSameTypeComponents ;
6118
6102
for (unsigned i : indices (equivClass->members )) {
6119
6103
auto pa = equivClass->members [i];
6120
- CanType depType = pa->getDependentType ({ })->getCanonicalType ();
6104
+ auto depType = pa->getDependentType (builder.getGenericParams ());
6105
+ CanType canType = depType->getCanonicalType ();
6121
6106
6122
6107
// Find the representative of this set.
6123
- assert (parentIndices.count (depType ) == 1 && " Unknown member?" );
6124
- unsigned index = parentIndices[depType ];
6108
+ assert (parentIndices.count (canType ) == 1 && " Unknown member?" );
6109
+ unsigned index = parentIndices[canType ];
6125
6110
unsigned representative = findRepresentative (parents, index);
6126
6111
6127
6112
// If this is the representative, add a component for it.
6128
6113
if (representative == index) {
6129
- componentOf[depType ] = components.size ();
6130
- components.push_back (DerivedSameTypeComponent{pa , nullptr });
6114
+ componentOf[canType ] = components.size ();
6115
+ components.push_back (DerivedSameTypeComponent{depType , nullptr });
6131
6116
continue ;
6132
6117
}
6133
6118
@@ -6139,13 +6124,12 @@ static void computeDerivedSameTypeComponents(
6139
6124
assert (componentOf.count (representativeDepTy) == 1 &&
6140
6125
" Missing representative component?" );
6141
6126
unsigned componentIndex = componentOf[representativeDepTy];
6142
- componentOf[depType ] = componentIndex;
6127
+ componentOf[canType ] = componentIndex;
6143
6128
6144
6129
// If this is a better anchor, record it.
6145
- if (compareDependentTypes (
6146
- depType, getUnresolvedType (components[componentIndex].anchor , {})) <
6147
- 0 )
6148
- components[componentIndex].anchor = pa;
6130
+ if (compareDependentTypes (depType, components[componentIndex].type ) < 0 ) {
6131
+ components[componentIndex].type = depType;
6132
+ }
6149
6133
}
6150
6134
6151
6135
// If there is a concrete type, figure out the best concrete type anchor
@@ -6459,7 +6443,7 @@ static void collapseSameTypeComponents(
6459
6443
unsigned newIndex = newComponents.size ();
6460
6444
newIndices[oldIndex] = newIndex;
6461
6445
newComponents.push_back (
6462
- {oldComponent.anchor , oldComponent.concreteTypeSource });
6446
+ {oldComponent.type , oldComponent.concreteTypeSource });
6463
6447
continue ;
6464
6448
}
6465
6449
@@ -6471,9 +6455,9 @@ static void collapseSameTypeComponents(
6471
6455
auto &newComponent = newComponents[newRepresentativeIndex];
6472
6456
6473
6457
// If the old component has a better anchor, keep it.
6474
- if (compareDependentTypes (getUnresolvedType ( oldComponent.anchor , {}),
6475
- getUnresolvedType ( newComponent.anchor , {})) < 0 )
6476
- newComponent. anchor = oldComponent. anchor ;
6458
+ if (compareDependentTypes (oldComponent.type , newComponent. type ) < 0 ) {
6459
+ newComponent.type = oldComponent. type ;
6460
+ }
6477
6461
6478
6462
// If the old component has a better concrete type source, keep it.
6479
6463
if (!newComponent.concreteTypeSource ||
@@ -6957,12 +6941,8 @@ namespace {
6957
6941
6958
6942
static int compareSameTypeComponents (const SameTypeComponentRef *lhsPtr,
6959
6943
const SameTypeComponentRef *rhsPtr){
6960
- Type lhsType = getUnresolvedType (
6961
- lhsPtr->first ->derivedSameTypeComponents [lhsPtr->second ].anchor ,
6962
- { });
6963
- Type rhsType = getUnresolvedType (
6964
- rhsPtr->first ->derivedSameTypeComponents [rhsPtr->second ].anchor ,
6965
- { });
6944
+ Type lhsType = lhsPtr->first ->derivedSameTypeComponents [lhsPtr->second ].type ;
6945
+ Type rhsType = rhsPtr->first ->derivedSameTypeComponents [rhsPtr->second ].type ;
6966
6946
6967
6947
return compareDependentTypes (lhsType, rhsType);
6968
6948
}
@@ -6993,7 +6973,7 @@ void GenericSignatureBuilder::enumerateRequirements(
6993
6973
// Dig out the subject type and its corresponding component.
6994
6974
auto equivClass = subject.first ;
6995
6975
auto &component = equivClass->derivedSameTypeComponents [subject.second ];
6996
- Type subjectType = getUnresolvedType ( component.anchor , genericParams) ;
6976
+ Type subjectType = component.type ;
6997
6977
6998
6978
// If this equivalence class is bound to a concrete type, equate the
6999
6979
// anchor with a concrete type.
@@ -7031,8 +7011,7 @@ void GenericSignatureBuilder::enumerateRequirements(
7031
7011
// FIXME: Distinguish between explicit and inferred here?
7032
7012
auto &nextComponent =
7033
7013
equivClass->derivedSameTypeComponents [subject.second + 1 ];
7034
- Type otherSubjectType =
7035
- getUnresolvedType (nextComponent.anchor , genericParams);
7014
+ Type otherSubjectType = nextComponent.type ;
7036
7015
deferredSameTypeRequirement =
7037
7016
[&f, subjectType, otherSubjectType, this ] {
7038
7017
f (RequirementKind::SameType, subjectType, otherSubjectType,
0 commit comments