@@ -1584,10 +1584,22 @@ class CheckEffectsCoverage : public EffectsHandlingWalker<CheckEffectsCoverage>
1584
1584
OldMaxThrowingKind = std::max (OldMaxThrowingKind, Self.MaxThrowingKind );
1585
1585
}
1586
1586
1587
+ void preserveDiagnoseErrorOnTryFlag () {
1588
+ // The "DiagnoseErrorOnTry" flag is a bit of mutable state
1589
+ // in the Context itself, used to postpone diagnostic emission
1590
+ // to a parent "try" expression. If something was diagnosed
1591
+ // during this ContextScope, the flag may have been set, and
1592
+ // we need to preseve its value when restoring the old Context.
1593
+ bool DiagnoseErrorOnTry = Self.CurContext .shouldDiagnoseErrorOnTry ();
1594
+ OldContext.setDiagnoseErrorOnTry (DiagnoseErrorOnTry);
1595
+ }
1596
+
1587
1597
void preserveCoverageFromAwaitOperand () {
1588
1598
OldFlags.mergeFrom (ContextFlags::HasAnyAwait, Self.Flags );
1589
1599
OldFlags.mergeFrom (ContextFlags::throwFlags (), Self.Flags );
1590
1600
OldMaxThrowingKind = std::max (OldMaxThrowingKind, Self.MaxThrowingKind );
1601
+
1602
+ preserveDiagnoseErrorOnTryFlag ();
1591
1603
}
1592
1604
1593
1605
void preserveCoverageFromTryOperand () {
@@ -1606,22 +1618,16 @@ class CheckEffectsCoverage : public EffectsHandlingWalker<CheckEffectsCoverage>
1606
1618
OldFlags.mergeFrom (ContextFlags::HasAnyAsyncSite, Self.Flags );
1607
1619
OldFlags.mergeFrom (ContextFlags::HasAnyAwait, Self.Flags );
1608
1620
OldMaxThrowingKind = std::max (OldMaxThrowingKind, Self.MaxThrowingKind );
1621
+
1622
+ preserveDiagnoseErrorOnTryFlag ();
1609
1623
}
1610
1624
1611
1625
bool wasTopLevelDebuggerFunction () const {
1612
1626
return OldFlags.has (ContextFlags::IsTopLevelDebuggerFunction);
1613
1627
}
1614
1628
1615
1629
~ContextScope () {
1616
- // The "DiagnoseErrorOnTry" flag is a bit of mutable state
1617
- // in the Context itself, used to postpone diagnostic emission
1618
- // to a parent "try" expression. If something was diagnosed
1619
- // during this ContextScope, the flag may have been set, and
1620
- // we need to preseve its value when restoring the old Context.
1621
- bool DiagnoseErrorOnTry = Self.CurContext .shouldDiagnoseErrorOnTry ();
1622
1630
Self.CurContext = OldContext;
1623
- Self.CurContext .setDiagnoseErrorOnTry (DiagnoseErrorOnTry);
1624
-
1625
1631
Self.RethrowsDC = OldRethrowsDC;
1626
1632
Self.Flags = OldFlags;
1627
1633
Self.MaxThrowingKind = OldMaxThrowingKind;
0 commit comments