Skip to content

Commit 8e2597b

Browse files
committed
Introduce a helper function, NFC.
1 parent 892c903 commit 8e2597b

File tree

7 files changed

+9
-10
lines changed

7 files changed

+9
-10
lines changed

include/swift/AST/Expr.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3176,7 +3176,8 @@ class ApplyExpr : public Expr {
31763176
public:
31773177
Expr *getFn() const { return Fn; }
31783178
void setFn(Expr *e) { Fn = e; }
3179-
3179+
Expr *getSemanticFn() const { return Fn->getSemanticsProvidingExpr(); }
3180+
31803181
Expr *getArg() const { return ArgAndIsSuper.getPointer(); }
31813182
void setArg(Expr *e) {
31823183
assert((getKind() != ExprKind::Binary || isa<TupleExpr>(e)) &&

lib/AST/Decl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4709,7 +4709,7 @@ ConstructorDecl::getDelegatingOrChainedInitKind(DiagnosticEngine *diags,
47094709
if (!apply)
47104710
return { true, E };
47114711

4712-
auto Callee = apply->getFn()->getSemanticsProvidingExpr();
4712+
auto Callee = apply->getSemanticFn();
47134713

47144714
Expr *arg;
47154715

lib/SILGen/SILGenApply.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -843,8 +843,7 @@ class SILGenApply : public Lowering::ExprVisitor<SILGenApply> {
843843
// actually be using the allocating constructor. Update the type
844844
// appropriately.
845845
// FIXME: Re-derive the type from the declaration + substitutions?
846-
auto ctorRef = cast<OtherConstructorDeclRefExpr>(
847-
site->getFn()->getSemanticsProvidingExpr());
846+
auto ctorRef = cast<OtherConstructorDeclRefExpr>(site->getSemanticFn());
848847
auto fnType = ctorRef->getType()->castTo<FunctionType>();
849848
auto selfTy = MetatypeType::get(
850849
fnType->getInput()->getInOutObjectType());

lib/Sema/CSSimplify.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2561,7 +2561,7 @@ getArgumentLabels(ConstraintSystem &cs, ConstraintLocatorBuilder locator) {
25612561

25622562
if (parts.back().getKind() == ConstraintLocator::ApplyFunction) {
25632563
if (auto applyExpr = dyn_cast<ApplyExpr>(anchor)) {
2564-
anchor = applyExpr->getFn()->getSemanticsProvidingExpr();
2564+
anchor = applyExpr->getSemanticFn();
25652565
}
25662566
parts.pop_back();
25672567
continue;

lib/Sema/MiscDiagnostics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ static void diagSyntacticUseRestrictions(TypeChecker &TC, const Expr *E,
181181
/// methods are fully applied when they can't support partial application.
182182
void checkInvalidPartialApplication(Expr *E) {
183183
if (auto AE = dyn_cast<ApplyExpr>(E)) {
184-
Expr *fnExpr = AE->getFn()->getSemanticsProvidingExpr();
184+
Expr *fnExpr = AE->getSemanticFn();
185185
if (auto forceExpr = dyn_cast<ForceValueExpr>(fnExpr))
186186
fnExpr = forceExpr->getSubExpr()->getSemanticsProvidingExpr();
187187
if (auto dotSyntaxExpr = dyn_cast<DotSyntaxBaseIgnoredExpr>(fnExpr))

lib/Sema/TypeCheckConstraints.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ namespace {
779779

780780
// If the function being called is not our unresolved initializer
781781
// reference, we're done.
782-
if (apply->getFn()->getSemanticsProvidingExpr() != unresolvedDot)
782+
if (apply->getSemanticFn() != unresolvedDot)
783783
break;
784784

785785
foundApply = true;

lib/Sema/TypeCheckStmt.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,7 +1327,7 @@ static bool checkSuperInit(TypeChecker &tc, ConstructorDecl *fromCtor,
13271327
ApplyExpr *apply, bool implicitlyGenerated) {
13281328
// Make sure we are referring to a designated initializer.
13291329
auto otherCtorRef = dyn_cast<OtherConstructorDeclRefExpr>(
1330-
apply->getFn()->getSemanticsProvidingExpr());
1330+
apply->getSemanticFn());
13311331
if (!otherCtorRef)
13321332
return false;
13331333

@@ -1463,8 +1463,7 @@ bool TypeChecker::typeCheckConstructorBodyUntil(ConstructorDecl *ctor,
14631463

14641464
std::pair<bool, Expr *> walkToExprPre(Expr *E) override {
14651465
if (auto apply = dyn_cast<ApplyExpr>(E)) {
1466-
if (isa<OtherConstructorDeclRefExpr>(
1467-
apply->getFn()->getSemanticsProvidingExpr())) {
1466+
if (isa<OtherConstructorDeclRefExpr>(apply->getSemanticFn())) {
14681467
Found = apply;
14691468
return { false, E };
14701469
}

0 commit comments

Comments
 (0)