@@ -27,8 +27,7 @@ bool PostfixCompletionCallback::Result::tryMerge(const Result &Other,
27
27
if (BaseDecl != Other.BaseDecl )
28
28
return false ;
29
29
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.
32
31
assert (BaseIsStaticMetaType == Other.BaseIsStaticMetaType );
33
32
34
33
auto baseTy = tryMergeBaseTypeForCompletionLookup (BaseTy, Other.BaseTy , DC);
@@ -56,6 +55,12 @@ bool PostfixCompletionCallback::Result::tryMerge(const Result &Other,
56
55
ExpectsNonVoid &= Other.ExpectsNonVoid ;
57
56
IsImpliedResult |= Other.IsImpliedResult ;
58
57
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
+
59
64
return true ;
60
65
}
61
66
@@ -119,25 +124,26 @@ getClosureActorIsolation(const Solution &S, AbstractClosureExpr *ACE) {
119
124
getClosureActorIsolationThunk);
120
125
}
121
126
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)
126
133
return false ;
127
- }
128
- auto fnRefKind = Choice.getFunctionRefInfo ();
129
134
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.
131
145
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 ();
139
146
}
140
- return false ;
141
147
}
142
148
143
149
void PostfixCompletionCallback::sawSolutionImpl (
@@ -166,7 +172,8 @@ void PostfixCompletionCallback::sawSolutionImpl(
166
172
bool IsBaseDeclUnapplied = false ;
167
173
if (auto SelectedOverload = S.getOverloadChoiceIfAvailable (CalleeLocator)) {
168
174
ReferencedDecl = SelectedOverload->choice .getDeclOrNull ();
169
- IsBaseDeclUnapplied = isUnappliedFunctionRef (SelectedOverload->choice );
175
+ IsBaseDeclUnapplied = ReferencedDecl && !isFullyAppliedFunctionRef (
176
+ S, SelectedOverload->choice );
170
177
}
171
178
172
179
bool BaseIsStaticMetaType = S.isStaticallyDerivedMetatype (ParsedExpr);
0 commit comments