Skip to content

Commit 18979b3

Browse files
committed
[Sema] Delete ClosuresInResultBuilderDontParticipateInInference
Since we migrated all of code completion to solver-based, this flag is no longer needed.
1 parent 7c72e7d commit 18979b3

File tree

5 files changed

+11
-36
lines changed

5 files changed

+11
-36
lines changed

include/swift/Sema/ConstraintSystem.h

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,8 @@ class SyntacticElementTarget;
7474
// so they could be made friends of ConstraintSystem.
7575
namespace TypeChecker {
7676

77-
llvm::Optional<BraceStmt *> applyResultBuilderBodyTransform(
78-
FuncDecl *func, Type builderType,
79-
bool ClosuresInResultBuilderDontParticipateInInference);
77+
llvm::Optional<BraceStmt *> applyResultBuilderBodyTransform(FuncDecl *func,
78+
Type builderType);
8079

8180
llvm::Optional<constraints::SyntacticElementTarget>
8281
typeCheckExpression(constraints::SyntacticElementTarget &target,
@@ -1815,12 +1814,6 @@ enum class ConstraintSystemFlags {
18151814

18161815
/// Disable macro expansions.
18171816
DisableMacroExpansions = 0x100,
1818-
1819-
/// Non solver-based code completion expects that closures inside result
1820-
/// builders don't participate in inference.
1821-
/// Once all code completion kinds are migrated to solver-based we should be
1822-
/// able to remove this flag.
1823-
ClosuresInResultBuildersDontParticipateInInference = 0x200,
18241817
};
18251818

18261819
/// Options that affect the constraint system as a whole.
@@ -2877,9 +2870,8 @@ class ConstraintSystem {
28772870

28782871
// FIXME: Perhaps these belong on ConstraintSystem itself.
28792872
friend llvm::Optional<BraceStmt *>
2880-
swift::TypeChecker::applyResultBuilderBodyTransform(
2881-
FuncDecl *func, Type builderType,
2882-
bool ClosuresInResultBuilderDontParticipateInInference);
2873+
swift::TypeChecker::applyResultBuilderBodyTransform(FuncDecl *func,
2874+
Type builderType);
28832875

28842876
friend llvm::Optional<SyntacticElementTarget>
28852877
swift::TypeChecker::typeCheckExpression(

lib/Sema/BuilderTransform.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -912,9 +912,8 @@ class ResultBuilderTransform
912912

913913
} // end anonymous namespace
914914

915-
llvm::Optional<BraceStmt *> TypeChecker::applyResultBuilderBodyTransform(
916-
FuncDecl *func, Type builderType,
917-
bool ClosuresInResultBuilderDontParticipateInInference) {
915+
llvm::Optional<BraceStmt *>
916+
TypeChecker::applyResultBuilderBodyTransform(FuncDecl *func, Type builderType) {
918917
// Pre-check the body: pre-check any expressions in it and look
919918
// for return statements.
920919
//
@@ -970,10 +969,6 @@ llvm::Optional<BraceStmt *> TypeChecker::applyResultBuilderBodyTransform(
970969
}
971970

972971
ConstraintSystemOptions options = ConstraintSystemFlags::AllowFixes;
973-
if (ClosuresInResultBuilderDontParticipateInInference) {
974-
options |= ConstraintSystemFlags::
975-
ClosuresInResultBuildersDontParticipateInInference;
976-
}
977972
auto resultInterfaceTy = func->getResultInterfaceType();
978973
auto resultContextType = func->mapTypeIntoContext(resultInterfaceTy);
979974

lib/Sema/ConstraintSystem.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7320,15 +7320,7 @@ bool ConstraintSystem::participatesInInference(ClosureExpr *closure) const {
73207320
if (closure->hasEmptyBody())
73217321
return false;
73227322

7323-
// If body is nested in a parent that has a function builder applied,
7324-
// let's prevent inference until result builders.
7325-
if (Options.contains(
7326-
ConstraintSystemFlags::
7327-
ClosuresInResultBuildersDontParticipateInInference)) {
7328-
return !isInResultBuilderContext(closure);
7329-
} else {
7330-
return true;
7331-
}
7323+
return true;
73327324
}
73337325

73347326
TypeVarBindingProducer::TypeVarBindingProducer(BindingSet &bindings)

lib/Sema/TypeCheckStmt.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2605,11 +2605,8 @@ bool TypeCheckASTNodeAtLocRequest::evaluate(
26052605
if (auto *func = dyn_cast<FuncDecl>(DC)) {
26062606
if (Type builderType = getResultBuilderType(func)) {
26072607
if (func->getBody()) {
2608-
auto optBody = TypeChecker::applyResultBuilderBodyTransform(
2609-
func, builderType,
2610-
/*ClosuresInResultBuilderDontParticipateInInference=*/
2611-
ctx.CompletionCallback == nullptr &&
2612-
ctx.SolutionCallback == nullptr);
2608+
auto optBody =
2609+
TypeChecker::applyResultBuilderBodyTransform(func, builderType);
26132610
if ((ctx.CompletionCallback && ctx.CompletionCallback->gotCallback()) ||
26142611
(ctx.SolutionCallback && ctx.SolutionCallback->gotCallback())) {
26152612
// We already informed the completion callback of solutions found by

lib/Sema/TypeChecker.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -459,9 +459,8 @@ void typeCheckASTNode(ASTNode &node, DeclContext *DC,
459459
/// e.g., because of a \c return statement. Otherwise, returns either the
460460
/// fully type-checked body of the function (on success) or a \c nullptr
461461
/// value if an error occurred while type checking the transformed body.
462-
llvm::Optional<BraceStmt *> applyResultBuilderBodyTransform(
463-
FuncDecl *func, Type builderType,
464-
bool ClosuresInResultBuilderDontParticipateInInference = false);
462+
llvm::Optional<BraceStmt *> applyResultBuilderBodyTransform(FuncDecl *func,
463+
Type builderType);
465464

466465
/// Find the return statements within the body of the given function.
467466
std::vector<ReturnStmt *> findReturnStatements(AnyFunctionRef fn);

0 commit comments

Comments
 (0)