Skip to content

Commit 9b45f99

Browse files
committed
Bring back -exlain-types
Need to keep it for cross compilation.
1 parent b501cbe commit 9b45f99

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@ class ScalaSettings extends Settings.SettingGroup with CommonScalaSettings {
103103
val semanticdbTarget: Setting[String] = PathSetting("-semanticdb-target", "Specify an alternative output directory for SemanticDB files.", "")
104104

105105
val deprecation: Setting[Boolean] = BooleanSetting("-deprecation", "Emit warning and location for usages of deprecated APIs.", aliases = List("--deprecation"))
106-
val explain: Setting[Boolean] = BooleanSetting("-explain", "Explain errors in more detail.", aliases = List("--explain", "-explain-types", "--explain-types"))
106+
val explainTypes: Setting[Boolean] = BooleanSetting("-explain-types", "Explain type errors in more detail (deprecated, use -explain instead).", aliases = List("--explain-types"))
107+
// this setting is necessary for cross compilation, since it is mentioned in sbt-tpolecat, for instance
108+
// it is otherwise subsumed by -explain, and should be dropped as soon as we can.
109+
val explain: Setting[Boolean] = BooleanSetting("-explain", "Explain errors in more detail.", aliases = List("--explain"))
107110
val feature: Setting[Boolean] = BooleanSetting("-feature", "Emit warning and location for usages of features that should be imported explicitly.", aliases = List("--feature"))
108111
val release: Setting[String] = ChoiceSetting("-release", "release", "Compile code with classes specific to the given version of the Java platform available on the classpath and emit bytecode for this version.", supportedReleaseVersions, "", aliases = List("--release"))
109112
val source: Setting[String] = ChoiceSetting("-source", "source version", "source version", List("3.0", "future", "3.0-migration", "future-migration"), "3.0", aliases = List("--source"))

compiler/src/dotty/tools/dotc/reporting/Diagnostic.scala

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ object Diagnostic:
1313

1414
def shouldExplain(dia: Diagnostic)(using Context): Boolean =
1515
ctx.settings.explain.value && dia.msg.canExplain
16+
|| ctx.settings.explainTypes.value && dia.msg.isInstanceOf[TypeMismatchMsg]
17+
// keep old explain-types behavior for backwards compatibility and cross-compilation
1618

1719
// `Diagnostics to be consumed by `Reporter` ---------------------- //
1820
class Error(

0 commit comments

Comments
 (0)