@@ -131,8 +131,18 @@ UUID GenericEnvironment::getOpenedElementUUID() const {
131
131
return getTrailingObjects<OpenedElementEnvironmentData>()->uuid ;
132
132
}
133
133
134
- void GenericEnvironment::getPackElementBindings (
135
- SmallVectorImpl<PackElementBinding> &bindings) const {
134
+ void GenericEnvironment::forEachPackElementArchetype (
135
+ llvm::function_ref<void (ElementArchetypeType *)> function) const {
136
+ auto packElements = getGenericSignature ().getInnermostGenericParams ();
137
+ for (auto eltInterfaceType: packElements) {
138
+ auto *elementArchetype =
139
+ mapTypeIntoContext (eltInterfaceType)->castTo <ElementArchetypeType>();
140
+ function (elementArchetype);
141
+ }
142
+ }
143
+
144
+ void GenericEnvironment::forEachPackElementBinding (
145
+ PackElementBindingCallback function) const {
136
146
auto sig = getGenericSignature ();
137
147
auto shapeClass = getOpenedElementShapeClass ();
138
148
auto packElements = sig.getInnermostGenericParams ();
@@ -156,13 +166,13 @@ void GenericEnvironment::getPackElementBindings(
156
166
157
167
assert (elementIt != packElements.end ());
158
168
auto *elementArchetype =
159
- mapTypeIntoContext (*elementIt++)->getAs <ElementArchetypeType>();
160
- auto *packArchetype =
161
- mapTypeIntoContext (genericParam)->getAs <PackArchetypeType>();
162
-
163
- assert (elementArchetype && packArchetype);
164
- bindings.emplace_back (elementArchetype, packArchetype);
169
+ mapTypeIntoContext (*elementIt++)->castTo <ElementArchetypeType>();
170
+ auto *packSubstitution =
171
+ maybeApplyOuterContextSubstitutions (genericParam)->castTo <PackType>();
172
+ function (elementArchetype, packSubstitution);
165
173
}
174
+
175
+ assert (elementIt == packElements.end ());
166
176
}
167
177
168
178
GenericEnvironment::GenericEnvironment (GenericSignature signature)
0 commit comments