@@ -1821,6 +1821,13 @@ static void lookupConcreteNestedType(NominalTypeDecl *decl,
1821
1821
concreteDecls.push_back (cast<TypeDecl>(member));
1822
1822
}
1823
1823
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
+
1824
1831
TypeDecl *EquivalenceClass::lookupNestedType (
1825
1832
GenericSignatureBuilder &builder,
1826
1833
Identifier name,
@@ -1928,11 +1935,7 @@ TypeDecl *EquivalenceClass::lookupNestedType(
1928
1935
" Lookup should never keep a non-anchor associated type" );
1929
1936
} else if (!concreteDecls.empty ()) {
1930
1937
// 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);
1936
1939
1937
1940
// Put the best concrete type first; the rest will follow.
1938
1941
entry.types .push_back (*bestConcreteTypeIter);
@@ -3530,7 +3533,8 @@ static Type getStructuralType(TypeDecl *typeDecl, bool keepSugar) {
3530
3533
3531
3534
static Type substituteConcreteType (Type parentType,
3532
3535
TypeDecl *concreteDecl) {
3533
- if (parentType->is <ErrorType>())
3536
+ if (parentType->is <ErrorType>() ||
3537
+ parentType->is <UnresolvedType>())
3534
3538
return parentType;
3535
3539
3536
3540
auto *dc = concreteDecl->getDeclContext ();
@@ -3583,18 +3587,14 @@ ResolvedType GenericSignatureBuilder::maybeResolveEquivalenceClass(
3583
3587
if (concreteDecls.empty ())
3584
3588
return ResolvedType::forUnresolved (nullptr );
3585
3589
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);
3592
3591
concreteDecl = *bestConcreteTypeIter;
3593
3592
}
3594
3593
}
3595
3594
3596
3595
auto concreteType = substituteConcreteType (parentType, concreteDecl);
3597
- return ResolvedType::forConcrete (concreteType);
3596
+ return maybeResolveEquivalenceClass (concreteType, resolutionKind,
3597
+ wantExactPotentialArchetype);
3598
3598
}
3599
3599
3600
3600
// Find the nested type declaration for this.
0 commit comments