Skip to content

Commit 809a6dc

Browse files
committed
Sema: Remove dead code for 'lazy' properties that's no longer used
1 parent 7aed494 commit 809a6dc

File tree

3 files changed

+12
-31
lines changed

3 files changed

+12
-31
lines changed

lib/Sema/TypeCheckConstraints.cpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2031,9 +2031,6 @@ Type TypeChecker::typeCheckExpression(Expr *&expr, DeclContext *dc,
20312031
return Type();
20322032
}
20332033

2034-
if (options.contains(TypeCheckExprFlags::SkipApplyingSolution))
2035-
return solution.simplifyType(cs.getType(expr));
2036-
20372034
// Apply the solution to the expression.
20382035
result = cs.applySolution(
20392036
solution, result, convertType.getType(),
@@ -2347,7 +2344,7 @@ TypeChecker::getTypeOfCompletionOperator(DeclContext *DC, Expr *LHS,
23472344
}
23482345

23492346
bool TypeChecker::typeCheckBinding(Pattern *&pattern, Expr *&initializer,
2350-
DeclContext *DC, bool skipApplyingSolution) {
2347+
DeclContext *DC) {
23512348

23522349
/// Type checking listener for pattern binding initializers.
23532350
class BindingListener : public ExprTypeCheckListener {
@@ -2442,9 +2439,6 @@ bool TypeChecker::typeCheckBinding(Pattern *&pattern, Expr *&initializer,
24422439
}
24432440

24442441
// Type-check the initializer.
2445-
if (skipApplyingSolution)
2446-
flags |= TypeCheckExprFlags::SkipApplyingSolution;
2447-
24482442
auto resultTy = typeCheckExpression(initializer, DC, contextualType,
24492443
contextualPurpose, flags, &listener);
24502444
assert(!listener.isInOut());
@@ -2495,8 +2489,7 @@ bool TypeChecker::typeCheckBinding(Pattern *&pattern, Expr *&initializer,
24952489
}
24962490

24972491
bool TypeChecker::typeCheckPatternBinding(PatternBindingDecl *PBD,
2498-
unsigned patternNumber,
2499-
bool skipApplyingSolution) {
2492+
unsigned patternNumber) {
25002493
auto &ctx = PBD->getASTContext();
25012494
const auto &pbe = PBD->getPatternList()[patternNumber];
25022495
Pattern *pattern = PBD->getPattern(patternNumber);
@@ -2516,7 +2509,7 @@ bool TypeChecker::typeCheckPatternBinding(PatternBindingDecl *PBD,
25162509
DC = initContext;
25172510
}
25182511

2519-
bool hadError = typeCheckBinding(pattern, init, DC, skipApplyingSolution);
2512+
bool hadError = typeCheckBinding(pattern, init, DC);
25202513
PBD->setPattern(patternNumber, pattern, initContext);
25212514
PBD->setInit(patternNumber, init);
25222515

@@ -2809,8 +2802,7 @@ bool TypeChecker::typeCheckStmtCondition(StmtCondition &cond, DeclContext *dc,
28092802
// If the pattern didn't get a type, it's because we ran into some
28102803
// unknown types along the way. We'll need to check the initializer.
28112804
auto init = elt.getInitializer();
2812-
hadError |= typeCheckBinding(pattern, init, dc,
2813-
/*skipApplyingSolution*/false);
2805+
hadError |= typeCheckBinding(pattern, init, dc);
28142806
elt.setPattern(pattern);
28152807
elt.setInitializer(init);
28162808
hadAnyFalsable |= pattern->isRefutablePattern();

lib/Sema/TypeCheckDecl.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,13 +1008,7 @@ static void validatePatternBindingEntry(TypeChecker &tc,
10081008
// If the pattern didn't get a type or if it contains an unbound generic type,
10091009
// we'll need to check the initializer.
10101010
if (!pattern->hasType() || pattern->getType()->hasUnboundGenericType()) {
1011-
// We used to not apply the solution to lazy bindings here, but that's
1012-
// unnecessary: the code for building lazy getters already has to handle
1013-
// initializers which have had solutions applied, and not applying the
1014-
// solution blocks other diagnostics if we decide not to synthesize the
1015-
// getter.
1016-
bool skipApplyingSolution = false;
1017-
if (tc.typeCheckPatternBinding(binding, entryNumber, skipApplyingSolution))
1011+
if (tc.typeCheckPatternBinding(binding, entryNumber))
10181012
return;
10191013
}
10201014

@@ -2644,7 +2638,7 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
26442638
// If we got a default initializer, install it and re-type-check it
26452639
// to make sure it is properly coerced to the pattern type.
26462640
PBD->setInit(i, defaultInit);
2647-
TC.typeCheckPatternBinding(PBD, i, /*skipApplyingSolution*/false);
2641+
TC.typeCheckPatternBinding(PBD, i);
26482642
}
26492643
}
26502644
}
@@ -2733,7 +2727,7 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
27332727
// If the initializers in the PBD aren't checked yet, do so now.
27342728
for (unsigned i = 0, e = PBD->getNumPatternEntries(); i != e; ++i) {
27352729
if (!PBD->isInitializerChecked(i) && PBD->getInit(i))
2736-
TC.typeCheckPatternBinding(PBD, i, /*skipApplyingSolution*/false);
2730+
TC.typeCheckPatternBinding(PBD, i);
27372731
}
27382732
}
27392733

lib/Sema/TypeChecker.h

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -257,15 +257,12 @@ enum class TypeCheckExprFlags {
257257
/// and so we should not visit bodies of non-single expression closures.
258258
SkipMultiStmtClosures = 0x40,
259259

260-
/// If set, don't apply a solution.
261-
SkipApplyingSolution = 0x100,
262-
263260
/// This is an inout yield.
264-
IsInOutYield = 0x200,
261+
IsInOutYield = 0x100,
265262

266-
/// If set, a conversion constraint should be specfied so that the result of
263+
/// If set, a conversion constraint should be specified so that the result of
267264
/// the expression is an optional type.
268-
ExpressionTypeMustBeOptional = 0x400,
265+
ExpressionTypeMustBeOptional = 0x200,
269266
};
270267

271268
using TypeCheckExprOptions = OptionSet<TypeCheckExprFlags>;
@@ -1535,10 +1532,8 @@ class TypeChecker final : public LazyResolver {
15351532

15361533

15371534
/// Type-check an initialized variable pattern declaration.
1538-
bool typeCheckBinding(Pattern *&P, Expr *&Init, DeclContext *DC,
1539-
bool skipApplyingSolution);
1540-
bool typeCheckPatternBinding(PatternBindingDecl *PBD, unsigned patternNumber,
1541-
bool skipApplyingSolution);
1535+
bool typeCheckBinding(Pattern *&P, Expr *&Init, DeclContext *DC);
1536+
bool typeCheckPatternBinding(PatternBindingDecl *PBD, unsigned patternNumber);
15421537

15431538
/// Type-check a for-each loop's pattern binding and sequence together.
15441539
bool typeCheckForEachBinding(DeclContext *dc, ForEachStmt *stmt);

0 commit comments

Comments
 (0)