@@ -1251,6 +1251,7 @@ class ApplyClassifier {
12511251 Classification classification;
12521252 PotentialEffectReason reason = PotentialEffectReason::forPropertyAccess ();
12531253 ConcreteDeclRef declRef = E->getDeclRef ();
1254+
12541255 if (auto getter = getEffectfulGetOnlyAccessor (declRef)) {
12551256 reason = getKindOfEffectfulProp (declRef);
12561257 classification = Classification::forDeclRef (
@@ -2018,7 +2019,7 @@ class ApplyClassifier {
20182019 // / Given the type of an argument, try to determine if it contains
20192020 // / a throws/async function in a way that is permitted to cause a
20202021 // / rethrows/reasync function to throw/async.
2021- static Classification
2022+ static Classification
20222023 classifyArgumentByType (Type paramType, SubstitutionMap subs,
20232024 ConditionalEffectKind conditional,
20242025 PotentialEffectReason reason, EffectKind kind) {
@@ -2663,12 +2664,20 @@ class Context {
26632664 }
26642665
26652666 // / providing a \c kind helps tailor the emitted message.
2666- void
2667- diagnoseUnhandledAsyncSite (DiagnosticEngine &Diags, ASTNode node,
2667+ void diagnoseUnhandledAsyncSite (DiagnosticEngine &Diags, ASTNode node,
26682668 std::optional<PotentialEffectReason> maybeReason,
26692669 bool forAwait = false ) {
2670- if (node.isImplicit ())
2670+ if (node.isImplicit ()) {
2671+ // The reason we return early on implicit nodes is that sometimes we
2672+ // inject implicit closures, e.g. in 'async let' and we'd end up
2673+ // "double reporting" some errors, with no great way to make sure the
2674+ // "more specific diagnostic" is emitted. So instead, we avoid emitting
2675+ // about implicit code.
2676+ //
2677+ // Some synthesized code, like macros, are NOT marked implicit, so we will
2678+ // report about errors in them properly.
26712679 return ;
2680+ }
26722681
26732682 switch (getKind ()) {
26742683 case Kind::PotentiallyHandled: {
@@ -2691,6 +2700,7 @@ class Context {
26912700 return ;
26922701 }
26932702 }
2703+
26942704};
26952705
26962706// / A class to walk over a local context and validate the correctness
@@ -2723,13 +2733,13 @@ class CheckEffectsCoverage : public EffectsHandlingWalker<CheckEffectsCoverage>
27232733
27242734 // / Do we have a throw site using 'try' in this context?
27252735 HasTryThrowSite = 0x10 ,
2726-
2736+
27272737 // / Are we in the context of an 'await'?
27282738 IsAsyncCovered = 0x20 ,
2729-
2739+
27302740 // / Do we have any calls to 'async' functions in this context?
27312741 HasAnyAsyncSite = 0x40 ,
2732-
2742+
27332743 // / Do we have any 'await's in this context?
27342744 HasAnyAwait = 0x80 ,
27352745
@@ -3293,7 +3303,7 @@ class CheckEffectsCoverage : public EffectsHandlingWalker<CheckEffectsCoverage>
32933303 CEC.Flags .set (ContextFlags::HasAnyThrowSite);
32943304 return Action::Continue (E);
32953305 }
3296-
3306+
32973307 PostWalkResult<Stmt *> walkToStmtPost (Stmt *S) override {
32983308 if (isa<ThrowStmt>(S))
32993309 CEC.Flags .set (ContextFlags::HasAnyThrowSite);
@@ -3305,7 +3315,7 @@ class CheckEffectsCoverage : public EffectsHandlingWalker<CheckEffectsCoverage>
33053315 for (auto &clause : ICD->getClauses ()) {
33063316 // Active clauses are handled by the normal AST walk.
33073317 if (clause.isActive ) continue ;
3308-
3318+
33093319 for (auto elt : clause.Elements )
33103320 elt.walk (ConservativeThrowChecker (*this ));
33113321 }
0 commit comments