@@ -661,7 +661,20 @@ static unsigned getNumRemovedArgumentLabels(ValueDecl *decl,
661
661
662
662
// / Determine the number of applications
663
663
unsigned constraints::getNumApplications (ValueDecl *decl, bool hasAppliedSelf,
664
- FunctionRefKind functionRefKind) {
664
+ FunctionRefKind functionRefKind,
665
+ ConstraintLocatorBuilder locator) {
666
+ // FIXME: Narrow hack for rdar://139234188 - Currently we set
667
+ // FunctionRefKind::Compound for enum element patterns with tuple
668
+ // sub-patterns to ensure the member has argument labels stripped. As such,
669
+ // we need to account for the correct application level here. We ought to be
670
+ // setting the correct FunctionRefKind and properly handling the label
671
+ // matching in the solver though.
672
+ if (auto lastElt = locator.last ()) {
673
+ if (auto matchElt = lastElt->getAs <LocatorPathElt::PatternMatch>()) {
674
+ if (auto *EP = dyn_cast<EnumElementPattern>(matchElt->getPattern ()))
675
+ return (EP->hasSubPattern () ? 1 : 0 ) + hasAppliedSelf;
676
+ }
677
+ }
665
678
switch (functionRefKind) {
666
679
case FunctionRefKind::Unapplied:
667
680
case FunctionRefKind::Compound:
@@ -885,7 +898,8 @@ ConstraintSystem::getTypeOfReference(ValueDecl *value,
885
898
886
899
auto origOpenedType = openedType;
887
900
if (!isRequirementOrWitness (locator)) {
888
- unsigned numApplies = getNumApplications (value, false , functionRefKind);
901
+ unsigned numApplies = getNumApplications (value, false , functionRefKind,
902
+ locator);
889
903
openedType = adjustFunctionTypeForConcurrency (
890
904
origOpenedType, /* baseType=*/ Type (), func, useDC, numApplies, false ,
891
905
replacements, locator);
@@ -914,7 +928,7 @@ ConstraintSystem::getTypeOfReference(ValueDecl *value,
914
928
auto origOpenedType = openedType;
915
929
if (!isRequirementOrWitness (locator)) {
916
930
unsigned numApplies = getNumApplications (
917
- funcDecl, false , functionRefKind);
931
+ funcDecl, false , functionRefKind, locator );
918
932
openedType = adjustFunctionTypeForConcurrency (
919
933
origOpenedType->castTo <FunctionType>(), /* baseType=*/ Type (), funcDecl,
920
934
useDC, numApplies, false , replacements, locator);
@@ -1657,7 +1671,7 @@ DeclReferenceType ConstraintSystem::getTypeOfMemberReference(
1657
1671
// Don't adjust when doing witness matching, because that can cause cycles.
1658
1672
} else if (isa<AbstractFunctionDecl>(value) || isa<EnumElementDecl>(value)) {
1659
1673
unsigned numApplies = getNumApplications (
1660
- value, hasAppliedSelf, functionRefKind);
1674
+ value, hasAppliedSelf, functionRefKind, locator );
1661
1675
openedType = adjustFunctionTypeForConcurrency (
1662
1676
origOpenedType->castTo <FunctionType>(), resolvedBaseTy, value, useDC,
1663
1677
numApplies, isMainDispatchQueueMember (locator), replacements, locator);
@@ -1841,7 +1855,7 @@ Type ConstraintSystem::getEffectiveOverloadType(ConstraintLocator *locator,
1841
1855
auto hasAppliedSelf =
1842
1856
doesMemberRefApplyCurriedSelf (overload.getBaseType (), decl);
1843
1857
unsigned numApplies = getNumApplications (
1844
- decl, hasAppliedSelf, overload.getFunctionRefKind ());
1858
+ decl, hasAppliedSelf, overload.getFunctionRefKind (), locator );
1845
1859
1846
1860
type = adjustFunctionTypeForConcurrency (
1847
1861
type->castTo <FunctionType>(), overload.getBaseType (), decl,
0 commit comments