diff options
author | Martin Odersky <odersky@gmail.com> | 2015-03-13 17:44:04 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2015-03-13 17:45:03 +0100 |
commit | a56bc34fb850a6dca40c4f8562f3cb2d5b69dcc7 (patch) | |
tree | e9804c9402e33c35fb297bb6b03f456e7a472730 /src/dotty/tools/dotc/reporting/Reporter.scala | |
parent | 0ee93122b9e367c08ed1d81c9cfc5919fc3a32af (diff) | |
download | dotty-a56bc34fb850a6dca40c4f8562f3cb2d5b69dcc7.tar.gz dotty-a56bc34fb850a6dca40c4f8562f3cb2d5b69dcc7.tar.bz2 dotty-a56bc34fb850a6dca40c4f8562f3cb2d5b69dcc7.zip |
add/strict
Add -strict option to do some type checks that are encessary to ensure type soundness, but
are stricter than what Scala 2.x enforces.
The first such test is the "pattern cannot be uniquely instantiated" problem where we reject a
non-variant case subclass of a covariant superclass in a pattern match. The error is now only
issued in -struct mode, otherwise it will be a warning.
We might move more tests into the same category. This should help the transition.
Diffstat (limited to 'src/dotty/tools/dotc/reporting/Reporter.scala')
-rw-r--r-- | src/dotty/tools/dotc/reporting/Reporter.scala | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/reporting/Reporter.scala b/src/dotty/tools/dotc/reporting/Reporter.scala index 41f007e66..5bb660cdb 100644 --- a/src/dotty/tools/dotc/reporting/Reporter.scala +++ b/src/dotty/tools/dotc/reporting/Reporter.scala @@ -89,6 +89,10 @@ trait Reporting { this: Context => def warning(msg: => String, pos: SourcePosition = NoSourcePosition): Unit = reporter.report(new Warning(msg, pos)) + + def strictWarning(msg: => String, pos: SourcePosition = NoSourcePosition): Unit = + if (this.settings.strict.value) error(msg, pos) + else warning(msg + "\n(This would be an error under strict mode)", pos) def error(msg: => String, pos: SourcePosition = NoSourcePosition): Unit = { // println("*** ERROR: " + msg) // !!! DEBUG |