@@ -1173,12 +1173,7 @@ class ApplyClassifier {
1173
1173
1174
1174
ShouldRecurse_t checkForEach (ForEachStmt *S) {
1175
1175
if (S->getAwaitLoc ().isValid ()) {
1176
- auto classification = Self.classifyConformance (
1177
- S->getSequenceConformance (),
1178
- EffectKind::Async);
1179
- IsInvalid |= classification.isInvalid ();
1180
- AsyncKind = std::max (AsyncKind,
1181
- classification.getConditionalKind (EffectKind::Async));
1176
+ AsyncKind = std::max (AsyncKind, ConditionalEffectKind::Always);
1182
1177
}
1183
1178
1184
1179
return ShouldRecurse;
@@ -2735,10 +2730,19 @@ class CheckEffectsCoverage : public EffectsHandlingWalker<CheckEffectsCoverage>
2735
2730
if (!S->getAwaitLoc ().isValid ())
2736
2731
return ShouldRecurse;
2737
2732
2733
+ // A 'for await' is always async. There's no effect polymorphism
2734
+ // via the conformance in a 'reasync' function body.
2735
+ Flags.set (ContextFlags::HasAnyAsyncSite);
2736
+
2737
+ if (!CurContext.handlesAsync (ConditionalEffectKind::Always))
2738
+ CurContext.diagnoseUnhandledAsyncSite (Ctx.Diags , S, None);
2739
+
2738
2740
ApplyClassifier classifier;
2739
2741
classifier.RethrowsDC = RethrowsDC;
2740
2742
classifier.ReasyncDC = ReasyncDC;
2741
2743
2744
+ // A 'for try await' might be effect polymorphic via the conformance
2745
+ // in a 'rethrows' function body.
2742
2746
if (S->getTryLoc ().isValid ()) {
2743
2747
auto classification = classifier.classifyConformance (
2744
2748
S->getSequenceConformance (), EffectKind::Throws);
@@ -2751,16 +2755,6 @@ class CheckEffectsCoverage : public EffectsHandlingWalker<CheckEffectsCoverage>
2751
2755
CurContext.diagnoseUnhandledThrowStmt (Ctx.Diags , S);
2752
2756
}
2753
2757
2754
- auto classification = classifier.classifyConformance (
2755
- S->getSequenceConformance (), EffectKind::Async);
2756
- auto asyncKind = classification.getConditionalKind (EffectKind::Async);
2757
-
2758
- if (asyncKind != ConditionalEffectKind::None)
2759
- Flags.set (ContextFlags::HasAnyAsyncSite);
2760
-
2761
- if (!CurContext.handlesAsync (asyncKind))
2762
- CurContext.diagnoseUnhandledAsyncSite (Ctx.Diags , S, None);
2763
-
2764
2758
return ShouldRecurse;
2765
2759
}
2766
2760
};
0 commit comments