@@ -662,7 +662,20 @@ static unsigned getNumRemovedArgumentLabels(ValueDecl *decl,
662
662
663
663
// / Determine the number of applications
664
664
unsigned constraints::getNumApplications (ValueDecl *decl, bool hasAppliedSelf,
665
- FunctionRefKind functionRefKind) {
665
+ FunctionRefKind functionRefKind,
666
+ ConstraintLocatorBuilder locator) {
667
+ // FIXME: Narrow hack for rdar://139234188 - Currently we set
668
+ // FunctionRefKind::Compound for enum element patterns with tuple
669
+ // sub-patterns to ensure the member has argument labels stripped. As such,
670
+ // we need to account for the correct application level here. We ought to be
671
+ // setting the correct FunctionRefKind and properly handling the label
672
+ // matching in the solver though.
673
+ if (auto lastElt = locator.last ()) {
674
+ if (auto matchElt = lastElt->getAs <LocatorPathElt::PatternMatch>()) {
675
+ if (auto *EP = dyn_cast<EnumElementPattern>(matchElt->getPattern ()))
676
+ return (EP->hasSubPattern () ? 1 : 0 ) + hasAppliedSelf;
677
+ }
678
+ }
666
679
switch (functionRefKind) {
667
680
case FunctionRefKind::Unapplied:
668
681
case FunctionRefKind::Compound:
@@ -886,7 +899,8 @@ ConstraintSystem::getTypeOfReference(ValueDecl *value,
886
899
887
900
auto origOpenedType = openedType;
888
901
if (!isRequirementOrWitness (locator)) {
889
- unsigned numApplies = getNumApplications (value, false , functionRefKind);
902
+ unsigned numApplies = getNumApplications (value, false , functionRefKind,
903
+ locator);
890
904
openedType = adjustFunctionTypeForConcurrency (
891
905
origOpenedType, /* baseType=*/ Type (), func, useDC, numApplies, false ,
892
906
replacements, locator);
@@ -915,7 +929,7 @@ ConstraintSystem::getTypeOfReference(ValueDecl *value,
915
929
auto origOpenedType = openedType;
916
930
if (!isRequirementOrWitness (locator)) {
917
931
unsigned numApplies = getNumApplications (
918
- funcDecl, false , functionRefKind);
932
+ funcDecl, false , functionRefKind, locator );
919
933
openedType = adjustFunctionTypeForConcurrency (
920
934
origOpenedType->castTo <FunctionType>(), /* baseType=*/ Type (), funcDecl,
921
935
useDC, numApplies, false , replacements, locator);
@@ -1665,7 +1679,7 @@ DeclReferenceType ConstraintSystem::getTypeOfMemberReference(
1665
1679
// Don't adjust when doing witness matching, because that can cause cycles.
1666
1680
} else if (isa<AbstractFunctionDecl>(value) || isa<EnumElementDecl>(value)) {
1667
1681
unsigned numApplies = getNumApplications (
1668
- value, hasAppliedSelf, functionRefKind);
1682
+ value, hasAppliedSelf, functionRefKind, locator );
1669
1683
openedType = adjustFunctionTypeForConcurrency (
1670
1684
origOpenedType->castTo <FunctionType>(), resolvedBaseTy, value, useDC,
1671
1685
numApplies, isMainDispatchQueueMember (locator), replacements, locator);
@@ -1849,7 +1863,7 @@ Type ConstraintSystem::getEffectiveOverloadType(ConstraintLocator *locator,
1849
1863
auto hasAppliedSelf =
1850
1864
doesMemberRefApplyCurriedSelf (overload.getBaseType (), decl);
1851
1865
unsigned numApplies = getNumApplications (
1852
- decl, hasAppliedSelf, overload.getFunctionRefKind ());
1866
+ decl, hasAppliedSelf, overload.getFunctionRefKind (), locator );
1853
1867
1854
1868
type = adjustFunctionTypeForConcurrency (
1855
1869
type->castTo <FunctionType>(), overload.getBaseType (), decl,
0 commit comments