Skip to content

Commit a7a8d9f

Browse files
committed
[AST] Remove NewBodyKind default
A bunch of callers were accidentally misusing it.
1 parent 55de91b commit a7a8d9f

File tree

5 files changed

+8
-7
lines changed

5 files changed

+8
-7
lines changed

include/swift/AST/AnyFunctionRef.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ class AnyFunctionRef {
137137
return cast<AutoClosureExpr>(ACE)->getBody();
138138
}
139139

140-
void setBody(BraceStmt *stmt, bool isSingleExpression) {
140+
void setTypecheckedBody(BraceStmt *stmt, bool isSingleExpression) {
141141
if (auto *AFD = TheFunction.dyn_cast<AbstractFunctionDecl *>()) {
142-
AFD->setBody(stmt);
142+
AFD->setBody(stmt, AbstractFunctionDecl::BodyKind::TypeChecked);
143143
AFD->setHasSingleExpressionBody(isSingleExpression);
144144
return;
145145
}

include/swift/AST/Decl.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5985,7 +5985,8 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
59855985
/// \sa hasBody()
59865986
BraceStmt *getBody(bool canSynthesize = true) const;
59875987

5988-
void setBody(BraceStmt *S, BodyKind NewBodyKind = BodyKind::Parsed);
5988+
/// Set a new body for the function.
5989+
void setBody(BraceStmt *S, BodyKind NewBodyKind);
59895990

59905991
/// Note that the body was skipped for this function. Function body
59915992
/// cannot be attached after this call.

lib/Sema/CSClosure.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ SolutionApplicationToFunctionResult ConstraintSystem::applySolution(
329329
if (!newBody)
330330
return SolutionApplicationToFunctionResult::Failure;
331331

332-
fn.setBody(newBody, /*isSingleExpression=*/false);
332+
fn.setTypecheckedBody(newBody, /*isSingleExpression=*/false);
333333
if (closure) {
334334
solution.setExprTypes(closure);
335335
}

lib/Sema/PCMacro.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ class Instrumenter : InstrumenterBase {
353353
NB = prependLoggerCall(NB, {StartLoc, EndLoc});
354354

355355
if (NB != B) {
356-
FD->setBody(NB);
356+
FD->setBody(NB, AbstractFunctionDecl::BodyKind::TypeChecked);
357357
TypeChecker::checkFunctionEffects(FD);
358358
}
359359
}

lib/Sema/PlaygroundTransform.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ class Instrumenter : InstrumenterBase {
293293
TargetKindSetter TKS(BracePairs, BracePair::TargetKinds::Return);
294294
BraceStmt *NB = transformBraceStmt(B);
295295
if (NB != B) {
296-
FD->setBody(NB);
296+
FD->setBody(NB, AbstractFunctionDecl::BodyKind::TypeChecked);
297297
TypeChecker::checkFunctionEffects(FD);
298298
}
299299
}
@@ -892,7 +892,7 @@ void swift::performPlaygroundTransform(SourceFile &SF, bool HighPerformance) {
892892
Instrumenter I(ctx, FD, RNG, HighPerformance, TmpNameIndex);
893893
BraceStmt *NewBody = I.transformBraceStmt(Body);
894894
if (NewBody != Body) {
895-
FD->setBody(NewBody);
895+
FD->setBody(NewBody, AbstractFunctionDecl::BodyKind::TypeChecked);
896896
TypeChecker::checkFunctionEffects(FD);
897897
}
898898
return false;

0 commit comments

Comments
 (0)