Skip to content

Commit f49b760

Browse files
committed
[IDE] Refactor isUnappliedFunctionRef
Switch to using `hasAppliedSelf` to match the constraint system, and flip the check to more accurately describe what we're checking which is really "is application fully applied"?
1 parent 33b58d2 commit f49b760

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

lib/IDE/PostfixCompletion.cpp

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -119,25 +119,26 @@ getClosureActorIsolation(const Solution &S, AbstractClosureExpr *ACE) {
119119
getClosureActorIsolationThunk);
120120
}
121121

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()) {
122+
/// Returns \c true if \p Choice refers to a function that has been fully
123+
/// applied, including the curried self if present.
124+
static bool isFullyAppliedFunctionRef(const Solution &S,
125+
const OverloadChoice &Choice) {
126+
auto *D = Choice.getDeclOrNull();
127+
if (!D)
126128
return false;
127-
}
128-
auto fnRefKind = Choice.getFunctionRefInfo();
129129

130-
if (fnRefKind.isUnapplied())
130+
switch (Choice.getFunctionRefInfo().getApplyLevel()) {
131+
case FunctionRefInfo::ApplyLevel::Unapplied:
132+
// No argument lists have been applied.
133+
return false;
134+
case FunctionRefInfo::ApplyLevel::SingleApply:
135+
// The arguments have been applied, check to see if the curried self has
136+
// been applied if present.
137+
return !D->hasCurriedSelf() || hasAppliedSelf(S, Choice);
138+
case FunctionRefInfo::ApplyLevel::DoubleApply:
139+
// All argument lists have been applied.
131140
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();
139141
}
140-
return false;
141142
}
142143

143144
void PostfixCompletionCallback::sawSolutionImpl(
@@ -166,7 +167,8 @@ void PostfixCompletionCallback::sawSolutionImpl(
166167
bool IsBaseDeclUnapplied = false;
167168
if (auto SelectedOverload = S.getOverloadChoiceIfAvailable(CalleeLocator)) {
168169
ReferencedDecl = SelectedOverload->choice.getDeclOrNull();
169-
IsBaseDeclUnapplied = isUnappliedFunctionRef(SelectedOverload->choice);
170+
IsBaseDeclUnapplied = ReferencedDecl && !isFullyAppliedFunctionRef(
171+
S, SelectedOverload->choice);
170172
}
171173

172174
bool BaseIsStaticMetaType = S.isStaticallyDerivedMetatype(ParsedExpr);

0 commit comments

Comments
 (0)