@@ -13701,6 +13701,25 @@ ConstraintSystem::simplifyExplicitGenericArgumentsConstraint(
13701
13701
if (simplifiedBoundType->isTypeVariableOrMember())
13702
13702
return formUnsolved();
13703
13703
13704
+ std::function<GenericParamList *(ValueDecl *)> getGenericParams =
13705
+ [&](ValueDecl *decl) -> GenericParamList * {
13706
+ auto genericContext = decl->getAsGenericContext();
13707
+ if (!genericContext)
13708
+ return nullptr;
13709
+
13710
+ auto genericParams = genericContext->getGenericParams();
13711
+ if (!genericParams) {
13712
+ // If declaration is a non-generic typealias, let's point
13713
+ // to the underlying generic declaration.
13714
+ if (auto *TA = dyn_cast<TypeAliasDecl>(decl)) {
13715
+ if (auto *UGT = TA->getUnderlyingType()->getAs<AnyGenericType>())
13716
+ return getGenericParams(UGT->getDecl());
13717
+ }
13718
+ }
13719
+
13720
+ return genericParams;
13721
+ };
13722
+
13704
13723
ValueDecl *decl;
13705
13724
SmallVector<OpenedType, 2> openedTypes;
13706
13725
if (auto *bound = dyn_cast<TypeAliasType>(type1.getPointer())) {
@@ -13757,27 +13776,19 @@ ConstraintSystem::simplifyExplicitGenericArgumentsConstraint(
13757
13776
decl = overloadChoice.getDecl();
13758
13777
13759
13778
auto openedOverloadTypes = getOpenedTypes(overloadLocator);
13760
- openedTypes.append(openedOverloadTypes.begin(), openedOverloadTypes.end());
13761
- }
13762
-
13763
- std::function<GenericParamList *(ValueDecl *)> getGenericParams =
13764
- [&](ValueDecl *decl) -> GenericParamList * {
13765
- auto genericContext = decl->getAsGenericContext();
13766
- if (!genericContext)
13767
- return nullptr;
13768
13779
13769
- auto genericParams = genericContext->getGenericParams();
13770
- if (!genericParams) {
13771
- // If declaration is a non-generic typealias, let's point
13772
- // to the underlying generic declaration.
13773
- if (auto *TA = dyn_cast<TypeAliasDecl>(decl)) {
13774
- if (auto *UGT = TA->getUnderlyingType()->getAs<AnyGenericType>())
13775
- return getGenericParams(UGT->getDecl());
13780
+ auto genericParams = getGenericParams(decl);
13781
+ if (genericParams) {
13782
+ for (auto gp : *genericParams) {
13783
+ auto found = find_if(openedOverloadTypes, [&](auto entry) {
13784
+ return entry.first->getDepth() == gp->getDepth() &&
13785
+ entry.first->getIndex() == gp->getIndex();
13786
+ });
13787
+ assert(found != openedOverloadTypes.end());
13788
+ openedTypes.push_back(*found);
13776
13789
}
13777
13790
}
13778
-
13779
- return genericParams;
13780
- };
13791
+ }
13781
13792
13782
13793
if (!decl->getAsGenericContext())
13783
13794
return SolutionKind::Error;
0 commit comments