@@ -1821,6 +1821,13 @@ static void lookupConcreteNestedType(NominalTypeDecl *decl,
18211821 concreteDecls.push_back (cast<TypeDecl>(member));
18221822}
18231823
1824+ static auto findBestConcreteNestedType (SmallVectorImpl<TypeDecl *> &concreteDecls) {
1825+ return std::min_element (concreteDecls.begin (), concreteDecls.end (),
1826+ [](TypeDecl *type1, TypeDecl *type2) {
1827+ return TypeDecl::compare (type1, type2) < 0 ;
1828+ });
1829+ }
1830+
18241831TypeDecl *EquivalenceClass::lookupNestedType (
18251832 GenericSignatureBuilder &builder,
18261833 Identifier name,
@@ -1928,11 +1935,7 @@ TypeDecl *EquivalenceClass::lookupNestedType(
19281935 " Lookup should never keep a non-anchor associated type" );
19291936 } else if (!concreteDecls.empty ()) {
19301937 // Find the best concrete type.
1931- auto bestConcreteTypeIter =
1932- std::min_element (concreteDecls.begin (), concreteDecls.end (),
1933- [](TypeDecl *type1, TypeDecl *type2) {
1934- return TypeDecl::compare (type1, type2) < 0 ;
1935- });
1938+ auto bestConcreteTypeIter = findBestConcreteNestedType (concreteDecls);
19361939
19371940 // Put the best concrete type first; the rest will follow.
19381941 entry.types .push_back (*bestConcreteTypeIter);
@@ -3530,7 +3533,8 @@ static Type getStructuralType(TypeDecl *typeDecl, bool keepSugar) {
35303533
35313534static Type substituteConcreteType (Type parentType,
35323535 TypeDecl *concreteDecl) {
3533- if (parentType->is <ErrorType>())
3536+ if (parentType->is <ErrorType>() ||
3537+ parentType->is <UnresolvedType>())
35343538 return parentType;
35353539
35363540 auto *dc = concreteDecl->getDeclContext ();
@@ -3583,18 +3587,14 @@ ResolvedType GenericSignatureBuilder::maybeResolveEquivalenceClass(
35833587 if (concreteDecls.empty ())
35843588 return ResolvedType::forUnresolved (nullptr );
35853589
3586- auto bestConcreteTypeIter =
3587- std::min_element (concreteDecls.begin (), concreteDecls.end (),
3588- [](TypeDecl *type1, TypeDecl *type2) {
3589- return TypeDecl::compare (type1, type2) < 0 ;
3590- });
3591-
3590+ auto bestConcreteTypeIter = findBestConcreteNestedType (concreteDecls);
35923591 concreteDecl = *bestConcreteTypeIter;
35933592 }
35943593 }
35953594
35963595 auto concreteType = substituteConcreteType (parentType, concreteDecl);
3597- return ResolvedType::forConcrete (concreteType);
3596+ return maybeResolveEquivalenceClass (concreteType, resolutionKind,
3597+ wantExactPotentialArchetype);
35983598 }
35993599
36003600 // Find the nested type declaration for this.
0 commit comments