@@ -1833,6 +1833,13 @@ static void lookupConcreteNestedType(NominalTypeDecl *decl,
1833
1833
concreteDecls.push_back (cast<TypeDecl>(member));
1834
1834
}
1835
1835
1836
+ static auto findBestConcreteNestedType (SmallVectorImpl<TypeDecl *> &concreteDecls) {
1837
+ return std::min_element (concreteDecls.begin (), concreteDecls.end (),
1838
+ [](TypeDecl *type1, TypeDecl *type2) {
1839
+ return TypeDecl::compare (type1, type2) < 0 ;
1840
+ });
1841
+ }
1842
+
1836
1843
TypeDecl *EquivalenceClass::lookupNestedType (
1837
1844
GenericSignatureBuilder &builder,
1838
1845
Identifier name,
@@ -1940,11 +1947,7 @@ TypeDecl *EquivalenceClass::lookupNestedType(
1940
1947
" Lookup should never keep a non-anchor associated type" );
1941
1948
} else if (!concreteDecls.empty ()) {
1942
1949
// Find the best concrete type.
1943
- auto bestConcreteTypeIter =
1944
- std::min_element (concreteDecls.begin (), concreteDecls.end (),
1945
- [](TypeDecl *type1, TypeDecl *type2) {
1946
- return TypeDecl::compare (type1, type2) < 0 ;
1947
- });
1950
+ auto bestConcreteTypeIter = findBestConcreteNestedType (concreteDecls);
1948
1951
1949
1952
// Put the best concrete type first; the rest will follow.
1950
1953
entry.types .push_back (*bestConcreteTypeIter);
@@ -3559,7 +3562,8 @@ static Type getStructuralType(TypeDecl *typeDecl, bool keepSugar) {
3559
3562
3560
3563
static Type substituteConcreteType (Type parentType,
3561
3564
TypeDecl *concreteDecl) {
3562
- if (parentType->is <ErrorType>())
3565
+ if (parentType->is <ErrorType>() ||
3566
+ parentType->is <UnresolvedType>())
3563
3567
return parentType;
3564
3568
3565
3569
auto *dc = concreteDecl->getDeclContext ();
@@ -3612,18 +3616,14 @@ ResolvedType GenericSignatureBuilder::maybeResolveEquivalenceClass(
3612
3616
if (concreteDecls.empty ())
3613
3617
return ResolvedType::forUnresolved (nullptr );
3614
3618
3615
- auto bestConcreteTypeIter =
3616
- std::min_element (concreteDecls.begin (), concreteDecls.end (),
3617
- [](TypeDecl *type1, TypeDecl *type2) {
3618
- return TypeDecl::compare (type1, type2) < 0 ;
3619
- });
3620
-
3619
+ auto bestConcreteTypeIter = findBestConcreteNestedType (concreteDecls);
3621
3620
concreteDecl = *bestConcreteTypeIter;
3622
3621
}
3623
3622
}
3624
3623
3625
3624
auto concreteType = substituteConcreteType (parentType, concreteDecl);
3626
- return ResolvedType::forConcrete (concreteType);
3625
+ return maybeResolveEquivalenceClass (concreteType, resolutionKind,
3626
+ wantExactPotentialArchetype);
3627
3627
}
3628
3628
3629
3629
// Find the nested type declaration for this.
0 commit comments