Skip to content

Commit a469f54

Browse files
committed
[Sema] Run structural/availability diagnostics on tap bodies
Since interpolations are now type-checked using conjunctions these diagnostics could be rank as part of the root expression or statement verification.
1 parent b2aabb4 commit a469f54

File tree

3 files changed

+1
-28
lines changed

3 files changed

+1
-28
lines changed

lib/Sema/ConstantnessSemaDiagnostics.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -353,14 +353,7 @@ void swift::diagnoseConstantArgumentRequirement(
353353
return walkToClosureExprPre(closureExpr);
354354
}
355355

356-
// Interpolated expressions' bodies will be type checked
357-
// separately so exit early to avoid duplicate diagnostics.
358-
// The caveat is that they won't be checked inside closure
359-
// bodies because we manually check all closures to avoid
360-
// duplicate diagnostics. Therefore we must still descend into
361-
// interpolated expressions if we are inside of a closure.
362-
if (!expr || isa<ErrorExpr>(expr) || !expr->getType() ||
363-
(isa<InterpolatedStringLiteralExpr>(expr) && !insideClosure))
356+
if (!expr || isa<ErrorExpr>(expr) || !expr->getType())
364357
return Action::SkipChildren(expr);
365358
if (auto *callExpr = dyn_cast<CallExpr>(expr)) {
366359
diagnoseConstantArgumentRequirementOfCall(callExpr, DC->getASTContext());

lib/Sema/MiscDiagnostics.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,6 @@ static void diagSyntacticUseRestrictions(const Expr *E, const DeclContext *DC,
136136

137137
bool shouldWalkCaptureInitializerExpressions() override { return true; }
138138

139-
bool shouldWalkIntoTapExpression() override { return false; }
140-
141139
PreWalkResult<Expr *> walkToExprPre(Expr *E) override {
142140
if (auto collection = dyn_cast<CollectionExpr>(E)) {
143141
if (collection->isTypeDefaulted()) {
@@ -1474,8 +1472,6 @@ static void diagRecursivePropertyAccess(const Expr *E, const DeclContext *DC) {
14741472

14751473
bool shouldWalkCaptureInitializerExpressions() override { return true; }
14761474

1477-
bool shouldWalkIntoTapExpression() override { return false; }
1478-
14791475
MacroWalking getMacroWalkingBehavior() const override {
14801476
return MacroWalking::Expansion;
14811477
}
@@ -1775,8 +1771,6 @@ static void diagnoseImplicitSelfUseInClosure(const Expr *E,
17751771

17761772
bool shouldWalkCaptureInitializerExpressions() override { return true; }
17771773

1778-
bool shouldWalkIntoTapExpression() override { return false; }
1779-
17801774
PreWalkResult<Expr *> walkToExprPre(Expr *E) override {
17811775
if (auto *CE = dyn_cast<AbstractClosureExpr>(E)) {
17821776
// If this is a potentially-escaping closure expression, start looking
@@ -4193,8 +4187,6 @@ static void checkStmtConditionTrailingClosure(ASTContext &ctx, const Expr *E) {
41934187

41944188
bool shouldWalkCaptureInitializerExpressions() override { return true; }
41954189

4196-
bool shouldWalkIntoTapExpression() override { return false; }
4197-
41984190
MacroWalking getMacroWalkingBehavior() const override {
41994191
return MacroWalking::Expansion;
42004192
}
@@ -4323,8 +4315,6 @@ class ObjCSelectorWalker : public ASTWalker {
43234315

43244316
bool shouldWalkCaptureInitializerExpressions() override { return true; }
43254317

4326-
bool shouldWalkIntoTapExpression() override { return false; }
4327-
43284318
MacroWalking getMacroWalkingBehavior() const override {
43294319
return MacroWalking::Expansion;
43304320
}
@@ -5184,8 +5174,6 @@ static void diagnoseUnintendedOptionalBehavior(const Expr *E,
51845174

51855175
bool shouldWalkCaptureInitializerExpressions() override { return true; }
51865176

5187-
bool shouldWalkIntoTapExpression() override { return false; }
5188-
51895177
MacroWalking getMacroWalkingBehavior() const override {
51905178
return MacroWalking::Expansion;
51915179
}
@@ -5265,8 +5253,6 @@ static void diagnoseDeprecatedWritableKeyPath(const Expr *E,
52655253

52665254
bool shouldWalkCaptureInitializerExpressions() override { return true; }
52675255

5268-
bool shouldWalkIntoTapExpression() override { return false; }
5269-
52705256
MacroWalking getMacroWalkingBehavior() const override {
52715257
return MacroWalking::Expansion;
52725258
}
@@ -5561,8 +5547,6 @@ static void diagUnqualifiedAccessToMethodNamedSelf(const Expr *E,
55615547
return false;
55625548
}
55635549

5564-
bool shouldWalkIntoTapExpression() override { return false; }
5565-
55665550
MacroWalking getMacroWalkingBehavior() const override {
55675551
return MacroWalking::Expansion;
55685552
}
@@ -5722,8 +5706,6 @@ diagnoseDictionaryLiteralDuplicateKeyEntries(const Expr *E,
57225706
return false;
57235707
}
57245708

5725-
bool shouldWalkIntoTapExpression() override { return false; }
5726-
57275709
MacroWalking getMacroWalkingBehavior() const override {
57285710
return MacroWalking::Expansion;
57295711
}

lib/Sema/TypeCheckAvailability.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3232,8 +3232,6 @@ class ExprAvailabilityWalker : public ASTWalker {
32323232
return false;
32333233
}
32343234

3235-
bool shouldWalkIntoTapExpression() override { return false; }
3236-
32373235
MacroWalking getMacroWalkingBehavior() const override {
32383236
return MacroWalking::ArgumentsAndExpansion;
32393237
}

0 commit comments

Comments
 (0)