Commit Graph

1 Commits

Author SHA1 Message Date
Alex Hoppen
6085e1dca4 [CodeCompletion] Reset diagnostics when reusing an ASTContext for completion
The diagnosticc engine is keeping track of state which might modify parsing/typechecking behaviour. In the added test case the `fatalErrorOccurred` flag was during the first completion. The flag was still `true` for the second completion, causing parsing/typechecking to behave slightly differently. Because of this, the ExprRewriter failed when applying a constraint system solution, not properly cleaning up its `ExprStack`.

This PR tackles both issues:
1) Reset the `hadError` flags in the diagnostics engine
2) Clean up the `ExprRewriter`’s `ExprStack` when rewriting a target fails.

Either of these changes fixes the crash in the test case but I think both could manifest through different code paths in different scenarios.

Fixes rdar://76051976 [SR-14430]
2021-04-15 13:07:27 +02:00