Skip to content

Commit 6ac7915

Browse files
authored
Merge pull request #70013 from ahoppen/ahoppen/remove-leaveclosurebodiesunchecked
[Sema] Remove `LeaveClosureBodiesUnchecked`
2 parents 340b7b7 + b603a5e commit 6ac7915

20 files changed

+51
-139
lines changed

include/swift/AST/Decl.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2212,9 +2212,7 @@ class PatternBindingDecl final : public Decl,
22122212
}
22132213

22142214
/// Returns the typechecked binding entry at the given index.
2215-
const PatternBindingEntry *
2216-
getCheckedPatternBindingEntry(unsigned i,
2217-
bool leaveClosureBodiesUnchecked = false) const;
2215+
const PatternBindingEntry *getCheckedPatternBindingEntry(unsigned i) const;
22182216

22192217
/// Clean up walking the initializers for the pattern
22202218
class InitIterator {

include/swift/AST/TypeCheckRequests.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2327,7 +2327,7 @@ class ResultTypeRequest
23272327
class PatternBindingEntryRequest
23282328
: public SimpleRequest<PatternBindingEntryRequest,
23292329
const PatternBindingEntry *(PatternBindingDecl *,
2330-
unsigned, bool),
2330+
unsigned),
23312331
RequestFlags::SeparatelyCached> {
23322332
public:
23332333
using SimpleRequest::SimpleRequest;
@@ -2336,9 +2336,8 @@ class PatternBindingEntryRequest
23362336
friend SimpleRequest;
23372337

23382338
// Evaluation.
2339-
const PatternBindingEntry *evaluate(Evaluator &evaluator,
2340-
PatternBindingDecl *PBD, unsigned i,
2341-
bool LeaveClosureBodiesUnchecked) const;
2339+
const PatternBindingEntry *
2340+
evaluate(Evaluator &evaluator, PatternBindingDecl *PBD, unsigned i) const;
23422341

23432342
public:
23442343
// Separate caching.

include/swift/AST/TypeCheckerTypeIDZone.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ SWIFT_REQUEST(TypeChecker, OverriddenDeclsRequest,
256256
llvm::TinyPtrVector<ValueDecl *>(ValueDecl *), SeparatelyCached,
257257
NoLocationInfo)
258258
SWIFT_REQUEST(TypeChecker, PatternBindingEntryRequest,
259-
const PatternBindingEntry *(PatternBindingDecl *, unsigned, bool),
259+
const PatternBindingEntry *(PatternBindingDecl *, unsigned),
260260
SeparatelyCached, NoLocationInfo)
261261
SWIFT_REQUEST(TypeChecker, PatternBindingCheckedAndContextualizedInitRequest,
262262
Expr *(PatternBindingDecl *, unsigned),

include/swift/Sema/ConstraintSystem.h

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1806,14 +1806,10 @@ enum class ConstraintSystemFlags {
18061806
/// \c DebugConstraintSolverOnLines.
18071807
DebugConstraints = 0x08,
18081808

1809-
/// Don't try to type check closure bodies, and leave them unchecked. This is
1810-
/// used for source tooling functionalities.
1811-
LeaveClosureBodyUnchecked = 0x10,
1812-
18131809
/// If set, we are solving specifically to determine the type of a
18141810
/// CodeCompletionExpr, and should continue in the presence of errors wherever
18151811
/// possible.
1816-
ForCodeCompletion = 0x20,
1812+
ForCodeCompletion = 0x10,
18171813

18181814
/// Include Clang function types when checking equality for function types.
18191815
///
@@ -1824,13 +1820,13 @@ enum class ConstraintSystemFlags {
18241820
/// should be treated as semantically different, as they may have different
18251821
/// calling conventions, say due to Clang attributes such as
18261822
/// `__attribute__((ns_consumed))`.
1827-
UseClangFunctionTypes = 0x40,
1823+
UseClangFunctionTypes = 0x20,
18281824

18291825
/// When set, ignore async/sync mismatches
1830-
IgnoreAsyncSyncMismatch = 0x80,
1826+
IgnoreAsyncSyncMismatch = 0x40,
18311827

18321828
/// Disable macro expansions.
1833-
DisableMacroExpansions = 0x100,
1829+
DisableMacroExpansions = 0x80,
18341830
};
18351831

18361832
/// Options that affect the constraint system as a whole.
@@ -5210,17 +5206,15 @@ class ConstraintSystem {
52105206
/// \param replaceInvalidRefsWithErrors Indicates whether it's allowed
52115207
/// to replace any discovered invalid member references with `ErrorExpr`.
52125208
static bool preCheckTarget(SyntacticElementTarget &target,
5213-
bool replaceInvalidRefsWithErrors,
5214-
bool leaveClosureBodiesUnchecked);
5209+
bool replaceInvalidRefsWithErrors);
52155210

52165211
/// Pre-check the expression, validating any types that occur in the
52175212
/// expression and folding sequence expressions.
52185213
///
52195214
/// \param replaceInvalidRefsWithErrors Indicates whether it's allowed
52205215
/// to replace any discovered invalid member references with `ErrorExpr`.
52215216
static bool preCheckExpression(Expr *&expr, DeclContext *dc,
5222-
bool replaceInvalidRefsWithErrors,
5223-
bool leaveClosureBodiesUnchecked);
5217+
bool replaceInvalidRefsWithErrors);
52245218

52255219
/// Solve the system of constraints generated from provided target.
52265220
///

include/swift/Sema/IDETypeChecking.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ namespace swift {
5858
}
5959

6060
/// Typecheck binding initializer at \p bindingIndex.
61-
void typeCheckPatternBinding(PatternBindingDecl *PBD, unsigned bindingIndex,
62-
bool leaveClosureBodiesUnchecked);
61+
void typeCheckPatternBinding(PatternBindingDecl *PBD, unsigned bindingIndex);
6362

6463
/// Check if T1 is convertible to T2.
6564
///

lib/AST/Decl.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2220,12 +2220,11 @@ bool PatternBindingDecl::hasStorage() const {
22202220
return false;
22212221
}
22222222

2223-
const PatternBindingEntry *PatternBindingDecl::getCheckedPatternBindingEntry(
2224-
unsigned i, bool leaveClosureBodiesUnchecked) const {
2223+
const PatternBindingEntry *
2224+
PatternBindingDecl::getCheckedPatternBindingEntry(unsigned i) const {
22252225
return evaluateOrDefault(
22262226
getASTContext().evaluator,
2227-
PatternBindingEntryRequest{const_cast<PatternBindingDecl *>(this), i,
2228-
leaveClosureBodiesUnchecked},
2227+
PatternBindingEntryRequest{const_cast<PatternBindingDecl *>(this), i},
22292228
nullptr);
22302229
}
22312230

@@ -2428,8 +2427,7 @@ bool PatternBindingDecl::isComputingPatternBindingEntry(
24282427
const VarDecl *vd) const {
24292428
unsigned i = getPatternEntryIndexForVarDecl(vd);
24302429
return getASTContext().evaluator.hasActiveRequest(
2431-
PatternBindingEntryRequest{const_cast<PatternBindingDecl *>(this), i,
2432-
/*LeaveClosureBodyUnchecked=*/false});
2430+
PatternBindingEntryRequest{const_cast<PatternBindingDecl *>(this), i});
24332431
}
24342432

24352433
bool PatternBindingDecl::isExplicitlyInitialized(unsigned i) const {

lib/IDE/PostfixCompletion.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,7 @@ getOperatorCompletionTypes(DeclContext *DC, Type LHSType, OperatorDecl *Op) {
328328
llvm_unreachable("unexpected operator kind");
329329
}
330330

331-
CS.preCheckExpression(OpCallExpr, DC, /*replaceInvalidRefsWithErrors=*/true,
332-
/*leaveClosureBodyUnchecked=*/false);
331+
CS.preCheckExpression(OpCallExpr, DC, /*replaceInvalidRefsWithErrors=*/true);
333332
OpCallExpr = CS.generateConstraints(OpCallExpr, DC);
334333

335334
CS.assignFixedType(CS.getType(&LHS)->getAs<TypeVariableType>(), LHSType);

lib/Sema/BuilderTransform.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,8 +1310,7 @@ class PreCheckResultBuilderApplication : public ASTWalker {
13101310
DiagnosticTransaction transaction(diagEngine);
13111311

13121312
HasError |= ConstraintSystem::preCheckExpression(
1313-
E, DC, /*replaceInvalidRefsWithErrors=*/true,
1314-
/*leaveClosureBodiesUnchecked=*/false);
1313+
E, DC, /*replaceInvalidRefsWithErrors=*/true);
13151314

13161315
HasError |= transaction.hasErrors();
13171316

lib/Sema/CSApply.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8749,11 +8749,8 @@ namespace {
87498749
return true;
87508750

87518751
case SolutionApplicationToFunctionResult::Delay: {
8752-
if (!Rewriter.cs.Options
8753-
.contains(ConstraintSystemFlags::LeaveClosureBodyUnchecked)) {
8754-
auto closure = cast<ClosureExpr>(fn.getAbstractClosureExpr());
8755-
ClosuresToTypeCheck.push_back(closure);
8756-
}
8752+
auto closure = cast<ClosureExpr>(fn.getAbstractClosureExpr());
8753+
ClosuresToTypeCheck.push_back(closure);
87578754
return false;
87588755
}
87598756
}

lib/Sema/CSSimplify.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10514,8 +10514,7 @@ static bool inferEnumMemberThroughTildeEqualsOperator(
1051410514

1051510515
DiagnosticTransaction diagnostics(ctx.Diags);
1051610516
{
10517-
if (cs.preCheckTarget(target, /*replaceInvalidRefWithErrors=*/true,
10518-
/*leaveClosureBodyUnchecked=*/false)) {
10517+
if (cs.preCheckTarget(target, /*replaceInvalidRefWithErrors=*/true)) {
1051910518
// Skip diagnostics if they are disabled, otherwise it would result in
1052010519
// duplicate diagnostics, since this operation is going to be repeated
1052110520
// in diagnostic mode.

0 commit comments

Comments
 (0)