This package has two different mechanisms that can cause an existing
diagnostic to be replaced with a modified version:
- "Override" effectively wraps an arbitrary other diagnostic with a new
severity and optional new "extra info".
- Contextual diagnostics allow a diagnostic to be created in one place
with some incomplete information, and then "elaborated" in another place
where more information is available.
Those two mechanisms did not previously interact well together: passing
a contextual diagnostic to Override would prevent its elaboration process
from taking effect.
Now the overriddenDiagnostic type -- implementation detail of "Override" --
implements the same unexported interface that the contextual diagnostics
do, and delegates the elaboration request to the diagnostic that it's
wrapping so that the elaboration can take effect while still preserving
the effect of the overrides.
This combination is okay because in practice "override" only affects
Severity and ExtraInfo, while contextual diagnostics today only affect
the source location information and the "address" components of the
diagnostic, so the two can work independently of one another.
Signed-off-by: Martin Atkins <mart@degeneration.co.uk>