Skip to content

Commit 6695006

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 deb211a commit 6695006

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
@@ -132,8 +132,6 @@ static void diagSyntacticUseRestrictions(const Expr *E, const DeclContext *DC,
132132

133133
bool shouldWalkCaptureInitializerExpressions() override { return true; }
134134

135-
bool shouldWalkIntoTapExpression() override { return false; }
136-
137135
PreWalkResult<Expr *> walkToExprPre(Expr *E) override {
138136
if (auto collection = dyn_cast<CollectionExpr>(E)) {
139137
if (collection->isTypeDefaulted()) {
@@ -1459,8 +1457,6 @@ static void diagRecursivePropertyAccess(const Expr *E, const DeclContext *DC) {
14591457

14601458
bool shouldWalkCaptureInitializerExpressions() override { return true; }
14611459

1462-
bool shouldWalkIntoTapExpression() override { return false; }
1463-
14641460
PreWalkResult<Expr *> walkToExprPre(Expr *E) override {
14651461
Expr *subExpr;
14661462
bool isStore = false;
@@ -1756,8 +1752,6 @@ static void diagnoseImplicitSelfUseInClosure(const Expr *E,
17561752

17571753
bool shouldWalkCaptureInitializerExpressions() override { return true; }
17581754

1759-
bool shouldWalkIntoTapExpression() override { return false; }
1760-
17611755
PreWalkResult<Expr *> walkToExprPre(Expr *E) override {
17621756
if (auto *CE = dyn_cast<AbstractClosureExpr>(E)) {
17631757
// If this is a potentially-escaping closure expression, start looking
@@ -4154,8 +4148,6 @@ static void checkStmtConditionTrailingClosure(ASTContext &ctx, const Expr *E) {
41544148

41554149
bool shouldWalkCaptureInitializerExpressions() override { return true; }
41564150

4157-
bool shouldWalkIntoTapExpression() override { return false; }
4158-
41594151
PreWalkResult<ArgumentList *>
41604152
walkToArgumentListPre(ArgumentList *args) override {
41614153
// Don't walk into an explicit argument list, as trailing closures that
@@ -4280,8 +4272,6 @@ class ObjCSelectorWalker : public ASTWalker {
42804272

42814273
bool shouldWalkCaptureInitializerExpressions() override { return true; }
42824274

4283-
bool shouldWalkIntoTapExpression() override { return false; }
4284-
42854275
PreWalkResult<Expr *> walkToExprPre(Expr *expr) override {
42864276
auto *stringLiteral = dyn_cast<StringLiteralExpr>(expr);
42874277
bool fromStringLiteral = false;
@@ -5137,8 +5127,6 @@ static void diagnoseUnintendedOptionalBehavior(const Expr *E,
51375127

51385128
bool shouldWalkCaptureInitializerExpressions() override { return true; }
51395129

5140-
bool shouldWalkIntoTapExpression() override { return false; }
5141-
51425130
PreWalkResult<Expr *> walkToExprPre(Expr *E) override {
51435131
if (!E || isa<ErrorExpr>(E) || !E->getType())
51445132
return Action::SkipChildren(E);
@@ -5214,8 +5202,6 @@ static void diagnoseDeprecatedWritableKeyPath(const Expr *E,
52145202

52155203
bool shouldWalkCaptureInitializerExpressions() override { return true; }
52165204

5217-
bool shouldWalkIntoTapExpression() override { return false; }
5218-
52195205
PreWalkResult<Expr *> walkToExprPre(Expr *E) override {
52205206
if (!E || isa<ErrorExpr>(E) || !E->getType())
52215207
return Action::SkipChildren(E);
@@ -5494,8 +5480,6 @@ static void diagUnqualifiedAccessToMethodNamedSelf(const Expr *E,
54945480
return false;
54955481
}
54965482

5497-
bool shouldWalkIntoTapExpression() override { return false; }
5498-
54995483
PreWalkResult<Expr *> walkToExprPre(Expr *E) override {
55005484
if (!E || isa<ErrorExpr>(E) || !E->getType())
55015485
return Action::SkipChildren(E);
@@ -5651,8 +5635,6 @@ diagnoseDictionaryLiteralDuplicateKeyEntries(const Expr *E,
56515635
return false;
56525636
}
56535637

5654-
bool shouldWalkIntoTapExpression() override { return false; }
5655-
56565638
PreWalkResult<Expr *> walkToExprPre(Expr *E) override {
56575639
const auto *DLE = dyn_cast_or_null<DictionaryExpr>(E);
56585640
if (!DLE)

lib/Sema/TypeCheckAvailability.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3223,8 +3223,6 @@ class ExprAvailabilityWalker : public ASTWalker {
32233223
return false;
32243224
}
32253225

3226-
bool shouldWalkIntoTapExpression() override { return false; }
3227-
32283226
PreWalkResult<Expr *> walkToExprPre(Expr *E) override {
32293227
auto *DC = Where.getDeclContext();
32303228

0 commit comments

Comments
 (0)