@@ -157,27 +157,17 @@ GenericSignature swift::buildGenericSignatureWithCapturedEnvironments(
157
157
/* allowInverses=*/ false );
158
158
}
159
159
160
- Type MapLocalArchetypesOutOfContext::operator ()(SubstitutableType *type) const {
161
- auto *archetypeTy = cast<ArchetypeType>(type);
160
+ Type MapLocalArchetypesOutOfContext::getInterfaceType (
161
+ Type interfaceTy, GenericEnvironment *genericEnv) const {
162
162
163
- // Primary archetypes just map out of context.
164
- if (isa<PrimaryArchetypeType>(archetypeTy) ||
165
- isa<PackArchetypeType>(archetypeTy)) {
166
- return archetypeTy->getInterfaceType ();
163
+ if (auto *dmt = interfaceTy->getAs <DependentMemberType>()) {
164
+ auto newBase = getInterfaceType (dmt->getBase (), genericEnv);
165
+ return DependentMemberType::get (newBase, dmt->getAssocType ());
167
166
}
168
167
169
- assert (isa<LocalArchetypeType>(archetypeTy));
170
-
171
- // Handle dependent member types recursively in the usual way.
172
- if (!archetypeTy->isRoot ())
173
- return Type ();
174
-
175
- // Root local archetypes change depth.
176
- auto *genericEnv = archetypeTy->getGenericEnvironment ();
177
- auto rootParam = archetypeTy->getInterfaceType ()
178
- ->castTo <GenericTypeParamType>();
179
- assert (!rootParam->isParameterPack ());
180
- assert (rootParam->getDepth () == genericEnv->getGenericSignature ()->getMaxDepth ());
168
+ auto rootParam = interfaceTy->castTo <GenericTypeParamType>();
169
+ ASSERT (!rootParam->isParameterPack ());
170
+ ASSERT (rootParam->getDepth () == genericEnv->getGenericSignature ()->getMaxDepth ());
181
171
182
172
// The new depth is determined by counting how many captured environments
183
173
// precede this one.
@@ -192,7 +182,25 @@ Type MapLocalArchetypesOutOfContext::operator()(SubstitutableType *type) const {
192
182
++depth;
193
183
}
194
184
195
- llvm_unreachable (" Fell off the end" );
185
+ llvm::errs () << " Fell off the end:\n " ;
186
+ interfaceTy->dump (llvm::errs ());
187
+ abort ();
188
+ }
189
+
190
+ Type MapLocalArchetypesOutOfContext::operator ()(SubstitutableType *type) const {
191
+ auto *archetypeTy = cast<ArchetypeType>(type);
192
+
193
+ // Primary archetypes just map out of context.
194
+ if (isa<PrimaryArchetypeType>(archetypeTy) ||
195
+ isa<PackArchetypeType>(archetypeTy)) {
196
+ return archetypeTy->getInterfaceType ();
197
+ }
198
+
199
+ ASSERT (isa<LocalArchetypeType>(archetypeTy));
200
+
201
+ // Root local archetypes change depth.
202
+ auto *genericEnv = archetypeTy->getGenericEnvironment ();
203
+ return getInterfaceType (archetypeTy->getInterfaceType (), genericEnv);
196
204
}
197
205
198
206
static Type mapIntoLocalContext (GenericTypeParamType *param, unsigned baseDepth,
0 commit comments