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