lampepfl/dotty — pull request #92 by samuelgruetter (2014-03-24 18:12:34+00:00)
Title: Error-specific Diagnostics subclasses

As suggested in this [Google Groups Thread](https://groups.google.com/forum/#!topic/dotty-internals/hwmRqMBe2YQ), this is an attempt to introduce specific error classes for each kind of error, instead of having String as the universal datatype.

There are many advantages:
* Testing doesn't need to regex-match error messages, but can test the error message type, and its fields, if desired. Changing the wording of an error message doesn't require updating of many tests.
* We can also write better unit tests which just check for the type of error.
* Once the error classes stabilize, we can expose them to external tools, such as IDEs, type debuggers, etc, and they will benefit a lot.

This PR is only a small stub, and I invite everyone to give feedback and to help find the right way to do it.

There are still many things to do:

* Replace all `ctx.error(string, pos)` calls by `ctx.report(diagnostics)`, same for `ctx.warning`
* Integrate TypeError, FatalTypeError, MalformedType, CyclicReference, MergeError in Types.scala
* Currently, the logic which generates the error messages is spread over the whole compiler. Move it into dotty.tools.dotc.reporting.
* Once all is moved, it should be possible to make the suppressed messages communication between Diagnostics and the i String interpolator (InfoString) nicer. Currently, it's based on a mutable field suppressNonSensicalErrors in ContextBase and on throwing/catching SuppressedMessage exceptions. Decouple Diagnostics from ContextBase, so that it becomes a minimal data structure with a small API that we can expose to other tools.
* Probably we will also be able to remove Severity, and just encode the severity in the class names.

/cc @adriaanm