@@ -466,7 +466,7 @@ Type ConstraintSystem::openUnboundGenericType(UnboundGenericType *unbound,
466
466
467
467
// Open up the generic type.
468
468
openGeneric (unboundDecl->getDeclContext (), unboundDecl->getGenericSignature (),
469
- /* skipProtocolSelfConstraint= */ false , locator, replacements);
469
+ locator, replacements);
470
470
471
471
if (parentTy) {
472
472
auto subs = parentTy->getContextSubstitutions (
@@ -633,19 +633,15 @@ FunctionType *ConstraintSystem::openFunctionType(
633
633
AnyFunctionType *funcType,
634
634
ConstraintLocatorBuilder locator,
635
635
OpenedTypeMap &replacements,
636
- DeclContext *outerDC,
637
- bool skipProtocolSelfConstraint,
638
- bool skipGenericRequirements) {
636
+ DeclContext *outerDC) {
639
637
if (auto *genericFn = funcType->getAs <GenericFunctionType>()) {
640
638
auto *signature = genericFn->getGenericSignature ();
641
639
642
640
openGenericParameters (outerDC, signature, replacements, locator);
643
641
644
- if (!skipGenericRequirements) {
645
- openGenericRequirements (
646
- outerDC, signature, skipProtocolSelfConstraint, locator,
647
- [&](Type type) -> Type { return openType (type, replacements); });
648
- }
642
+ openGenericRequirements (
643
+ outerDC, signature, /* skipProtocolSelfConstraint=*/ false , locator,
644
+ [&](Type type) -> Type { return openType (type, replacements); });
649
645
650
646
funcType = genericFn->substGenericArgs (
651
647
[&](Type type) { return openType (type, replacements); });
@@ -914,11 +910,9 @@ ConstraintSystem::getTypeOfReference(ValueDecl *value,
914
910
915
911
OpenedTypeMap replacements;
916
912
917
- auto openedType = openFunctionType (
918
- func->getInterfaceType ()->castTo <AnyFunctionType>(),
919
- locator, replacements,
920
- func->getDeclContext (),
921
- /* skipProtocolSelfConstraint=*/ false );
913
+ auto openedType =
914
+ openFunctionType (func->getInterfaceType ()->castTo <AnyFunctionType>(),
915
+ locator, replacements, func->getDeclContext ());
922
916
923
917
// If we opened up any type variables, record the replacements.
924
918
recordOpenedTypes (locator, replacements);
@@ -951,8 +945,7 @@ ConstraintSystem::getTypeOfReference(ValueDecl *value,
951
945
/* isCurriedInstanceReference=*/ false , functionRefKind);
952
946
953
947
auto openedType = openFunctionType (funcType, locator, replacements,
954
- funcDecl->getDeclContext (),
955
- /* skipProtocolSelfConstraint=*/ false )
948
+ funcDecl->getDeclContext ())
956
949
->removeArgumentLabels (numLabelsToRemove);
957
950
958
951
// If we opened up any type variables, record the replacements.
@@ -1079,7 +1072,6 @@ static void bindArchetypesFromContext(
1079
1072
void ConstraintSystem::openGeneric (
1080
1073
DeclContext *outerDC,
1081
1074
GenericSignature *sig,
1082
- bool skipProtocolSelfConstraint,
1083
1075
ConstraintLocatorBuilder locator,
1084
1076
OpenedTypeMap &replacements) {
1085
1077
if (sig == nullptr )
@@ -1089,7 +1081,7 @@ void ConstraintSystem::openGeneric(
1089
1081
1090
1082
// Add the requirements as constraints.
1091
1083
openGenericRequirements (
1092
- outerDC, sig, skipProtocolSelfConstraint, locator,
1084
+ outerDC, sig, /* skipProtocolSelfConstraint= */ false , locator,
1093
1085
[&](Type type) { return openType (type, replacements); });
1094
1086
}
1095
1087
@@ -1304,10 +1296,17 @@ ConstraintSystem::getTypeOfMemberReference(
1304
1296
1305
1297
// While opening member function type, let's delay opening requirements
1306
1298
// to allow contextual types to affect the situation.
1307
- openedType = openFunctionType (funcType, locator, replacements, outerDC,
1308
- /* skipProtocolSelfConstraint=*/ true ,
1309
- /* skipGenericRequirements=*/ true )
1310
- ->removeArgumentLabels (numRemovedArgumentLabels);
1299
+ if (auto *genericFn = funcType->getAs <GenericFunctionType>()) {
1300
+ openGenericParameters (outerDC, genericFn->getGenericSignature (),
1301
+ replacements, locator);
1302
+
1303
+ openedType = genericFn->substGenericArgs (
1304
+ [&](Type type) { return openType (type, replacements); });
1305
+ } else {
1306
+ openedType = funcType;
1307
+ }
1308
+
1309
+ openedType = openedType->removeArgumentLabels (numRemovedArgumentLabels);
1311
1310
1312
1311
if (!outerDC->getSelfProtocolDecl ()) {
1313
1312
// Class methods returning Self as well as constructors get the
0 commit comments