Skip to content

Commit 6d01bdd

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 96eeb57 commit 6d01bdd

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
@@ -349,14 +349,7 @@ void swift::diagnoseConstantArgumentRequirement(
349349
return walkToClosureExprPre(closureExpr);
350350
}
351351

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

lib/Sema/MiscDiagnostics.cpp

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

130130
bool shouldWalkCaptureInitializerExpressions() override { return true; }
131131

132-
bool shouldWalkIntoTapExpression() override { return false; }
133-
134132
PreWalkResult<Expr *> walkToExprPre(Expr *E) override {
135133
if (auto collection = dyn_cast<CollectionExpr>(E)) {
136134
if (collection->isTypeDefaulted()) {
@@ -1408,8 +1406,6 @@ static void diagRecursivePropertyAccess(const Expr *E, const DeclContext *DC) {
14081406

14091407
bool shouldWalkCaptureInitializerExpressions() override { return true; }
14101408

1411-
bool shouldWalkIntoTapExpression() override { return false; }
1412-
14131409
PreWalkResult<Expr *> walkToExprPre(Expr *E) override {
14141410
Expr *subExpr;
14151411
bool isStore = false;
@@ -1705,8 +1701,6 @@ static void diagnoseImplicitSelfUseInClosure(const Expr *E,
17051701

17061702
bool shouldWalkCaptureInitializerExpressions() override { return true; }
17071703

1708-
bool shouldWalkIntoTapExpression() override { return false; }
1709-
17101704
PreWalkResult<Expr *> walkToExprPre(Expr *E) override {
17111705
if (auto *CE = dyn_cast<AbstractClosureExpr>(E)) {
17121706
// If this is a potentially-escaping closure expression, start looking
@@ -3952,8 +3946,6 @@ static void checkStmtConditionTrailingClosure(ASTContext &ctx, const Expr *E) {
39523946

39533947
bool shouldWalkCaptureInitializerExpressions() override { return true; }
39543948

3955-
bool shouldWalkIntoTapExpression() override { return false; }
3956-
39573949
PreWalkResult<ArgumentList *>
39583950
walkToArgumentListPre(ArgumentList *args) override {
39593951
// Don't walk into an explicit argument list, as trailing closures that
@@ -4078,8 +4070,6 @@ class ObjCSelectorWalker : public ASTWalker {
40784070

40794071
bool shouldWalkCaptureInitializerExpressions() override { return true; }
40804072

4081-
bool shouldWalkIntoTapExpression() override { return false; }
4082-
40834073
PreWalkResult<Expr *> walkToExprPre(Expr *expr) override {
40844074
auto *stringLiteral = dyn_cast<StringLiteralExpr>(expr);
40854075
bool fromStringLiteral = false;
@@ -4900,8 +4890,6 @@ static void diagnoseUnintendedOptionalBehavior(const Expr *E,
49004890

49014891
bool shouldWalkCaptureInitializerExpressions() override { return true; }
49024892

4903-
bool shouldWalkIntoTapExpression() override { return false; }
4904-
49054893
PreWalkResult<Expr *> walkToExprPre(Expr *E) override {
49064894
if (!E || isa<ErrorExpr>(E) || !E->getType())
49074895
return Action::SkipChildren(E);
@@ -4977,8 +4965,6 @@ static void diagnoseDeprecatedWritableKeyPath(const Expr *E,
49774965

49784966
bool shouldWalkCaptureInitializerExpressions() override { return true; }
49794967

4980-
bool shouldWalkIntoTapExpression() override { return false; }
4981-
49824968
PreWalkResult<Expr *> walkToExprPre(Expr *E) override {
49834969
if (!E || isa<ErrorExpr>(E) || !E->getType())
49844970
return Action::SkipChildren(E);
@@ -5257,8 +5243,6 @@ static void diagUnqualifiedAccessToMethodNamedSelf(const Expr *E,
52575243
return false;
52585244
}
52595245

5260-
bool shouldWalkIntoTapExpression() override { return false; }
5261-
52625246
PreWalkResult<Expr *> walkToExprPre(Expr *E) override {
52635247
if (!E || isa<ErrorExpr>(E) || !E->getType())
52645248
return Action::SkipChildren(E);
@@ -5414,8 +5398,6 @@ diagnoseDictionaryLiteralDuplicateKeyEntries(const Expr *E,
54145398
return false;
54155399
}
54165400

5417-
bool shouldWalkIntoTapExpression() override { return false; }
5418-
54195401
PreWalkResult<Expr *> walkToExprPre(Expr *E) override {
54205402
const auto *DLE = dyn_cast_or_null<DictionaryExpr>(E);
54215403
if (!DLE)

lib/Sema/TypeCheckAvailability.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3215,8 +3215,6 @@ class ExprAvailabilityWalker : public ASTWalker {
32153215
return false;
32163216
}
32173217

3218-
bool shouldWalkIntoTapExpression() override { return false; }
3219-
32203218
PreWalkResult<Expr *> walkToExprPre(Expr *E) override {
32213219
auto *DC = Where.getDeclContext();
32223220

0 commit comments

Comments
 (0)