|
1 | 1 | package dotty.tools.dotc
|
2 | 2 | package config
|
3 | 3 |
|
| 4 | +import dotty.tools.dotc.config.PathResolver.Defaults |
| 5 | +import dotty.tools.dotc.config.Settings.{Setting, SettingGroup} |
4 | 6 | import dotty.tools.dotc.core.Contexts._
|
5 |
| -import dotty.tools.io.{ Directory, PlainDirectory, AbstractFile, JDK9Reflectors } |
6 |
| -import PathResolver.Defaults |
7 |
| -import rewrites.Rewrites |
8 |
| -import Settings.{ Setting, SettingGroup } |
| 7 | +import dotty.tools.dotc.rewrites.Rewrites |
| 8 | +import dotty.tools.io.{AbstractFile, Directory, JDK9Reflectors, PlainDirectory} |
| 9 | + |
| 10 | +import scala.util.chaining._ |
9 | 11 |
|
10 | 12 | class ScalaSettings extends SettingGroup with AllScalaSettings
|
11 | 13 |
|
@@ -51,7 +53,7 @@ trait AllScalaSettings extends CommonScalaSettings, VerboseSettings, WarningSett
|
51 | 53 | val explain: Setting[Boolean] = BooleanSetting("-explain", "Explain errors in more detail.", aliases = List("--explain"))
|
52 | 54 | val feature: Setting[Boolean] = BooleanSetting("-feature", "Emit warning and location for usages of features that should be imported explicitly.", aliases = List("--feature"))
|
53 | 55 | val source: Setting[String] = ChoiceSetting("-source", "source version", "source version", List("3.0", "future", "3.0-migration", "future-migration"), "3.0", aliases = List("--source"))
|
54 |
| - val unchecked: Setting[Boolean] = BooleanSetting("-unchecked", "Enable additional warnings where generated code depends on assumptions.", aliases = List("--unchecked")) |
| 56 | + val unchecked: Setting[Boolean] = BooleanSetting("-unchecked", "Enable additional warnings where generated code depends on assumptions.", initialValue = true, aliases = List("--unchecked")) |
55 | 57 | val uniqid: Setting[Boolean] = BooleanSetting("-uniqid", "Uniquely tag all identifiers in debugging output.", aliases = List("--unique-id"))
|
56 | 58 | val language: Setting[List[String]] = MultiStringSetting("-language", "feature", "Enable one or more language features.", aliases = List("--language"))
|
57 | 59 | val rewrite: Setting[Option[Rewrites]] = OptionSetting[Rewrites]("-rewrite", "When used in conjunction with a `...-migration` source version, rewrites sources to migrate to new version.", aliases = List("--rewrite"))
|
@@ -133,6 +135,64 @@ private sealed trait WarningSettings:
|
133 | 135 | val Whelp: Setting[Boolean] = BooleanSetting("-W", "Print a synopsis of warning options.")
|
134 | 136 | val XfatalWarnings: Setting[Boolean] = BooleanSetting("-Werror", "Fail the compilation if there are any warnings.", aliases = List("-Xfatal-warnings"))
|
135 | 137 |
|
| 138 | + val Wunused: Setting[List[String]] = MultiChoiceSetting( |
| 139 | + name = "-Wunused", |
| 140 | + helpArg = "warning", |
| 141 | + descr = "Enable or disable specific `unused` warnings", |
| 142 | + choices = List("nowarn", "all"), |
| 143 | + default = Nil |
| 144 | + ) |
| 145 | + object WunusedHas: |
| 146 | + def allOr(s: String)(using Context) = Wunused.value.pipe(us => us.contains("all") || us.contains(s)) |
| 147 | + def nowarn(using Context) = allOr("nowarn") |
| 148 | + |
| 149 | + val Wconf: Setting[List[String]] = MultiStringSetting( |
| 150 | + "-Wconf", |
| 151 | + "patterns", |
| 152 | + default = List(), |
| 153 | + descr = |
| 154 | + s"""Configure compiler warnings. |
| 155 | + |Syntax: -Wconf:<filters>:<action>,<filters>:<action>,... |
| 156 | + |multiple <filters> are combined with &, i.e., <filter>&...&<filter> |
| 157 | + | |
| 158 | + |<filter> |
| 159 | + | - Any message: any |
| 160 | + | |
| 161 | + | - Message categories: cat=deprecation, cat=feature, cat=unchecked |
| 162 | + | |
| 163 | + | - Message content: msg=regex |
| 164 | + | The regex need only match some part of the message, not all of it. |
| 165 | + | |
| 166 | + | - Message id: id=E129 |
| 167 | + | The message id is printed with the warning. |
| 168 | + | |
| 169 | + | - Message name: name=PureExpressionInStatementPosition |
| 170 | + | The message name is printed with the warning in verbose warning mode. |
| 171 | + | |
| 172 | + |In verbose warning mode the compiler prints matching filters for warnings. |
| 173 | + |Verbose mode can be enabled globally using `-Wconf:any:verbose`, or locally |
| 174 | + |using the @nowarn annotation (example: `@nowarn("v") def test = try 1`). |
| 175 | + | |
| 176 | + |<action> |
| 177 | + | - error / e |
| 178 | + | - warning / w |
| 179 | + | - verbose / v (emit warning, show additional help for writing `-Wconf` filters) |
| 180 | + | - info / i (infos are not counted as warnings and not affected by `-Werror`) |
| 181 | + | - silent / s |
| 182 | + | |
| 183 | + |The default configuration is empty. |
| 184 | + | |
| 185 | + |User-defined configurations are added to the left. The leftmost rule matching |
| 186 | + |a warning message defines the action. |
| 187 | + | |
| 188 | + |Examples: |
| 189 | + | - change every warning into an error: -Wconf:any:error |
| 190 | + | - silence deprecations: -Wconf:cat=deprecation:s |
| 191 | + | |
| 192 | + |Note: on the command-line you might need to quote configurations containing `*` or `&` |
| 193 | + |to prevent the shell from expanding patterns.""".stripMargin, |
| 194 | + ) |
| 195 | + |
136 | 196 | /** -X "Extended" or "Advanced" settings */
|
137 | 197 | private sealed trait XSettings:
|
138 | 198 | self: SettingGroup =>
|
|
0 commit comments