diff options
author | Martin Odersky <odersky@gmail.com> | 2015-11-02 18:30:39 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2015-11-05 13:57:37 +0100 |
commit | a0fbe09d945b6b6ef1279e7d6f828bdd3b93cce2 (patch) | |
tree | 01d1ba063b9842dc519e5ae33ba9de224758db7a | |
parent | c16c7f6009c5c7255cf3768585c1115a82b5a38c (diff) | |
download | dotty-a0fbe09d945b6b6ef1279e7d6f828bdd3b93cce2.tar.gz dotty-a0fbe09d945b6b6ef1279e7d6f828bdd3b93cce2.tar.bz2 dotty-a0fbe09d945b6b6ef1279e7d6f828bdd3b93cce2.zip |
Add migration warnings
The idea is that whenever Dotty detects a migration problem under -language:Scala2,
it should issue a migration warning, so we know what needs to be rewritten.
-rw-r--r-- | src/dotty/tools/dotc/config/ScalaSettings.scala | 1 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/TypeComparer.scala | 4 | ||||
-rw-r--r-- | src/dotty/tools/dotc/reporting/Reporter.scala | 6 |
3 files changed, 10 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/config/ScalaSettings.scala b/src/dotty/tools/dotc/config/ScalaSettings.scala index 05fefc8b4..62b071372 100644 --- a/src/dotty/tools/dotc/config/ScalaSettings.scala +++ b/src/dotty/tools/dotc/config/ScalaSettings.scala @@ -18,6 +18,7 @@ class ScalaSettings extends Settings.SettingGroup { */ val dependencyfile = StringSetting("-dependencyfile", "file", "Set dependency tracking file.", ".scala_dependencies") val deprecation = BooleanSetting("-deprecation", "Emit warning and location for usages of deprecated APIs.") + val migration = BooleanSetting("-migration", "Emit warning and location for migration issues from Scala 2.") val encoding = StringSetting("-encoding", "encoding", "Specify character encoding used by source files.", Properties.sourceEncoding) val explaintypes = BooleanSetting("-explaintypes", "Explain type errors in more detail.") val feature = BooleanSetting("-feature", "Emit warning and location for usages of features that should be imported explicitly.") diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala index 684e9cbfd..d60828a21 100644 --- a/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/src/dotty/tools/dotc/core/TypeComparer.scala @@ -500,7 +500,9 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling { projection.name == tpnme.hkApply && !other.isHKApply && other.testLifted(projection.prefix.LambdaClass(forcing = true).typeParams, - if (inOrder) isSubType(projection.prefix, _) else isSubType(_, projection.prefix), + { xx => println(i"test lifted with $xx") + if (inOrder) isSubType(projection.prefix, xx) else isSubType(xx, projection.prefix) + }, if (inOrder) Nil else classBounds(projection.prefix)) /** The class symbols bounding the type of the `Apply` member of `tp` */ diff --git a/src/dotty/tools/dotc/reporting/Reporter.scala b/src/dotty/tools/dotc/reporting/Reporter.scala index 0358f71f6..4a72c2066 100644 --- a/src/dotty/tools/dotc/reporting/Reporter.scala +++ b/src/dotty/tools/dotc/reporting/Reporter.scala @@ -66,6 +66,9 @@ object Reporter { class DeprecationWarning(msgFn: => String, pos: SourcePosition) extends ConditionalWarning(msgFn, pos) { def enablingOption(implicit ctx: Context) = ctx.settings.deprecation } + class MigrationWarning(msgFn: => String, pos: SourcePosition) extends ConditionalWarning(msgFn, pos) { + def enablingOption(implicit ctx: Context) = ctx.settings.migration + } } import Reporter._ @@ -82,6 +85,9 @@ trait Reporting { this: Context => def deprecationWarning(msg: => String, pos: SourcePosition = NoSourcePosition): Unit = reporter.report(new DeprecationWarning(msg, pos)) + def migrationWarning(msg: => String, pos: SourcePosition = NoSourcePosition): Unit = + reporter.report(new MigrationWarning(msg, pos)) + def uncheckedWarning(msg: => String, pos: SourcePosition = NoSourcePosition): Unit = reporter.report(new UncheckedWarning(msg, pos)) |