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