Skip to content

Commit 38d8158

Browse files
committed
[ConstraintSystem] Remove ConstraintSystemFlags::ReusePrecheckedType.
1 parent 3c6ec7f commit 38d8158

File tree

2 files changed

+8
-44
lines changed

2 files changed

+8
-44
lines changed

include/swift/Sema/ConstraintSystem.h

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,10 +1530,6 @@ enum class ConstraintSystemFlags {
15301530
/// left in-tact.
15311531
AllowUnresolvedTypeVariables = 0x04,
15321532

1533-
/// If set, constraint system always reuses type of pre-typechecked
1534-
/// expression, and doesn't dig into its subexpressions.
1535-
ReusePrecheckedType = 0x08,
1536-
15371533
/// If set, verbose output is enabled for this constraint system.
15381534
///
15391535
/// Note that this flag is automatically applied to all constraint systems,
@@ -1542,16 +1538,16 @@ enum class ConstraintSystemFlags {
15421538
/// \c DebugConstraintSolverAttempt. Finally, it can also be automatically
15431539
/// enabled for a pre-configured set of expressions on line numbers by setting
15441540
/// \c DebugConstraintSolverOnLines.
1545-
DebugConstraints = 0x10,
1541+
DebugConstraints = 0x08,
15461542

15471543
/// Don't try to type check closure bodies, and leave them unchecked. This is
15481544
/// used for source tooling functionalities.
1549-
LeaveClosureBodyUnchecked = 0x20,
1545+
LeaveClosureBodyUnchecked = 0x10,
15501546

15511547
/// If set, we are solving specifically to determine the type of a
15521548
/// CodeCompletionExpr, and should continue in the presence of errors wherever
15531549
/// possible.
1554-
ForCodeCompletion = 0x40,
1550+
ForCodeCompletion = 0x20,
15551551

15561552
/// Include Clang function types when checking equality for function types.
15571553
///
@@ -1562,10 +1558,10 @@ enum class ConstraintSystemFlags {
15621558
/// should be treated as semantically different, as they may have different
15631559
/// calling conventions, say due to Clang attributes such as
15641560
/// `__attribute__((ns_consumed))`.
1565-
UseClangFunctionTypes = 0x80,
1561+
UseClangFunctionTypes = 0x40,
15661562

15671563
/// When set, ignore async/sync mismatches
1568-
IgnoreAsyncSyncMismatch = 0x100,
1564+
IgnoreAsyncSyncMismatch = 0x80,
15691565
};
15701566

15711567
/// Options that affect the constraint system as a whole.
@@ -3792,10 +3788,6 @@ class ConstraintSystem {
37923788
return Options.contains(ConstraintSystemFlags::SuppressDiagnostics);
37933789
}
37943790

3795-
bool shouldReusePrecheckedType() const {
3796-
return Options.contains(ConstraintSystemFlags::ReusePrecheckedType);
3797-
}
3798-
37993791
/// Whether we are solving to determine the possible types of a
38003792
/// \c CodeCompletionExpr.
38013793
bool isForCodeCompletion() const {

lib/Sema/CSGen.cpp

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -88,20 +88,12 @@ namespace {
8888
class LinkedExprCollector : public ASTWalker {
8989

9090
llvm::SmallVectorImpl<Expr*> &LinkedExprs;
91-
ConstraintSystem &CS;
9291

9392
public:
94-
LinkedExprCollector(llvm::SmallVectorImpl<Expr *> &linkedExprs,
95-
ConstraintSystem &cs)
96-
: LinkedExprs(linkedExprs), CS(cs) {}
93+
LinkedExprCollector(llvm::SmallVectorImpl<Expr *> &linkedExprs)
94+
: LinkedExprs(linkedExprs) {}
9795

9896
std::pair<bool, Expr *> walkToExprPre(Expr *expr) override {
99-
100-
if (CS.shouldReusePrecheckedType() &&
101-
!CS.getType(expr)->hasTypeVariable()) {
102-
return { false, expr };
103-
}
104-
10597
if (isa<ClosureExpr>(expr))
10698
return {false, expr};
10799

@@ -161,12 +153,6 @@ namespace {
161153
LTI(lti), CS(cs) {}
162154

163155
std::pair<bool, Expr *> walkToExprPre(Expr *expr) override {
164-
165-
if (CS.shouldReusePrecheckedType() &&
166-
!CS.getType(expr)->hasTypeVariable()) {
167-
return { false, expr };
168-
}
169-
170156
if (isa<LiteralExpr>(expr)) {
171157
LTI.hasLiteral = true;
172158
return { false, expr };
@@ -791,11 +777,6 @@ namespace {
791777
if (CS.isArgumentIgnoredForCodeCompletion(expr)) {
792778
return {false, expr};
793779
}
794-
795-
if (CS.shouldReusePrecheckedType() &&
796-
!CS.getType(expr)->hasTypeVariable()) {
797-
return { false, expr };
798-
}
799780

800781
if (auto applyExpr = dyn_cast<ApplyExpr>(expr)) {
801782
if (isa<PrefixUnaryExpr>(applyExpr) ||
@@ -3654,15 +3635,6 @@ namespace {
36543635
return {false, expr};
36553636
}
36563637

3657-
if (CG.getConstraintSystem().shouldReusePrecheckedType()) {
3658-
if (expr->getType()) {
3659-
assert(!expr->getType()->hasTypeVariable());
3660-
assert(!expr->getType()->hasPlaceholder());
3661-
CG.getConstraintSystem().cacheType(expr);
3662-
return { false, expr };
3663-
}
3664-
}
3665-
36663638
// Note that the subexpression of a #selector expression is
36673639
// unevaluated.
36683640
if (auto sel = dyn_cast<ObjCSelectorExpr>(expr)) {
@@ -4436,7 +4408,7 @@ void ConstraintSystem::optimizeConstraints(Expr *e) {
44364408
SmallVector<Expr *, 16> linkedExprs;
44374409

44384410
// Collect any linked expressions.
4439-
LinkedExprCollector collector(linkedExprs, *this);
4411+
LinkedExprCollector collector(linkedExprs);
44404412
e->walk(collector);
44414413

44424414
// Favor types, as appropriate.

0 commit comments

Comments
 (0)