@@ -149,53 +149,6 @@ UUID GenericEnvironment::getOpenedElementUUID() const {
149
149
return getTrailingObjects<OpenedElementEnvironmentData>()->uuid ;
150
150
}
151
151
152
- namespace {
153
-
154
- struct FindOpenedElementParam {
155
- ArrayRef<Type> openedPacks;
156
- ArrayRef<GenericTypeParamType *> packElementParams;
157
-
158
- FindOpenedElementParam (const GenericEnvironment *env,
159
- ArrayRef<Type> openedPacks)
160
- : openedPacks(openedPacks),
161
- packElementParams (
162
- env->getGenericSignature ().getInnermostGenericParams()) {
163
- assert (openedPacks.size () == packElementParams.size ());
164
- }
165
-
166
- GenericTypeParamType *operator ()(Type packParam) {
167
- for (auto i : indices (openedPacks)) {
168
- if (openedPacks[i]->isEqual (packParam))
169
- return packElementParams[i];
170
- }
171
- llvm_unreachable (" parameter was not an opened pack parameter" );
172
- }
173
- };
174
-
175
- struct FindElementArchetypeForOpenedPackParam {
176
- FindOpenedElementParam findElementParam;
177
- QueryInterfaceTypeSubstitutions getElementArchetype;
178
-
179
- FindElementArchetypeForOpenedPackParam (const GenericEnvironment *env,
180
- ArrayRef<Type> openedPacks)
181
- : findElementParam(env, openedPacks), getElementArchetype(env) {}
182
-
183
-
184
- Type operator ()(Type interfaceType) {
185
- assert (interfaceType->isTypeParameter ());
186
- if (auto member = interfaceType->getAs <DependentMemberType>()) {
187
- auto baseArchetype = (*this )(member->getBase ())
188
- ->castTo <ElementArchetypeType>();
189
- return baseArchetype->getNestedType (member->getAssocType ())
190
- ->castTo <ElementArchetypeType>();
191
- }
192
- assert (interfaceType->is <GenericTypeParamType>());
193
- return getElementArchetype (findElementParam (interfaceType));
194
- }
195
- };
196
-
197
- }
198
-
199
152
void GenericEnvironment::forEachPackElementArchetype (
200
153
llvm::function_ref<void (ElementArchetypeType *)> function) const {
201
154
auto packElements = getGenericSignature ().getInnermostGenericParams ();
@@ -652,6 +605,41 @@ Type GenericEnvironment::mapTypeIntoContext(GenericTypeParamType *type) const {
652
605
return result;
653
606
}
654
607
608
+ namespace {
609
+
610
+ struct FindElementArchetypeForOpenedPackParam {
611
+ ArrayRef<Type> openedPacks;
612
+ ArrayRef<GenericTypeParamType *> packElementParams;
613
+ const GenericEnvironment *env;
614
+
615
+ FindElementArchetypeForOpenedPackParam (const GenericEnvironment *env,
616
+ ArrayRef<Type> openedPacks)
617
+ : openedPacks(openedPacks),
618
+ packElementParams (env->getGenericSignature ().getInnermostGenericParams()),
619
+ env(env) {}
620
+
621
+ Type getInterfaceType (Type interfaceType) const {
622
+ if (auto member = interfaceType->getAs <DependentMemberType>()) {
623
+ return DependentMemberType::get (getInterfaceType (member->getBase ()),
624
+ member->getAssocType ());
625
+ }
626
+
627
+ assert (interfaceType->is <GenericTypeParamType>());
628
+ for (auto i : indices (openedPacks)) {
629
+ if (openedPacks[i]->isEqual (interfaceType))
630
+ return packElementParams[i];
631
+ }
632
+
633
+ llvm_unreachable (" parameter was not an opened pack parameter" );
634
+ }
635
+
636
+ Type operator ()(Type interfaceType) const {
637
+ return env->mapTypeIntoContext (getInterfaceType (interfaceType));
638
+ }
639
+ };
640
+
641
+ }
642
+
655
643
// / So this expects a type written with the archetypes of the original generic
656
644
// / environment, not 'this', the opened element environment, because it is the
657
645
// / original PackArchetypes that become ElementArchetypes. Also this function
0 commit comments