Skip to content

Commit 13fe88c

Browse files
committed
[AST] Rename isCallableNominalType -> isCallAsFunctionType
Make it explicit that we're checking for `callAsFunction` instead of `dynamicallyCall`.
1 parent a39c78b commit 13fe88c

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

include/swift/AST/Types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,7 @@ class alignas(1 << TypeAlignInBits) TypeBase
921921
/// Checks whether this is a type that supports being called through the
922922
/// implementation of a \c callAsFunction method. Note that this does not
923923
/// check access control.
924-
bool isCallableNominalType(DeclContext *dc);
924+
bool isCallAsFunctionType(DeclContext *dc);
925925

926926
/// Return true if the specified type or a super-class/super-protocol has the
927927
/// @dynamicMemberLookup attribute on it.

lib/AST/Type.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2006,7 +2006,7 @@ bool TypeBase::satisfiesClassConstraint() {
20062006
return mayHaveSuperclass() || isObjCExistentialType();
20072007
}
20082008

2009-
bool TypeBase::isCallableNominalType(DeclContext *dc) {
2009+
bool TypeBase::isCallAsFunctionType(DeclContext *dc) {
20102010
// Don't allow callAsFunction to be used with dynamic lookup.
20112011
if (isAnyObject())
20122012
return false;

lib/Sema/CSApply.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7749,7 +7749,7 @@ Expr *ExprRewriter::finishApply(ApplyExpr *apply, Type openedType,
77497749

77507750
// If this is an implicit call to a `callAsFunction` method, build the
77517751
// appropriate member reference.
7752-
if (cs.getType(fn)->getRValueType()->isCallableNominalType(dc)) {
7752+
if (cs.getType(fn)->getRValueType()->isCallAsFunctionType(dc)) {
77537753
fn = buildCallAsFunctionMethodRef(*this, apply, *overload, calleeLoc);
77547754
if (!fn)
77557755
return nullptr;

lib/Sema/CSDiagnostics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ Expr *FailureDiagnostic::getBaseExprFor(const Expr *anchor) const {
147147
return MRE->getBase();
148148
else if (auto *call = dyn_cast<CallExpr>(anchor)) {
149149
auto fnType = getType(call->getFn());
150-
if (fnType->isCallableNominalType(getDC())) {
150+
if (fnType->isCallAsFunctionType(getDC())) {
151151
return call->getFn();
152152
}
153153
}

lib/Sema/CSSimplify.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,7 +1185,7 @@ class ArgumentFailureTracker : public MatchCallArgumentListener {
11851185
argIdx == *UnlabeledTrailingClosureArgIndex && Callee) {
11861186
if (auto *ctor = dyn_cast<ConstructorDecl>(Callee.get())) {
11871187
auto resultTy = ctor->getResultInterfaceType();
1188-
if (resultTy->isCallableNominalType(CS.DC))
1188+
if (resultTy->isCallAsFunctionType(CS.DC))
11891189
return true;
11901190
}
11911191
}
@@ -10985,7 +10985,7 @@ bool ConstraintSystem::simplifyAppliedOverloadsImpl(
1098510985
auto *dc = decl->getDeclContext();
1098610986
if (auto *parent = dc->getSelfNominalTypeDecl()) {
1098710987
auto type = parent->getDeclaredInterfaceType();
10988-
if (type->isCallableNominalType(DC))
10988+
if (type->isCallAsFunctionType(DC))
1098910989
return false;
1099010990
}
1099110991
}
@@ -11330,7 +11330,7 @@ ConstraintSystem::simplifyApplicableFnConstraint(
1133011330
// Handle applications of types with `callAsFunction` methods.
1133111331
// Do this before stripping optional types below, when `shouldAttemptFixes()`
1133211332
// is true.
11333-
if (desugar2->isCallableNominalType(DC)) {
11333+
if (desugar2->isCallAsFunctionType(DC)) {
1133411334
auto memberLoc = getConstraintLocator(
1133511335
locator.withPathElement(ConstraintLocator::ImplicitCallAsFunction));
1133611336
// Add a `callAsFunction` member constraint, binding the member type to a
@@ -11391,7 +11391,7 @@ ConstraintSystem::simplifyApplicableFnConstraint(
1139111391
// trailing closure(s), closure(s) might not belong to
1139211392
// the constructor but rather to implicit `callAsFunction`,
1139311393
// there is no way to determine that without trying.
11394-
if (resultTy->isCallableNominalType(DC) &&
11394+
if (resultTy->isCallAsFunctionType(DC) &&
1139511395
argumentList->hasAnyTrailingClosures()) {
1139611396
auto *calleeLoc = getCalleeLocator(argumentsLoc);
1139711397

@@ -11553,7 +11553,7 @@ ConstraintSystem::simplifyApplicableFnConstraint(
1155311553
// once constraint generation is done.
1155411554
if (getPhase() == ConstraintSystemPhase::ConstraintGeneration &&
1155511555
argumentList->hasAnyTrailingClosures() &&
11556-
instance2->isCallableNominalType(DC)) {
11556+
instance2->isCallAsFunctionType(DC)) {
1155711557
return formUnsolved(/*activate=*/true);
1155811558
}
1155911559

lib/Sema/ConstraintSystem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ ConstraintLocator *ConstraintSystem::getCalleeLocator(
567567
}
568568

569569
// Handle an apply of a nominal type which supports callAsFunction.
570-
if (fnTy->isCallableNominalType(DC)) {
570+
if (fnTy->isCallAsFunctionType(DC)) {
571571
return getConstraintLocator(anchor,
572572
{LocatorPathElt::ApplyFunction(),
573573
LocatorPathElt::ImplicitCallAsFunction()});

0 commit comments

Comments
 (0)