Skip to content

Commit 773513a

Browse files
xedinahoppen
authored andcommitted
[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 60fa909 commit 773513a

File tree

4 files changed

+1
-30
lines changed

4 files changed

+1
-30
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
@@ -134,8 +134,6 @@ static void diagSyntacticUseRestrictions(const Expr *E, const DeclContext *DC,
134134

135135
bool shouldWalkCaptureInitializerExpressions() override { return true; }
136136

137-
bool shouldWalkIntoTapExpression() override { return false; }
138-
139137
PreWalkResult<Expr *> walkToExprPre(Expr *E) override {
140138
// See through implicit conversions of the expression. We want to be able
141139
// to associate the parent of this expression with the ultimate callee.
@@ -1482,8 +1480,6 @@ static void diagRecursivePropertyAccess(const Expr *E, const DeclContext *DC) {
14821480

14831481
bool shouldWalkCaptureInitializerExpressions() override { return true; }
14841482

1485-
bool shouldWalkIntoTapExpression() override { return false; }
1486-
14871483
MacroWalking getMacroWalkingBehavior() const override {
14881484
return MacroWalking::Expansion;
14891485
}
@@ -1774,8 +1770,6 @@ static void diagnoseImplicitSelfUseInClosure(const Expr *E,
17741770

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

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

42464240
bool shouldWalkCaptureInitializerExpressions() override { return true; }
42474241

4248-
bool shouldWalkIntoTapExpression() override { return false; }
4249-
42504242
MacroWalking getMacroWalkingBehavior() const override {
42514243
return MacroWalking::Expansion;
42524244
}
@@ -4376,8 +4368,6 @@ class ObjCSelectorWalker : public ASTWalker {
43764368

43774369
bool shouldWalkCaptureInitializerExpressions() override { return true; }
43784370

4379-
bool shouldWalkIntoTapExpression() override { return false; }
4380-
43814371
MacroWalking getMacroWalkingBehavior() const override {
43824372
return MacroWalking::Expansion;
43834373
}
@@ -5240,8 +5230,6 @@ static void diagnoseUnintendedOptionalBehavior(const Expr *E,
52405230

52415231
bool shouldWalkCaptureInitializerExpressions() override { return true; }
52425232

5243-
bool shouldWalkIntoTapExpression() override { return false; }
5244-
52455233
MacroWalking getMacroWalkingBehavior() const override {
52465234
return MacroWalking::Expansion;
52475235
}
@@ -5321,8 +5309,6 @@ static void diagnoseDeprecatedWritableKeyPath(const Expr *E,
53215309

53225310
bool shouldWalkCaptureInitializerExpressions() override { return true; }
53235311

5324-
bool shouldWalkIntoTapExpression() override { return false; }
5325-
53265312
MacroWalking getMacroWalkingBehavior() const override {
53275313
return MacroWalking::Expansion;
53285314
}
@@ -5617,8 +5603,6 @@ static void diagUnqualifiedAccessToMethodNamedSelf(const Expr *E,
56175603
return false;
56185604
}
56195605

5620-
bool shouldWalkIntoTapExpression() override { return false; }
5621-
56225606
MacroWalking getMacroWalkingBehavior() const override {
56235607
return MacroWalking::Expansion;
56245608
}
@@ -5778,8 +5762,6 @@ diagnoseDictionaryLiteralDuplicateKeyEntries(const Expr *E,
57785762
return false;
57795763
}
57805764

5781-
bool shouldWalkIntoTapExpression() override { return false; }
5782-
57835765
MacroWalking getMacroWalkingBehavior() const override {
57845766
return MacroWalking::Expansion;
57855767
}

lib/Sema/TypeCheckAvailability.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3191,8 +3191,6 @@ class ExprAvailabilityWalker : public ASTWalker {
31913191
return false;
31923192
}
31933193

3194-
bool shouldWalkIntoTapExpression() override { return false; }
3195-
31963194
MacroWalking getMacroWalkingBehavior() const override {
31973195
// Expanded source should be type checked and diagnosed separately.
31983196
return MacroWalking::Arguments;

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2156,8 +2156,6 @@ namespace {
21562156

21572157
bool shouldWalkCaptureInitializerExpressions() override { return true; }
21582158

2159-
bool shouldWalkIntoTapExpression() override { return true; }
2160-
21612159
MacroWalking getMacroWalkingBehavior() const override {
21622160
return MacroWalking::Expansion;
21632161
}

0 commit comments

Comments
 (0)