@@ -27,8 +27,7 @@ bool PostfixCompletionCallback::Result::tryMerge(const Result &Other,
2727 if (BaseDecl != Other.BaseDecl )
2828 return false ;
2929
30- // These properties should match if we are talking about the same BaseDecl.
31- assert (IsBaseDeclUnapplied == Other.IsBaseDeclUnapplied );
30+ // This should match if we are talking about the same BaseDecl.
3231 assert (BaseIsStaticMetaType == Other.BaseIsStaticMetaType );
3332
3433 auto baseTy = tryMergeBaseTypeForCompletionLookup (BaseTy, Other.BaseTy , DC);
@@ -56,6 +55,12 @@ bool PostfixCompletionCallback::Result::tryMerge(const Result &Other,
5655 ExpectsNonVoid &= Other.ExpectsNonVoid ;
5756 IsImpliedResult |= Other.IsImpliedResult ;
5857 IsInAsyncContext |= Other.IsInAsyncContext ;
58+
59+ // Note this may differ if we pre-check multiple times since pre-checking
60+ // changes the recorded apply level.
61+ // FIXME: We ought to fix completion to not pre-check multiple times.
62+ IsBaseDeclUnapplied |= Other.IsBaseDeclUnapplied ;
63+
5964 return true ;
6065}
6166
@@ -119,25 +124,26 @@ getClosureActorIsolation(const Solution &S, AbstractClosureExpr *ACE) {
119124 getClosureActorIsolationThunk);
120125}
121126
122- // / Returns \c true if \p Choice refers to a function that hasn't been called
123- // / yet.
124- static bool isUnappliedFunctionRef (const OverloadChoice &Choice) {
125- if (!Choice.isDecl ()) {
127+ // / Returns \c true if \p Choice refers to a function that has been fully
128+ // / applied, including the curried self if present.
129+ static bool isFullyAppliedFunctionRef (const Solution &S,
130+ const OverloadChoice &Choice) {
131+ auto *D = Choice.getDeclOrNull ();
132+ if (!D)
126133 return false ;
127- }
128- auto fnRefKind = Choice.getFunctionRefInfo ();
129134
130- if (fnRefKind.isUnapplied ())
135+ switch (Choice.getFunctionRefInfo ().getApplyLevel ()) {
136+ case FunctionRefInfo::ApplyLevel::Unapplied:
137+ // No argument lists have been applied.
138+ return false ;
139+ case FunctionRefInfo::ApplyLevel::SingleApply:
140+ // The arguments have been applied, check to see if the curried self has
141+ // been applied if present.
142+ return !D->hasCurriedSelf () || hasAppliedSelf (S, Choice);
143+ case FunctionRefInfo::ApplyLevel::DoubleApply:
144+ // All argument lists have been applied.
131145 return true ;
132-
133- // We consider curried member calls as unapplied. E.g.
134- // MyStruct.someInstanceFunc(theInstance)#^COMPLETE^#
135- // is unapplied.
136- if (fnRefKind.isSingleApply ()) {
137- if (auto BaseTy = Choice.getBaseType ())
138- return BaseTy->is <MetatypeType>() && !Choice.getDeclOrNull ()->isStatic ();
139146 }
140- return false ;
141147}
142148
143149void PostfixCompletionCallback::sawSolutionImpl (
@@ -166,7 +172,8 @@ void PostfixCompletionCallback::sawSolutionImpl(
166172 bool IsBaseDeclUnapplied = false ;
167173 if (auto SelectedOverload = S.getOverloadChoiceIfAvailable (CalleeLocator)) {
168174 ReferencedDecl = SelectedOverload->choice .getDeclOrNull ();
169- IsBaseDeclUnapplied = isUnappliedFunctionRef (SelectedOverload->choice );
175+ IsBaseDeclUnapplied = ReferencedDecl && !isFullyAppliedFunctionRef (
176+ S, SelectedOverload->choice );
170177 }
171178
172179 bool BaseIsStaticMetaType = S.isStaticallyDerivedMetatype (ParsedExpr);
0 commit comments