Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions compiler/src/dotty/tools/dotc/config/ScalaSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ private sealed trait PluginSettings:
private sealed trait VerboseSettings:
self: SettingGroup =>
val Vhelp: Setting[Boolean] = BooleanSetting(VerboseSetting, "V", "Print a synopsis of verbose options.")
val Vprint: Setting[List[String]] = PhasesSetting(VerboseSetting, "Vprint", "Print out program after", aliases = List("-Xprint"))
val XshowPhases: Setting[Boolean] = BooleanSetting(VerboseSetting, "Vphases", "List compiler phases.", aliases = List("-Xshow-phases"))
val Vprint: Setting[List[String]] = PhasesSetting(VerboseSetting, "Vprint", "Print out program after", deprecatedAliases = List("-Xprint" -> Deprecation()))
val XshowPhases: Setting[Boolean] = BooleanSetting(VerboseSetting, "Vphases", "List compiler phases.", deprecatedAliases = List("-Xshow-phases" -> Deprecation()))

val Vprofile: Setting[Boolean] = BooleanSetting(VerboseSetting, "Vprofile", "Show metrics about sources and internal representations to estimate compile-time complexity.")
val VprofileSortedBy = ChoiceSetting(VerboseSetting, "Vprofile-sorted-by", "key", "Show metrics about sources and internal representations sorted by given column name", List("name", "path", "lines", "tokens", "tasty", "complexity"), "")
Expand All @@ -161,7 +161,7 @@ private sealed trait WarningSettings:
self: SettingGroup =>

