scala/scala — pull request #2259 by Blaisorblade (2013-03-15 10:20:20+00:00)
Title: SI-6123: -explaintypes should not explain errors which won't be reported, new attempt

-explainTypes means that only type tests which fail should be reported in more
detail by using explainTypes. Hence, callers of explainTypes should check if
type errors are being ignored, by checking context.reportErrors. Hence, this
check is added to Inferencer, and another call site is redirected to that
method.

Note that this patch does not fix all occurrences, but only the ones which
showed up during debugging. The other ones never cause problems, maybe because
they occur when contextErrors is in fact guaranteed to be true. We might want to
fix those ones anyway.

Compared to the old request (https://github.com/scala/scala/pull/1940), I added some tests. However, these tests will become fully effective only once SI-7003 is finally fixed - right now there's no way of testing this, especially not of saying "for a compiling program, `-explaintypes` should add no extra output".

Review by @hubertp.
Refs #6123
backport to 2.10.x