@@ -259,33 +259,22 @@ findDeclContextForType(TypeChecker &TC,
259
259
260
260
auto ownerDC = typeDecl->getDeclContext ();
261
261
262
- // If the type is declared at the top level, there's nothing we can learn from
263
- // walking our parent contexts.
264
- if (ownerDC->isModuleScopeContext ())
262
+ // If the type is not nested in another type, there's nothing we can
263
+ // learn from walking parent contexts.
264
+ if (!ownerDC->isTypeContext () ||
265
+ isa<GenericTypeParamDecl>(typeDecl))
265
266
return std::make_tuple (Type (), true );
266
267
267
- // Workaround for issue where generic typealias generic parameters are
268
- // looked up with the wrong 'fromDC'.
269
- if (isa<TypeAliasDecl>(ownerDC)) {
270
- assert (isa<GenericTypeParamDecl>(typeDecl));
271
- return std::make_tuple (Type (), true );
272
- }
273
-
274
- bool needsBaseType = (ownerDC->isTypeContext () &&
275
- !isa<GenericTypeParamDecl>(typeDecl));
276
268
NominalTypeDecl *ownerNominal =
277
269
ownerDC->getAsNominalTypeOrNominalTypeExtensionContext ();
278
270
279
271
// We might have an invalid extension that didn't resolve.
280
272
//
281
273
// FIXME: How did UnqualifiedLookup find the decl then?
282
- if (needsBaseType && ownerNominal == nullptr )
274
+ if (ownerNominal == nullptr )
283
275
return std::make_tuple (Type (), false );
284
276
285
277
auto getSelfType = [&](DeclContext *DC) -> Type {
286
- if (!needsBaseType)
287
- return Type ();
288
-
289
278
// When looking up a nominal type declaration inside of a
290
279
// protocol extension, always use the nominal type and
291
280
// not the protocol 'Self' type.
@@ -332,13 +321,6 @@ findDeclContextForType(TypeChecker &TC,
332
321
// We're going to check the next parent context.
333
322
}
334
323
335
- // If we didn't find the member in an immediate parent context and
336
- // there is no base type, something went wrong.
337
- if (!needsBaseType) {
338
- assert (false && " Should have found non-type context by now" );
339
- return std::make_tuple (Type (), false );
340
- }
341
-
342
324
// Now, search the supertypes or refined protocols of each parent
343
325
// context.
344
326
for (auto parentDC = fromDC; !parentDC->isModuleContext ();
0 commit comments