val Whelp: Setting[Boolean] = BooleanSetting(WarningSetting, "W", "Print a synopsis of warning options.")
val Werror: Setting[Boolean] = BooleanSetting(WarningSetting, "Werror", "Fail the compilation if there are any warnings.", aliases = List("-Xfatal-warnings"))
val Werror: Setting[Boolean] = BooleanSetting(WarningSetting, "Werror", "Fail the compilation if there are any warnings.", deprecatedAliases = List("-Xfatal-warnings" -> Deprecation()))
val Wall: Setting[Boolean] = BooleanSetting(WarningSetting, "Wall", "Enable all warning settings.")
private val WvalueDiscard: Setting[Boolean] = BooleanSetting(WarningSetting, "Wvalue-discard", "Warn when non-Unit expression results are unused.")
private val WNonUnitStatement = BooleanSetting(WarningSetting, "Wnonunit-statement", "Warn when block statements are non-Unit expressions.")
Expand Down
91 changes: 55 additions & 36 deletions compiler/src/dotty/tools/dotc/config/Settings.scala

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/reporting/Reporter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ abstract class Reporter extends interfaces.ReporterResult {

def finalizeReporting()(using Context) =
if (hasWarnings && ctx.settings.Werror.value)
report(new Error("No warnings can be incurred under -Werror (or -Xfatal-warnings)", NoSourcePosition))
report(new Error("No warnings can be incurred under -Werror", NoSourcePosition))

/** Summary of warnings and errors */
def summary: String =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,4 +306,12 @@ class ScalaSettingsTests:
assertEquals(0, result.warnings.length)
assertEquals(1, result.errors.length)

@Test def `deprecated aliases warn`: Unit =
val settings = ScalaSettings
val args = "-Xfatal-warnings" :: "-Xprint" :: "typer" :: Nil
val result = settings.processArguments(args, processAll = true)
assertEquals(2, result.warnings.length)
assertEquals("Option -Xfatal-warnings is a deprecated alias: use -Werror instead", result.warnings.head)
assertEquals(0, result.errors.length)

end ScalaSettingsTests
6 changes: 3 additions & 3 deletions repl/test-resources/repl/rewrite-messages
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ scala> import scala.util._
1 | import scala.util._
| ^
| `_` is no longer supported for a wildcard import; use `*` instead
No warnings can be incurred under -Werror (or -Xfatal-warnings)
No warnings can be incurred under -Werror
1 warning found
1 error found
scala> extension (x: Int) def foo(y: Int) = x + y
Expand All @@ -15,6 +15,6 @@ scala> 2 foo 4
| ^^^
|Alphanumeric method foo is not declared infix; it should not be used as infix operator.
|Instead, use method syntax .foo(...) or backticked identifier `foo`.
No warnings can be incurred under -Werror (or -Xfatal-warnings)
No warnings can be incurred under -Werror
1 warning found
1 error found
1 error found
Original file line number Diff line number Diff line change
@@ -1 +1 @@
scalac.options = -Xfatal-warnings
scalac.options = -Werror
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ object DottyInjectedPlugin extends AutoPlugin {

override val projectSettings = Seq(
scalaVersion := sys.props("plugin.scalaVersion"),
scalacOptions ++= Seq("-source:3.0-migration", "-Xfatal-warnings")
scalacOptions ++= Seq("-source:3.0-migration", "-Werror")
)
}
4 changes: 2 additions & 2 deletions sbt-test/source-dependencies/sealed/test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
> 'set scalacOptions += "-Xfatal-warnings"'
> 'set scalacOptions += "-Werror"'

> compile

Expand All @@ -8,4 +8,4 @@ $ copy-file changes/A.scala A.scala
# D.scala needs recompiling because the pattern match in D
# is no longer exhaustive, which should be a warning
# there is no way to make warnings errors, so this has to be manually checked
-> compile
-> compile
2 changes: 1 addition & 1 deletion sbt-test/tasty-compat/add-overload/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ lazy val `a-changes` = project.in(file("a-changes"))

lazy val c = project.in(file("."))
.settings(
scalacOptions ++= Seq("-from-tasty", "-Ycheck:readTasty", "-Xfatal-warnings"),
scalacOptions ++= Seq("-from-tasty", "-Ycheck:readTasty", "-Werror"),
Compile / sources := Seq(new java.io.File("c-input/B.tasty")),
Compile / unmanagedClasspath += (ThisBuild / baseDirectory).value / "c-input",
Compile / classDirectory := (ThisBuild / baseDirectory).value / "c-output"
Expand Down
2 changes: 1 addition & 1 deletion sbt-test/tasty-compat/add-param-unroll/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ lazy val c = project.in(file("c"))
.settings(commonSettings)
.settings(printSettings)
.settings(
// scalacOptions ++= Seq("-from-tasty", "-Ycheck:readTasty", "-Xfatal-warnings", "-Vprint:readTasty", "-Xprint-types"),
// scalacOptions ++= Seq("-from-tasty", "-Ycheck:readTasty", "-Werror", "-Vprint:readTasty", "-Xprint-types"),
// Compile / sources := Seq(new java.io.File("c-input/B.tasty")),
Compile / unmanagedClasspath += (ThisBuild / baseDirectory).value / "c-input",
Compile / classDirectory := (ThisBuild / baseDirectory).value / "c-output"
Expand Down
2 changes: 1 addition & 1 deletion tests/disabled/macro/pos/t8013/inpervolated_2.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -Xfatal-warnings -Xlint
//> using options -Werror -Xlint
package t8013

// unsuspecting user of perverse macro
Expand Down
2 changes: 1 addition & 1 deletion tests/disabled/partest/neg/t5663-badwarneq.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final case class ValueClass3(val value: Int) extends AnyVal

/* It's not possible to run partest without -deprecation.
* Since detecting the warnings requires a neg test with
* -Xfatal-warnings, and deprecation terminates the compile,
* -Werror and deprecation terminates the compile,
* we'll just comment out the nasty part. The point was
* just to show there's nothing special about a trait
* that extends a case class, which is only permitted
Expand Down
2 changes: 1 addition & 1 deletion tests/explicit-nulls/neg-patmat/match-pat.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -Xfatal-warnings
//> using options -Werror

class Foo {

Expand Down
2 changes: 1 addition & 1 deletion tests/explicit-nulls/pos/match-pat.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -Xfatal-warnings
//> using options -Werror

// Ensure we don't get "the type test for argType cannot be checked at runtime" warning

Expand Down
2 changes: 1 addition & 1 deletion tests/explicit-nulls/pos/unsafe-match-null-pat.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -Xfatal-warnings
//> using options -Werror

import scala.language.unsafeNulls

Expand Down
4 changes: 2 additions & 2 deletions tests/neg-custom-args/captures/capt-wf.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -language:experimental.captureChecking -Xfatal-warnings
//> using options -language:experimental.captureChecking -Werror
import caps.cap
class C
type Cap = C^
Expand Down Expand Up @@ -35,4 +35,4 @@ def test(c: Cap, other: String): Unit =
val y3: String^{ev} = ??? // error cs is empty

()
// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings)
// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings)
2 changes: 1 addition & 1 deletion tests/neg-custom-args/sourcepath2/hi/A.check
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
| class Hello is in the wrong directory.
| It was declared to be in package <empty>
| But it is found in directory hi
No warnings can be incurred under -Werror (or -Xfatal-warnings)
No warnings can be incurred under -Werror
4 changes: 2 additions & 2 deletions tests/neg-custom-args/wildcards.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//> using options -source future -deprecation -Xfatal-warnings
//> using options -source future -deprecation -Werror

object Test {
val xs: List[_] = List(1, 2, 3) // error
val ys: Map[_ <: AnyRef, _ >: Null] = Map() // error // error
}
}
2 changes: 1 addition & 1 deletion tests/neg-deep-subtype/i17435.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -Xfatal-warnings
//> using options -Werror

import scala.collection.mutable

Expand Down
2 changes: 1 addition & 1 deletion tests/neg-deep-subtype/i5495.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -Xfatal-warnings
//> using options -Werror

class A
class B
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-deep-subtype/i5826b.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -Xfatal-warnings
//> using options -Werror

class Foo {
def test1[A]: List[Int] | A => Int = {
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-deep-subtype/patmat-applied.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -Xfatal-warnings
//> using options -Werror

class A[-T]
class B[T] extends A[T]
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/i9570.check
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
15 | case '{HCons(_,$t)} => // warn (in .check file)
| ^
| Use of `_` for lambda in quoted pattern. Use explicit lambda instead or use `$_` to match any term.
No warnings can be incurred under -Werror (or -Xfatal-warnings)
No warnings can be incurred under -Werror
4 changes: 2 additions & 2 deletions tests/neg-macros/i9570.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -Xfatal-warnings
//> using options -Werror

import scala.quoted.*

Expand All @@ -25,4 +25,4 @@ object Macros {
}
}

// nopos-error No warnings can be incurred under -Werror (or -Xfatal-warnings)
// nopos-error No warnings can be incurred under -Werror
2 changes: 1 addition & 1 deletion tests/neg-macros/macro-deprecation.check
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
5 |inline def f = ${ impl } // warn (in .check file)
| ^^^^
| method impl is deprecated
No warnings can be incurred under -Werror (or -Xfatal-warnings)
No warnings can be incurred under -Werror
2 changes: 1 addition & 1 deletion tests/neg-macros/macro-deprecation.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -Xfatal-warnings -deprecation
//> using options -Werror -deprecation

import scala.quoted.*

Expand Down
2 changes: 1 addition & 1 deletion tests/neg-scalajs/enumeration-warnings.check
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@
| ^^^^^^^^^^^^
| Passing null as name to a constructor of scala.Enumeration.Val requires reflection at run-time.
| The resulting program is unlikely to function properly.
No warnings can be incurred under -Werror (or -Xfatal-warnings)
No warnings can be incurred under -Werror
2 changes: 1 addition & 1 deletion tests/neg-scalajs/enumeration-warnings.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -Xfatal-warnings
//> using options -Werror

class UnableToTransformValue extends Enumeration {
val a = {
Expand Down
2 changes: 1 addition & 1 deletion tests/neg/IsInstanceOfClassTag.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -Xfatal-warnings
//> using options -Werror

import scala.reflect.ClassTag

Expand Down
4 changes: 2 additions & 2 deletions tests/neg/adhoc-extension/B.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -source future -feature -Xfatal-warnings
//> using options -source future -feature -Werror

package adhoc
class B extends A // warn: adhoc-extension (under -strict -feature -Xfatal-warnings)
Expand All @@ -8,4 +8,4 @@ object O {
val a = new A {} // warn
object E extends A // warn
}
// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings)
// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings)
2 changes: 1 addition & 1 deletion tests/neg/classtag-typetest/3_1-migration.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -Xfatal-warnings
//> using options -Werror

import scala.language.`future-migration`
import scala.reflect.ClassTag
Expand Down
2 changes: 1 addition & 1 deletion tests/neg/classtag-typetest/3_1.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -Xfatal-warnings
//> using options -Werror

import scala.language.future
import scala.reflect.ClassTag
Expand Down
2 changes: 1 addition & 1 deletion tests/neg/enum-variance.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -Xfatal-warnings
//> using options -Werror

enum View[-T]:
case Refl(f: T => T) // error: enum case Refl requires explicit declaration of type T
Expand Down
4 changes: 2 additions & 2 deletions tests/neg/filtering-fors.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -Xfatal-warnings
//> using options -Werror

object Test {

Expand Down Expand Up @@ -31,4 +31,4 @@ object Test {
for (case (x: String) <- xs; case (y, z) <- xs) do () // OK

for (case (x, y) <- pairs) yield (y, x) // OK
}
}
2 changes: 1 addition & 1 deletion tests/neg/i1050.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -source future -deprecation -Xfatal-warnings
//> using options -source future -deprecation -Werror

// i1050 checks failing at posttyper
trait A { type L <: Nothing }
Expand Down
4 changes: 2 additions & 2 deletions tests/neg/i12188/Test.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -Xfatal-warnings
//> using options -Werror

sealed trait P
case class PC1(a: String) extends P
Expand All @@ -10,4 +10,4 @@ def foo(x: P): Unit =
x match // warn
case _: PC1 =>

// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings)
// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings)
2 changes: 1 addition & 1 deletion tests/neg/i13946/BadPrinter.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -Xfatal-warnings -feature
//> using options -Werror -feature

// in BadPrinter.scala
import language.future
Expand Down
2 changes: 1 addition & 1 deletion tests/neg/i15474b.check
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
| ^^^^^^^^^^
| Infinite loop in function body
| Test1.c.apply(from).toInt
No warnings can be incurred under -Werror (or -Xfatal-warnings)
No warnings can be incurred under -Werror
2 changes: 1 addition & 1 deletion tests/neg/i15474b.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -Xfatal-warnings
//> using options -Werror

import scala.language.implicitConversions

Expand Down
2 changes: 1 addition & 1 deletion tests/neg/i16092.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -source future -deprecation -Xfatal-warnings
//> using options -source future -deprecation -Werror

trait X {
type T
Expand Down
4 changes: 2 additions & 2 deletions tests/neg/i16876/Test.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -Xfatal-warnings -Wunused:all
//> using options -Werror -Wunused:all

object Foo {
private def myMethod(a: Int, b: Int, c: Int) = adder // ok
Expand All @@ -7,4 +7,4 @@ object Foo {
private def myMethodFailing(a: Int, b: Int, c: Int) = a + 0 // warn // warn
myMethodFailing(1, 2, 3)
}
// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings)
// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings)
2 changes: 1 addition & 1 deletion tests/neg/i17335.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -Xfatal-warnings -Wunused:all
//> using options -Werror -Wunused:all

def aMethod() =
doStuff { (x) => x } // error
2 changes: 1 addition & 1 deletion tests/neg/i17612b.check
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@
41 | class UnderDerived(x: Int, y: Int, z: Int) extends Derived(x, 1, y, z) // warn // warn // warn
| ^
| value z in class UnderDerived shadows field z inherited from trait Base
No warnings can be incurred under -Werror (or -Xfatal-warnings)
No warnings can be incurred under -Werror
4 changes: 2 additions & 2 deletions tests/neg/i17612b/i17612b.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -Xfatal-warnings -Wshadow:private-shadow -source:3.3
//> using options -Werror -Wshadow:private-shadow -source:3.3

object i17612b:

Expand Down Expand Up @@ -42,4 +42,4 @@ object i17612b:

def main(args: Array[String]) =
val derived = new Derived(1, 1, 1, 1)
// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings)
// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings)
2 changes: 1 addition & 1 deletion tests/neg/i17613b.check
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@
42 | class InnerCl[ImClassR] // warn
| ^^^^^^^^
| Type parameter ImClassR for class InnerCl shadows an explicitly renamed type : ImClassR
No warnings can be incurred under -Werror (or -Xfatal-warnings)
No warnings can be incurred under -Werror
2 changes: 1 addition & 1 deletion tests/neg/i17613b/i17613b.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -Wshadow:type-parameter-shadow -Xfatal-warnings
//> using options -Wshadow:type-parameter-shadow -Werror

object i17613b:
import importTry._
Expand Down
2 changes: 1 addition & 1 deletion tests/neg/i18632.check
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
12 | bar // warn
| ^^^
| unused value of type String
No warnings can be incurred under -Werror (or -Xfatal-warnings)
No warnings can be incurred under -Werror
4 changes: 2 additions & 2 deletions tests/neg/i4986d.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -Xfatal-warnings
//> using options -Werror

trait Foo[A]

Expand All @@ -22,4 +22,4 @@ trait Bar[A]
type Barable[A] = {
def bar(implicit ev: Bar[A]): Any // ok
}
// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings)
// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings)
Loading
Loading