[CFE/DDC] Fix leak caused by cached diagnosticReporter

In 8f4e5c8194 the `DiagnosticReporter` was cached in
`DevCompilerTarget` which introduced a memory leak.
Unfortunately our weekly bot that looks for leaks has been out of
commission, but is now coming back online.

This CL fixes the leak by overwriting the field every time, meaing we
don't save a reference to the first one (which is a leak).
Maybe ideally we shouldn't save it as a field at all, but that's a
potential for another day.

Change-Id: Ic740a212c436c475688a1de73c55a2344301e688
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/325260
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
This commit is contained in:
Jens Johansen 2023-09-12 06:11:28 +00:00 committed by Commit Queue
parent 5282f6e33f
commit cef9865586

View file

@ -179,7 +179,7 @@ class DevCompilerTarget extends Target {
{void Function(String msg)? logger,
ChangedStructureNotifier? changedStructureNotifier}) {
_nativeClasses ??= JsInteropChecks.getNativeClasses(component);
_diagnosticReporter ??=
_diagnosticReporter =
diagnosticReporter as DiagnosticReporter<Message, LocatedMessage>;
_performTransformations(coreTypes, hierarchy, libraries);
}