Skip to content

Commit d34a511

Browse files
committed
Merge pull request #409 from dotty-staging/add/strict
add/strict
2 parents 0ee9312 + a56bc34 commit d34a511

File tree

5 files changed

+6
-1
lines changed

5 files changed

+6
-1
lines changed

src/dotty/tools/dotc/config/ScalaSettings.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class ScalaSettings extends Settings.SettingGroup {
3939
val defines = PrefixSetting("-Dproperty=value", "-D", "Pass -Dproperty=value directly to the runtime system.")
4040
val toolcp = PathSetting("-toolcp", "Add to the runner classpath.", "")
4141
val nobootcp = BooleanSetting("-nobootcp", "Do not use the boot classpath for the scala jars.")
42+
val strict = BooleanSetting("-strict", "Use strict type rules, which means some formerly legal code does not typecheck anymore.")
4243

4344
val argfiles = BooleanSetting("@<file>", "A text file containing compiler arguments (options and source files)")
4445
val classpath = PathSetting("-classpath", "Specify where to find user class files.", defaultClasspath) withAbbreviation "-cp"

src/dotty/tools/dotc/reporting/Reporter.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ trait Reporting { this: Context =>
8989

9090
def warning(msg: => String, pos: SourcePosition = NoSourcePosition): Unit =
9191
reporter.report(new Warning(msg, pos))
92+
93+
def strictWarning(msg: => String, pos: SourcePosition = NoSourcePosition): Unit =
94+
if (this.settings.strict.value) error(msg, pos)
95+
else warning(msg + "\n(This would be an error under strict mode)", pos)
9296

9397
def error(msg: => String, pos: SourcePosition = NoSourcePosition): Unit = {
9498
// println("*** ERROR: " + msg) // !!! DEBUG

src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ trait Applications extends Compatibility { self: Typer =>
716716
if (ctx.settings.verbose.value) ctx.warning(msg, tree.pos)
717717
} else {
718718
unapp.println(s" ${unapplyFn.symbol.owner} ${unapplyFn.symbol.owner is Scala2x}")
719-
ctx.error(msg, tree.pos)
719+
ctx.strictWarning(msg, tree.pos)
720720
}
721721
case _ =>
722722
}
File renamed without changes.

0 commit comments

Comments
 (0)