diff --git a/compiler/src/dotty/tools/dotc/Run.scala b/compiler/src/dotty/tools/dotc/Run.scala index bec1c89d7216..1e801dc5998a 100644 --- a/compiler/src/dotty/tools/dotc/Run.scala +++ b/compiler/src/dotty/tools/dotc/Run.scala @@ -346,6 +346,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint runCtx.withProgressCallback: cb => _progress = Progress(cb, this, fusedPhases.map(_.traversals).sum) runPhases(allPhases = fusedPhases)(using runCtx) + ctx.reporter.finalizeReporting() if (!ctx.reporter.hasErrors) Rewrites.writeBack() suppressions.runFinished(hasErrors = ctx.reporter.hasErrors) diff --git a/compiler/src/dotty/tools/dotc/reporting/Reporter.scala b/compiler/src/dotty/tools/dotc/reporting/Reporter.scala index f567e094e831..5465f4f0dc63 100644 --- a/compiler/src/dotty/tools/dotc/reporting/Reporter.scala +++ b/compiler/src/dotty/tools/dotc/reporting/Reporter.scala @@ -172,19 +172,14 @@ abstract class Reporter extends interfaces.ReporterResult { end issueUnconfigured def issueIfNotSuppressed(dia: Diagnostic)(using Context): Unit = - def toErrorIfFatal(dia: Diagnostic) = dia match - case w: Warning if ctx.settings.silentWarnings.value => dia - case w: ConditionalWarning if w.isSummarizedConditional => dia - case w: Warning if ctx.settings.XfatalWarnings.value => w.toError - case _ => dia def go() = import Action.* dia match case w: Warning => WConf.parsed.action(dia) match case Error => issueUnconfigured(w.toError) - case Warning => issueUnconfigured(toErrorIfFatal(w)) - case Verbose => issueUnconfigured(toErrorIfFatal(w.setVerbose())) + case Warning => issueUnconfigured(w) + case Verbose => issueUnconfigured(w.setVerbose()) case Info => issueUnconfigured(w.toInfo) case Silent => case _ => issueUnconfigured(dia) @@ -214,6 +209,10 @@ abstract class Reporter extends interfaces.ReporterResult { def incomplete(dia: Diagnostic)(using Context): Unit = incompleteHandler(dia, ctx) + def finalizeReporting()(using Context) = + if (hasWarnings && ctx.settings.XfatalWarnings.value) + report(new Error("No warnings can be incurred under -Werror.", NoSourcePosition)) + /** Summary of warnings and errors */ def summary: String = { val b = new mutable.ListBuffer[String] diff --git a/compiler/test-resources/repl/rewrite-messages b/compiler/test-resources/repl/rewrite-messages index a63a72195019..393b87ee272b 100644 --- a/compiler/test-resources/repl/rewrite-messages +++ b/compiler/test-resources/repl/rewrite-messages @@ -1,17 +1,20 @@ //> using options -source:future-migration -deprecation -Werror scala> import scala.util._ --- Error: ---------------------------------------------------------------------- +-- Migration Warning: ---------------------------------------------------------- 1 | import scala.util._ | ^ | `_` is no longer supported for a wildcard import; use `*` instead - +No warnings can be incurred under -Werror. +1 warning found +1 error found scala> extension (x: Int) def foo(y: Int) = x + y def foo(x: Int)(y: Int): Int - scala> 2 foo 4 --- Error: ---------------------------------------------------------------------- +-- Migration Warning: ---------------------------------------------------------- 1 | 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`. -1 error found +No warnings can be incurred under -Werror. +1 warning found +1 error found \ No newline at end of file diff --git a/compiler/test/dotty/tools/dotc/CompilationTests.scala b/compiler/test/dotty/tools/dotc/CompilationTests.scala index 41b8de0d6138..7af43295814d 100644 --- a/compiler/test/dotty/tools/dotc/CompilationTests.scala +++ b/compiler/test/dotty/tools/dotc/CompilationTests.scala @@ -216,7 +216,10 @@ class CompilationTests { @Test def checkInitGlobal: Unit = { implicit val testGroup: TestGroup = TestGroup("checkInitGlobal") val options = defaultOptions.and("-Ysafe-init-global", "-Xfatal-warnings") + compileFilesInDir("tests/init-global/neg", options).checkExpectedErrors() + compileFilesInDir("tests/init-global/pos", options).checkCompile() compileFilesInDir("tests/init-global/neg", options, FileFilter.exclude(TestSources.negInitGlobalScala2LibraryTastyBlacklisted)).checkExpectedErrors() + compileFilesInDir("tests/init-global/warn", defaultOptions.and("-Ysafe-init-global"), FileFilter.exclude(TestSources.negInitGlobalScala2LibraryTastyBlacklisted)).checkWarnings() compileFilesInDir("tests/init-global/pos", options, FileFilter.exclude(TestSources.posInitGlobalScala2LibraryTastyBlacklisted)).checkCompile() } @@ -225,6 +228,7 @@ class CompilationTests { implicit val testGroup: TestGroup = TestGroup("checkInit") val options = defaultOptions.and("-Ysafe-init", "-Xfatal-warnings") compileFilesInDir("tests/init/neg", options).checkExpectedErrors() + compileFilesInDir("tests/init/warn", defaultOptions.and("-Ysafe-init")).checkWarnings() compileFilesInDir("tests/init/pos", options).checkCompile() compileFilesInDir("tests/init/crash", options.without("-Xfatal-warnings")).checkCompile() // The regression test for i12128 has some atypical classpath requirements. diff --git a/compiler/test/dotty/tools/vulpix/ParallelTesting.scala b/compiler/test/dotty/tools/vulpix/ParallelTesting.scala index e93a0435987b..174fbb60ef34 100644 --- a/compiler/test/dotty/tools/vulpix/ParallelTesting.scala +++ b/compiler/test/dotty/tools/vulpix/ParallelTesting.scala @@ -776,7 +776,7 @@ trait ParallelTesting extends RunnerOrchestration { self => end maybeFailureMessage def getWarnMapAndExpectedCount(files: Seq[JFile]): (HashMap[String, Integer], Int) = - val comment = raw"//( *)warn".r + val comment = raw"//( *)(nopos-)?warn".r val map = new HashMap[String, Integer]() var count = 0 def bump(key: String): Unit = @@ -787,8 +787,11 @@ trait ParallelTesting extends RunnerOrchestration { self => files.filter(isSourceFile).foreach { file => Using(Source.fromFile(file, StandardCharsets.UTF_8.name)) { source => source.getLines.zipWithIndex.foreach { case (line, lineNbr) => - comment.findAllMatchIn(line).foreach { _ => - bump(s"${file.getPath}:${lineNbr+1}") + comment.findAllMatchIn(line).foreach { m => + m.group(2) match + case "nopos-" => + bump("nopos") + case _ => bump(s"${file.getPath}:${lineNbr+1}") } } }.get @@ -809,7 +812,7 @@ trait ParallelTesting extends RunnerOrchestration { self => val key = s"${relativize(srcpos.source.file.toString())}:${srcpos.line + 1}" if !seenAt(key) then unexpected += key else - unpositioned += relativize(srcpos.source.file.toString()) + if(!seenAt("nopos")) unpositioned += relativize(srcpos.source.file.toString()) reporterWarnings.foreach(sawDiagnostic) diff --git a/tests/init-global/neg/context-sensitivity.check b/tests/init-global/neg/context-sensitivity.check new file mode 100644 index 000000000000..e5eaad3d2a58 --- /dev/null +++ b/tests/init-global/neg/context-sensitivity.check @@ -0,0 +1,11 @@ +-- Warning: tests/init-global/neg/context-sensitivity.scala:9:21 ------------------------------------------------------- +9 | def foo(): Int = A.m + | ^^^ + | Access uninitialized field value m. Calling trace: + | ├── object A: [ context-sensitivity.scala:14 ] + | │ ^ + | ├── val m: Int = box1.value.foo() [ context-sensitivity.scala:17 ] + | │ ^^^^^^^^^^^^^^^^ + | └── def foo(): Int = A.m [ context-sensitivity.scala:9 ] + | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/context-sensitivity.scala b/tests/init-global/neg/context-sensitivity.scala old mode 100755 new mode 100644 index 626fd41bb43f..7b7477df5773 --- a/tests/init-global/neg/context-sensitivity.scala +++ b/tests/init-global/neg/context-sensitivity.scala @@ -6,7 +6,7 @@ class C(var x: Int) extends Foo { } class D(var y: Int) extends Foo { - def foo(): Int = A.m // error + def foo(): Int = A.m } class Box(var value: Foo) @@ -15,3 +15,5 @@ object A: val box1: Box = new Box(new C(5)) val box2: Box = new Box(new D(10)) val m: Int = box1.value.foo() + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-cycle1.check b/tests/init-global/neg/global-cycle1.check index c68b8b51a419..81859776b06f 100644 --- a/tests/init-global/neg/global-cycle1.check +++ b/tests/init-global/neg/global-cycle1.check @@ -1,20 +1,21 @@ --- Error: tests/init-global/neg/global-cycle1.scala:1:7 ---------------------------------------------------------------- -1 |object A { // error +-- Warning: tests/init-global/neg/global-cycle1.scala:1:7 -------------------------------------------------------------- +1 |object A { | ^ | Cyclic initialization: object A -> object B -> object A. Calling trace: - | ├── object A { // error [ global-cycle1.scala:1 ] + | ├── object A { [ global-cycle1.scala:1 ] | │ ^ | ├── val a: Int = B.b [ global-cycle1.scala:2 ] | │ ^ | ├── object B { [ global-cycle1.scala:5 ] | │ ^ - | └── val b: Int = A.a // error [ global-cycle1.scala:6 ] + | └── val b: Int = A.a [ global-cycle1.scala:6 ] | ^ --- Error: tests/init-global/neg/global-cycle1.scala:6:17 --------------------------------------------------------------- -6 | val b: Int = A.a // error +-- Warning: tests/init-global/neg/global-cycle1.scala:6:17 ------------------------------------------------------------- +6 | val b: Int = A.a | ^^^ | Access uninitialized field value a. Calling trace: | ├── object B { [ global-cycle1.scala:5 ] | │ ^ - | └── val b: Int = A.a // error [ global-cycle1.scala:6 ] + | └── val b: Int = A.a [ global-cycle1.scala:6 ] | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-cycle1.scala b/tests/init-global/neg/global-cycle1.scala index 592f5a652dc8..992d3eacc6f5 100644 --- a/tests/init-global/neg/global-cycle1.scala +++ b/tests/init-global/neg/global-cycle1.scala @@ -1,10 +1,12 @@ -object A { // error +object A { val a: Int = B.b } object B { - val b: Int = A.a // error + val b: Int = A.a } @main def Test = print(A.a) + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-cycle14.check b/tests/init-global/neg/global-cycle14.check new file mode 100644 index 000000000000..d976653c05f0 --- /dev/null +++ b/tests/init-global/neg/global-cycle14.check @@ -0,0 +1,21 @@ +-- Warning: tests/init-global/neg/global-cycle14.scala:8:7 ------------------------------------------------------------- +8 |object A { + | ^ + | Cyclic initialization: object A -> object B -> object A. Calling trace: + | ├── object A { [ global-cycle14.scala:8 ] + | │ ^ + | ├── val n: Int = B.m [ global-cycle14.scala:9 ] + | │ ^ + | ├── object B { [ global-cycle14.scala:12 ] + | │ ^ + | └── val m: Int = A.n [ global-cycle14.scala:13 ] + | ^ +-- Warning: tests/init-global/neg/global-cycle14.scala:13:17 ----------------------------------------------------------- +13 | val m: Int = A.n + | ^^^ + | Access uninitialized field value n. Calling trace: + | ├── object B { [ global-cycle14.scala:12 ] + | │ ^ + | └── val m: Int = A.n [ global-cycle14.scala:13 ] + | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-cycle14.scala b/tests/init-global/neg/global-cycle14.scala index bcacbebb74fa..35a3019a2a64 100644 --- a/tests/init-global/neg/global-cycle14.scala +++ b/tests/init-global/neg/global-cycle14.scala @@ -5,10 +5,12 @@ object O { val d = Data(3) } -object A { // error +object A { val n: Int = B.m } object B { - val m: Int = A.n // error + val m: Int = A.n } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-cycle2.check b/tests/init-global/neg/global-cycle2.check new file mode 100644 index 000000000000..e01fb2f15aea --- /dev/null +++ b/tests/init-global/neg/global-cycle2.check @@ -0,0 +1,11 @@ +-- Warning: tests/init-global/neg/global-cycle2.scala:6:21 ------------------------------------------------------------- +6 | def foo(): Int = A.a * 2 + | ^^^ + | Access uninitialized field value a. Calling trace: + | ├── object A { [ global-cycle2.scala:1 ] + | │ ^ + | ├── val a: Int = B.foo() [ global-cycle2.scala:2 ] + | │ ^^^^^^^ + | └── def foo(): Int = A.a * 2 [ global-cycle2.scala:6 ] + | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-cycle2.scala b/tests/init-global/neg/global-cycle2.scala index d86fe09fb0fa..f3bd33a1c179 100644 --- a/tests/init-global/neg/global-cycle2.scala +++ b/tests/init-global/neg/global-cycle2.scala @@ -3,5 +3,7 @@ object A { } object B { - def foo(): Int = A.a * 2 // error + def foo(): Int = A.a * 2 } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-cycle3.check b/tests/init-global/neg/global-cycle3.check new file mode 100644 index 000000000000..1b3ccd8dd857 --- /dev/null +++ b/tests/init-global/neg/global-cycle3.check @@ -0,0 +1,11 @@ +-- Warning: tests/init-global/neg/global-cycle3.scala:2:21 ------------------------------------------------------------- +2 | def foo(): Int = B.a + 10 + | ^^^ + | Access uninitialized field value a. Calling trace: + | ├── object B { [ global-cycle3.scala:5 ] + | │ ^ + | ├── val a: Int = A(4).foo() [ global-cycle3.scala:6 ] + | │ ^^^^^^^^^^ + | └── def foo(): Int = B.a + 10 [ global-cycle3.scala:2 ] + | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-cycle3.scala b/tests/init-global/neg/global-cycle3.scala index 405e007b044a..5e97ba59c735 100644 --- a/tests/init-global/neg/global-cycle3.scala +++ b/tests/init-global/neg/global-cycle3.scala @@ -1,7 +1,9 @@ class A(x: Int) { - def foo(): Int = B.a + 10 // error + def foo(): Int = B.a + 10 } object B { val a: Int = A(4).foo() } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-cycle4.check b/tests/init-global/neg/global-cycle4.check new file mode 100644 index 000000000000..68a4dcae4b77 --- /dev/null +++ b/tests/init-global/neg/global-cycle4.check @@ -0,0 +1,11 @@ +-- Warning: tests/init-global/neg/global-cycle4.scala:10:21 ------------------------------------------------------------ +10 | def foo(): Int = O.a + 10 + | ^^^ + | Access uninitialized field value a. Calling trace: + | ├── object O { [ global-cycle4.scala:17 ] + | │ ^ + | ├── val a: Int = D(5).bar().foo() [ global-cycle4.scala:18 ] + | │ ^^^^^^^^^^^^^^^^ + | └── def foo(): Int = O.a + 10 [ global-cycle4.scala:10 ] + | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-cycle4.scala b/tests/init-global/neg/global-cycle4.scala index 8c1627afeae4..789d682da3be 100644 --- a/tests/init-global/neg/global-cycle4.scala +++ b/tests/init-global/neg/global-cycle4.scala @@ -7,7 +7,7 @@ class B extends A { } class C extends A { - def foo(): Int = O.a + 10 // error + def foo(): Int = O.a + 10 } class D(x: Int) { @@ -17,3 +17,5 @@ class D(x: Int) { object O { val a: Int = D(5).bar().foo() } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-cycle5.check b/tests/init-global/neg/global-cycle5.check new file mode 100644 index 000000000000..c1d21cb77a45 --- /dev/null +++ b/tests/init-global/neg/global-cycle5.check @@ -0,0 +1,10 @@ +-- Warning: tests/init-global/neg/global-cycle5.scala:10:17 ------------------------------------------------------------ +10 | val b: Int = A.a.foo() + | ^^^ + |Reading mutable state of object A during initialization of object B. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object B { [ global-cycle5.scala:9 ] + |│ ^ + |└── val b: Int = A.a.foo() [ global-cycle5.scala:10 ] + | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-cycle5.scala b/tests/init-global/neg/global-cycle5.scala old mode 100755 new mode 100644 index 1ba3435d3830..281ea9b879d1 --- a/tests/init-global/neg/global-cycle5.scala +++ b/tests/init-global/neg/global-cycle5.scala @@ -7,7 +7,7 @@ object A { } object B { - val b: Int = A.a.foo() // error + val b: Int = A.a.foo() } class Y extends X { @@ -20,4 +20,5 @@ object C { def main = { A.a = new Y(); C -} \ No newline at end of file +} +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-cycle6.check b/tests/init-global/neg/global-cycle6.check new file mode 100644 index 000000000000..47a1c1543773 --- /dev/null +++ b/tests/init-global/neg/global-cycle6.check @@ -0,0 +1,29 @@ +-- Warning: tests/init-global/neg/global-cycle6.scala:1:7 -------------------------------------------------------------- +1 |object A { + | ^ + | Cyclic initialization: object A -> object B -> object A. Calling trace: + | ├── object A { [ global-cycle6.scala:1 ] + | │ ^ + | ├── val n: Int = B.m [ global-cycle6.scala:2 ] + | │ ^ + | ├── object B { [ global-cycle6.scala:8 ] + | │ ^ + | ├── val a = new A.Inner [ global-cycle6.scala:9 ] + | │ ^^^^^^^^^^^ + | ├── class Inner { [ global-cycle6.scala:3 ] + | │ ^ + | └── println(n) [ global-cycle6.scala:4 ] + | ^ +-- Warning: tests/init-global/neg/global-cycle6.scala:4:12 ------------------------------------------------------------- +4 | println(n) + | ^ + | Access uninitialized field value n. Calling trace: + | ├── object B { [ global-cycle6.scala:8 ] + | │ ^ + | ├── val a = new A.Inner [ global-cycle6.scala:9 ] + | │ ^^^^^^^^^^^ + | ├── class Inner { [ global-cycle6.scala:3 ] + | │ ^ + | └── println(n) [ global-cycle6.scala:4 ] + | ^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-cycle6.scala b/tests/init-global/neg/global-cycle6.scala index 36e3ab0b6a94..88adc536b307 100644 --- a/tests/init-global/neg/global-cycle6.scala +++ b/tests/init-global/neg/global-cycle6.scala @@ -1,7 +1,7 @@ -object A { // error +object A { val n: Int = B.m class Inner { - println(n) // error + println(n) } } @@ -22,4 +22,5 @@ object O { val a = new A.Inner val m: Int = 10 } -} \ No newline at end of file +} +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-cycle7.check b/tests/init-global/neg/global-cycle7.check new file mode 100644 index 000000000000..96a63b77b73e --- /dev/null +++ b/tests/init-global/neg/global-cycle7.check @@ -0,0 +1,21 @@ +-- Warning: tests/init-global/neg/global-cycle7.scala:1:7 -------------------------------------------------------------- +1 |object A { + | ^ + | Cyclic initialization: object A -> object B -> object A. Calling trace: + | ├── object A { [ global-cycle7.scala:1 ] + | │ ^ + | ├── val n: Int = B.m [ global-cycle7.scala:2 ] + | │ ^ + | ├── object B { [ global-cycle7.scala:5 ] + | │ ^ + | └── val m: Int = A.n [ global-cycle7.scala:6 ] + | ^ +-- Warning: tests/init-global/neg/global-cycle7.scala:6:17 ------------------------------------------------------------- +6 | val m: Int = A.n + | ^^^ + | Access uninitialized field value n. Calling trace: + | ├── object B { [ global-cycle7.scala:5 ] + | │ ^ + | └── val m: Int = A.n [ global-cycle7.scala:6 ] + | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-cycle7.scala b/tests/init-global/neg/global-cycle7.scala index aea75726fbf7..b8084984aeec 100644 --- a/tests/init-global/neg/global-cycle7.scala +++ b/tests/init-global/neg/global-cycle7.scala @@ -1,9 +1,9 @@ -object A { // error +object A { val n: Int = B.m } object B { - val m: Int = A.n // error + val m: Int = A.n } abstract class TokensCommon { @@ -16,3 +16,5 @@ object JavaTokens extends TokensCommon { final def maxToken: Int = DOUBLE final val DOUBLE = 188 } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-cycle8.check b/tests/init-global/neg/global-cycle8.check new file mode 100644 index 000000000000..6dc544fe8e7c --- /dev/null +++ b/tests/init-global/neg/global-cycle8.check @@ -0,0 +1,17 @@ +-- Warning: tests/init-global/neg/global-cycle8.scala:9:7 -------------------------------------------------------------- +9 |object O { + | ^ + | Cyclic initialization: object O -> object P -> object O. Calling trace: + | ├── object O { [ global-cycle8.scala:9 ] + | │ ^ + | ├── println(P.m) [ global-cycle8.scala:11 ] + | │ ^ + | ├── object P { [ global-cycle8.scala:14 ] + | │ ^ + | ├── val m = Q.bar(new B) [ global-cycle8.scala:15 ] + | │ ^^^^^^^^^^^^ + | ├── def bar(b: B) = b.a.foo() [ global-cycle8.scala:19 ] + | │ ^^^^^^^^^ + | └── def foo() = println(O.n) [ global-cycle8.scala:2 ] + | ^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-cycle8.scala b/tests/init-global/neg/global-cycle8.scala index 344dc3241395..91290da30353 100644 --- a/tests/init-global/neg/global-cycle8.scala +++ b/tests/init-global/neg/global-cycle8.scala @@ -6,7 +6,7 @@ class B { val a = new A } -object O { // error +object O { val n: Int = 10 println(P.m) } @@ -18,3 +18,5 @@ object P { object Q { def bar(b: B) = b.a.foo() } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-irrelevance1.check b/tests/init-global/neg/global-irrelevance1.check new file mode 100644 index 000000000000..799d80ec9623 --- /dev/null +++ b/tests/init-global/neg/global-irrelevance1.check @@ -0,0 +1,10 @@ +-- Warning: tests/init-global/neg/global-irrelevance1.scala:5:12 ------------------------------------------------------- +5 | var y = A.x * 2 + | ^^^ + |Reading mutable state of object A during initialization of object B. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object B: [ global-irrelevance1.scala:4 ] + |│ ^ + |└── var y = A.x * 2 [ global-irrelevance1.scala:5 ] + | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-irrelevance1.scala b/tests/init-global/neg/global-irrelevance1.scala index 903d3b14ae18..2eb5511001e2 100644 --- a/tests/init-global/neg/global-irrelevance1.scala +++ b/tests/init-global/neg/global-irrelevance1.scala @@ -2,4 +2,5 @@ object A: var x = 6 object B: - var y = A.x * 2 // error \ No newline at end of file + var y = A.x * 2 +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-irrelevance2.check b/tests/init-global/neg/global-irrelevance2.check new file mode 100644 index 000000000000..56263b936308 --- /dev/null +++ b/tests/init-global/neg/global-irrelevance2.check @@ -0,0 +1,14 @@ +-- Warning: tests/init-global/neg/global-irrelevance2.scala:5:6 -------------------------------------------------------- +5 | A.x = b * 2 + | ^^^^^^^^^^^^ + | Mutating object A during initialization of object B. + | Mutating other static objects during the initialization of one static object is forbidden. Calling trace: + | ├── object B: [ global-irrelevance2.scala:7 ] + | │ ^ + | ├── new B(10) [ global-irrelevance2.scala:8 ] + | │ ^^^^^^^^^ + | ├── class B(b: Int): [ global-irrelevance2.scala:4 ] + | │ ^ + | └── A.x = b * 2 [ global-irrelevance2.scala:5 ] + | ^^^^^^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-irrelevance2.scala b/tests/init-global/neg/global-irrelevance2.scala index 66b06677b689..8804eed6cc52 100644 --- a/tests/init-global/neg/global-irrelevance2.scala +++ b/tests/init-global/neg/global-irrelevance2.scala @@ -2,7 +2,9 @@ object A: var x = 6 class B(b: Int): - A.x = b * 2 // error + A.x = b * 2 object B: new B(10) + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-irrelevance3.check b/tests/init-global/neg/global-irrelevance3.check new file mode 100644 index 000000000000..7d7f9dbfb1fc --- /dev/null +++ b/tests/init-global/neg/global-irrelevance3.check @@ -0,0 +1,12 @@ +-- Warning: tests/init-global/neg/global-irrelevance3.scala:9:13 ------------------------------------------------------- +9 | (() => x) + | ^ + |Reading mutable state of object A during initialization of object B. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object B: [ global-irrelevance3.scala:13 ] + |│ ^ + |├── var y = A.p.g() [ global-irrelevance3.scala:14 ] + |│ ^^^^^^^ + |└── (() => x) [ global-irrelevance3.scala:9 ] + | ^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-irrelevance3.scala b/tests/init-global/neg/global-irrelevance3.scala index 2f36d65d917e..4b53c0335314 100644 --- a/tests/init-global/neg/global-irrelevance3.scala +++ b/tests/init-global/neg/global-irrelevance3.scala @@ -6,9 +6,11 @@ object A: var x = 6 new Pair( y => x = y, - (() => x) // error + (() => x) ) object B: var y = A.p.g() + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-irrelevance4.check b/tests/init-global/neg/global-irrelevance4.check new file mode 100644 index 000000000000..ebabde96294d --- /dev/null +++ b/tests/init-global/neg/global-irrelevance4.check @@ -0,0 +1,12 @@ +-- Warning: tests/init-global/neg/global-irrelevance4.scala:8:9 -------------------------------------------------------- +8 | (y => x = y), + | ^^^^^^^^^^ + | Mutating object A during initialization of object B. + | Mutating other static objects during the initialization of one static object is forbidden. Calling trace: + | ├── object B: [ global-irrelevance4.scala:12 ] + | │ ^ + | ├── A.p.f(10) [ global-irrelevance4.scala:13 ] + | │ ^^^^^^^^^ + | └── (y => x = y), [ global-irrelevance4.scala:8 ] + | ^^^^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-irrelevance4.scala b/tests/init-global/neg/global-irrelevance4.scala index 7a2a778814b2..caf7f2bb6466 100644 --- a/tests/init-global/neg/global-irrelevance4.scala +++ b/tests/init-global/neg/global-irrelevance4.scala @@ -5,9 +5,11 @@ object A: def foo(): Pair = var x = 6 new Pair( - (y => x = y), // error + (y => x = y), () => x ) object B: A.p.f(10) + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-irrelevance5.check b/tests/init-global/neg/global-irrelevance5.check new file mode 100644 index 000000000000..7d472621821c --- /dev/null +++ b/tests/init-global/neg/global-irrelevance5.check @@ -0,0 +1,10 @@ +-- Warning: tests/init-global/neg/global-irrelevance5.scala:6:17 ------------------------------------------------------- +6 | var y = A.array(0) * 2 + | ^^^^^^^^^^ + |Reading mutable state of object A during initialization of object B. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object B: [ global-irrelevance5.scala:5 ] + |│ ^ + |└── var y = A.array(0) * 2 [ global-irrelevance5.scala:6 ] + | ^^^^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-irrelevance5.scala b/tests/init-global/neg/global-irrelevance5.scala index fd5bde3032aa..a1cff0aeb802 100644 --- a/tests/init-global/neg/global-irrelevance5.scala +++ b/tests/init-global/neg/global-irrelevance5.scala @@ -3,4 +3,6 @@ object A: array(0) = 10 object B: - var y = A.array(0) * 2 // error + var y = A.array(0) * 2 + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-irrelevance6.check b/tests/init-global/neg/global-irrelevance6.check new file mode 100644 index 000000000000..52df6bd253e2 --- /dev/null +++ b/tests/init-global/neg/global-irrelevance6.check @@ -0,0 +1,10 @@ +-- Warning: tests/init-global/neg/global-irrelevance6.scala:9:17 ------------------------------------------------------- +9 | var y = A.array(0).foo() * 2 + | ^^^^^^^^^^ + |Reading mutable state of object A during initialization of object B. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object B: [ global-irrelevance6.scala:8 ] + |│ ^ + |└── var y = A.array(0).foo() * 2 [ global-irrelevance6.scala:9 ] + | ^^^^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-irrelevance6.scala b/tests/init-global/neg/global-irrelevance6.scala index 78699b6988b6..a16849a81934 100644 --- a/tests/init-global/neg/global-irrelevance6.scala +++ b/tests/init-global/neg/global-irrelevance6.scala @@ -6,4 +6,6 @@ object A: val n = array(0).foo() // ok, no crash object B: - var y = A.array(0).foo() * 2 // error + var y = A.array(0).foo() * 2 + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-irrelevance7.check b/tests/init-global/neg/global-irrelevance7.check new file mode 100644 index 000000000000..3178c21cbca5 --- /dev/null +++ b/tests/init-global/neg/global-irrelevance7.check @@ -0,0 +1,10 @@ +-- Warning: tests/init-global/neg/global-irrelevance7.scala:10:17 ------------------------------------------------------ +10 | var y = A.array(0).foo() * 2 + | ^^^^^^^^^^ + |Reading mutable state of object A during initialization of object B. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object B: [ global-irrelevance7.scala:9 ] + |│ ^ + |└── var y = A.array(0).foo() * 2 [ global-irrelevance7.scala:10 ] + | ^^^^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-irrelevance7.scala b/tests/init-global/neg/global-irrelevance7.scala index 2c860cbc4259..f679c9cc60b7 100644 --- a/tests/init-global/neg/global-irrelevance7.scala +++ b/tests/init-global/neg/global-irrelevance7.scala @@ -7,4 +7,6 @@ object A: val n = array(0).foo() // ok object B: - var y = A.array(0).foo() * 2 // error + var y = A.array(0).foo() * 2 + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-list.check b/tests/init-global/neg/global-list.check new file mode 100644 index 000000000000..4d4bc3d7e8ca --- /dev/null +++ b/tests/init-global/neg/global-list.check @@ -0,0 +1,37 @@ +-- Warning: tests/init-global/neg/global-list.scala:3:7 ---------------------------------------------------------------- +3 |object O: + | ^ + | Cyclic initialization: object O -> object Foo -> object O. Calling trace: + | ├── object O: [ global-list.scala:3 ] + | │ ^ + | ├── val a = Foo("Apple") [ global-list.scala:4 ] + | │ ^^^ + | ├── object Foo: [ global-list.scala:8 ] + | │ ^ + | └── val all: List[Foo] = List(O.a, O.b, O.c) [ global-list.scala:9 ] + | ^ +-- Warning: tests/init-global/neg/global-list.scala:9:30 --------------------------------------------------------------- +9 | val all: List[Foo] = List(O.a, O.b, O.c) + | ^^^ + | Access uninitialized field value a. Calling trace: + | ├── object Foo: [ global-list.scala:8 ] + | │ ^ + | └── val all: List[Foo] = List(O.a, O.b, O.c) [ global-list.scala:9 ] + | ^^^ +-- Warning: tests/init-global/neg/global-list.scala:9:35 --------------------------------------------------------------- +9 | val all: List[Foo] = List(O.a, O.b, O.c) + | ^^^ + | Access uninitialized field value b. Calling trace: + | ├── object Foo: [ global-list.scala:8 ] + | │ ^ + | └── val all: List[Foo] = List(O.a, O.b, O.c) [ global-list.scala:9 ] + | ^^^ +-- Warning: tests/init-global/neg/global-list.scala:9:40 --------------------------------------------------------------- +9 | val all: List[Foo] = List(O.a, O.b, O.c) + | ^^^ + | Access uninitialized field value c. Calling trace: + | ├── object Foo: [ global-list.scala:8 ] + | │ ^ + | └── val all: List[Foo] = List(O.a, O.b, O.c) [ global-list.scala:9 ] + | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-list.scala b/tests/init-global/neg/global-list.scala old mode 100755 new mode 100644 index cdef6dbf3bbe..e9fed153f78f --- a/tests/init-global/neg/global-list.scala +++ b/tests/init-global/neg/global-list.scala @@ -1,9 +1,10 @@ case class Foo(name: String) -object O: // error +object O: val a = Foo("Apple") val b = Foo("Banana") val c = Foo("Cherry") object Foo: - val all: List[Foo] = List(O.a, O.b, O.c) // error // error // error \ No newline at end of file + val all: List[Foo] = List(O.a, O.b, O.c) +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-local-var.check b/tests/init-global/neg/global-local-var.check new file mode 100644 index 000000000000..bbedc06dce3d --- /dev/null +++ b/tests/init-global/neg/global-local-var.check @@ -0,0 +1,13 @@ +-- Warning: tests/init-global/neg/global-local-var.scala:10:6 ---------------------------------------------------------- +10 | B.a + 10 + sum + | ^^^ + | Access uninitialized field value a. Calling trace: + | ├── object B { [ global-local-var.scala:14 ] + | │ ^ + | ├── val a: Int = A(4).foo() [ global-local-var.scala:15 ] + | │ ^^^^^^^^^^ + | ├── def foo(): Int = { [ global-local-var.scala:2 ] + | │ ^ + | └── B.a + 10 + sum [ global-local-var.scala:10 ] + | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-local-var.scala b/tests/init-global/neg/global-local-var.scala index 6965a42bd37f..9db071de5ae8 100644 --- a/tests/init-global/neg/global-local-var.scala +++ b/tests/init-global/neg/global-local-var.scala @@ -7,10 +7,12 @@ class A(x: Int) { sum += i i += 1 - B.a + 10 + sum // error + B.a + 10 + sum } } object B { val a: Int = A(4).foo() } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-region1.check b/tests/init-global/neg/global-region1.check new file mode 100644 index 000000000000..b3b7e2a3b7ca --- /dev/null +++ b/tests/init-global/neg/global-region1.check @@ -0,0 +1,11 @@ +-- Warning: tests/init-global/neg/global-region1.scala:3:51 ------------------------------------------------------------ +3 |class D(var y: Int) extends B { def foo(): Int = A.m } + | ^^^ + | Access uninitialized field value m. Calling trace: + | ├── object A: [ global-region1.scala:6 ] + | │ ^ + | ├── val m: Int = box1.value.foo() [ global-region1.scala:9 ] + | │ ^^^^^^^^^^^^^^^^ + | └── class D(var y: Int) extends B { def foo(): Int = A.m } [ global-region1.scala:3 ] + | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-region1.scala b/tests/init-global/neg/global-region1.scala index 48473717b5b5..f47e10a06424 100644 --- a/tests/init-global/neg/global-region1.scala +++ b/tests/init-global/neg/global-region1.scala @@ -1,9 +1,11 @@ trait B { def foo(): Int } class C(var x: Int) extends B { def foo(): Int = 20 } -class D(var y: Int) extends B { def foo(): Int = A.m } // error +class D(var y: Int) extends B { def foo(): Int = A.m } class Box(var value: B) object A: val box1: Box = new Box(new C(5)) val box2: Box = new Box(new D(10)) val m: Int = box1.value.foo() + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/i11262.check b/tests/init-global/neg/i11262.check new file mode 100644 index 000000000000..643a70838167 --- /dev/null +++ b/tests/init-global/neg/i11262.check @@ -0,0 +1,15 @@ +-- Warning: tests/init-global/neg/i11262.scala:1:7 --------------------------------------------------------------------- +1 |object A { val x: String = B.y } + | ^ + | Cyclic initialization: object A -> object B -> object A. Calling trace: + | ├── object A { val x: String = B.y } [ i11262.scala:1 ] + | │ ^ + | └── object B { val y: String = A.x } [ i11262.scala:2 ] + | ^ +-- Warning: tests/init-global/neg/i11262.scala:2:29 -------------------------------------------------------------------- +2 |object B { val y: String = A.x } + | ^^^ + | Access uninitialized field value x. Calling trace: + | └── object B { val y: String = A.x } [ i11262.scala:2 ] + | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/i11262.scala b/tests/init-global/neg/i11262.scala index c1c01f6aad8c..befc9ca0834d 100644 --- a/tests/init-global/neg/i11262.scala +++ b/tests/init-global/neg/i11262.scala @@ -1,2 +1,4 @@ -object A { val x: String = B.y } // error -object B { val y: String = A.x } // error +object A { val x: String = B.y } +object B { val y: String = A.x } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/i12544b.check b/tests/init-global/neg/i12544b.check new file mode 100644 index 000000000000..7680b62d0b7b --- /dev/null +++ b/tests/init-global/neg/i12544b.check @@ -0,0 +1,21 @@ +-- Warning: tests/init-global/neg/i12544b.scala:5:9 -------------------------------------------------------------------- +5 | object nested: + | ^ + | Cyclic initialization: object nested -> object Enum -> object nested. Calling trace: + | ├── object nested: [ i12544b.scala:5 ] + | │ ^ + | ├── val a: Enum = Case [ i12544b.scala:6 ] + | │ ^^^^ + | ├── object Enum: [ i12544b.scala:4 ] + | │ ^ + | └── val b: Enum = f(nested.a) [ i12544b.scala:8 ] + | ^^^^^^ +-- Warning: tests/init-global/neg/i12544b.scala:8:25 ------------------------------------------------------------------- +8 | val b: Enum = f(nested.a) + | ^^^^^^^^ + | Access uninitialized field value a. Calling trace: + | ├── object Enum: [ i12544b.scala:4 ] + | │ ^ + | └── val b: Enum = f(nested.a) [ i12544b.scala:8 ] + | ^^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/i12544b.scala b/tests/init-global/neg/i12544b.scala index 586b88df04bd..759829e3bd75 100644 --- a/tests/init-global/neg/i12544b.scala +++ b/tests/init-global/neg/i12544b.scala @@ -2,11 +2,13 @@ enum Enum: case Case object Enum: - object nested: // error + object nested: val a: Enum = Case - val b: Enum = f(nested.a) // error + val b: Enum = f(nested.a) def f(e: Enum): Enum = e @main def main(): Unit = println(Enum.b) + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/i9176.check b/tests/init-global/neg/i9176.check new file mode 100644 index 000000000000..a26b66081d75 --- /dev/null +++ b/tests/init-global/neg/i9176.check @@ -0,0 +1,9 @@ +-- Warning: tests/init-global/neg/i9176.scala:2:12 --------------------------------------------------------------------- +2 |case object A extends Foo(B) + | ^ + | Cyclic initialization: object A -> object B -> object A. Calling trace: + | ├── case object A extends Foo(B) [ i9176.scala:2 ] + | │ ^ + | └── case object B extends Foo(A) [ i9176.scala:3 ] + | ^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/i9176.scala b/tests/init-global/neg/i9176.scala index c93a16f2f8b1..fe1c5388029e 100644 --- a/tests/init-global/neg/i9176.scala +++ b/tests/init-global/neg/i9176.scala @@ -1,5 +1,5 @@ class Foo(val opposite: Foo) -case object A extends Foo(B) // error +case object A extends Foo(B) case object B extends Foo(A) object Test { def main(args: Array[String]): Unit = { @@ -7,3 +7,5 @@ object Test { println(B.opposite) } } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/line-spacing.check b/tests/init-global/neg/line-spacing.check index 6fa8801bb07b..66f695d62ca5 100644 --- a/tests/init-global/neg/line-spacing.check +++ b/tests/init-global/neg/line-spacing.check @@ -1,6 +1,6 @@ --- Error: tests/init-global/neg/line-spacing.scala:4:7 ----------------------------------------------------------------- +-- Warning: tests/init-global/neg/line-spacing.scala:4:7 --------------------------------------------------------------- 3 | B -4 | .s.length // error +4 | .s.length | ^ | Access uninitialized field value s. Calling trace: | ├── object B { [ line-spacing.scala:7 ] @@ -9,5 +9,6 @@ | │ ^^^ | ├── def a: Int = [ line-spacing.scala:2 ] | │ ^ - | └── .s.length // error [ line-spacing.scala:4 ] + | └── .s.length [ line-spacing.scala:4 ] | ^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/line-spacing.scala b/tests/init-global/neg/line-spacing.scala index 42474decb53c..7855e82954b8 100644 --- a/tests/init-global/neg/line-spacing.scala +++ b/tests/init-global/neg/line-spacing.scala @@ -1,9 +1,11 @@ object A { def a: Int = B - .s.length // error + .s.length } object B { val s: String = s"${A.a}a" } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/mutable-array.check b/tests/init-global/neg/mutable-array.check new file mode 100644 index 000000000000..9a877be4eff4 --- /dev/null +++ b/tests/init-global/neg/mutable-array.check @@ -0,0 +1,10 @@ +-- Warning: tests/init-global/neg/mutable-array.scala:8:19 ------------------------------------------------------------- +8 | val x: Int = box.value + | ^^^^^^^^^ + |Reading mutable state of object A during initialization of object B. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object B: [ mutable-array.scala:5 ] + |│ ^ + |└── val x: Int = box.value [ mutable-array.scala:8 ] + | ^^^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/mutable-array.scala b/tests/init-global/neg/mutable-array.scala index 3cbc23a5e127..4fea9a813423 100644 --- a/tests/init-global/neg/mutable-array.scala +++ b/tests/init-global/neg/mutable-array.scala @@ -5,4 +5,6 @@ object A: object B: val boxes: Array[A.Box] = Array(A.box) val box: A.Box = boxes(0) - val x: Int = box.value // error + val x: Int = box.value + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/mutable-read1.check b/tests/init-global/neg/mutable-read1.check new file mode 100644 index 000000000000..4e446490d7e5 --- /dev/null +++ b/tests/init-global/neg/mutable-read1.check @@ -0,0 +1,10 @@ +-- Warning: tests/init-global/neg/mutable-read1.scala:10:20 ------------------------------------------------------------ +10 | val n: Int = boxA.value + | ^^^^^^^^^^ + |Reading mutable state of object A during initialization of object B. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object B: [ mutable-read1.scala:6 ] + |│ ^ + |└── val n: Int = boxA.value [ mutable-read1.scala:10 ] + | ^^^^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/mutable-read1.scala b/tests/init-global/neg/mutable-read1.scala old mode 100755 new mode 100644 index 507a8b7d74ad..78aa0e1c4ff3 --- a/tests/init-global/neg/mutable-read1.scala +++ b/tests/init-global/neg/mutable-read1.scala @@ -7,4 +7,5 @@ object B: val boxB: Box = new Box(5) val boxA: Box = A.box val m: Int = boxB.value - val n: Int = boxA.value // error \ No newline at end of file + val n: Int = boxA.value +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/mutable-read2.check b/tests/init-global/neg/mutable-read2.check new file mode 100644 index 000000000000..24c3c0ef3789 --- /dev/null +++ b/tests/init-global/neg/mutable-read2.check @@ -0,0 +1,10 @@ +-- Warning: tests/init-global/neg/mutable-read2.scala:10:19 ------------------------------------------------------------ +10 | val b: Int = box.value + | ^^^^^^^^^ + |Reading mutable state of object A during initialization of object B. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object B: [ mutable-read2.scala:7 ] + |│ ^ + |└── val b: Int = box.value [ mutable-read2.scala:10 ] + | ^^^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/mutable-read2.scala b/tests/init-global/neg/mutable-read2.scala old mode 100755 new mode 100644 index e7653c63d8bb..d223de11d801 --- a/tests/init-global/neg/mutable-read2.scala +++ b/tests/init-global/neg/mutable-read2.scala @@ -7,4 +7,5 @@ object A: object B: val box: A.Box = A.box val a: Int = box.initial - val b: Int = box.value // error \ No newline at end of file + val b: Int = box.value +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/mutable-read3.check b/tests/init-global/neg/mutable-read3.check new file mode 100644 index 000000000000..e0eeb62cee63 --- /dev/null +++ b/tests/init-global/neg/mutable-read3.check @@ -0,0 +1,10 @@ +-- Warning: tests/init-global/neg/mutable-read3.scala:9:19 ------------------------------------------------------------- +9 | val x: Int = box.value + | ^^^^^^^^^ + |Reading mutable state of object A during initialization of object B. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object B: [ mutable-read3.scala:5 ] + |│ ^ + |└── val x: Int = box.value [ mutable-read3.scala:9 ] + | ^^^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/mutable-read3.scala b/tests/init-global/neg/mutable-read3.scala old mode 100755 new mode 100644 index d103e112f372..d5cf067f7609 --- a/tests/init-global/neg/mutable-read3.scala +++ b/tests/init-global/neg/mutable-read3.scala @@ -6,4 +6,5 @@ object B: val boxes: Array[A.Box] = new Array(1) boxes(0) = A.box val box: A.Box = boxes(0) - val x: Int = box.value // error \ No newline at end of file + val x: Int = box.value +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/mutable-read4.check b/tests/init-global/neg/mutable-read4.check new file mode 100644 index 000000000000..81f3a68e0f8b --- /dev/null +++ b/tests/init-global/neg/mutable-read4.check @@ -0,0 +1,10 @@ +-- Warning: tests/init-global/neg/mutable-read4.scala:10:20 ------------------------------------------------------------ +10 | val n: Int = boxA.value + | ^^^^^^^^^^ + |Reading mutable state of object A during initialization of object B. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object B: [ mutable-read4.scala:6 ] + |│ ^ + |└── val n: Int = boxA.value [ mutable-read4.scala:10 ] + | ^^^^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/mutable-read4.scala b/tests/init-global/neg/mutable-read4.scala old mode 100755 new mode 100644 index 507a8b7d74ad..78aa0e1c4ff3 --- a/tests/init-global/neg/mutable-read4.scala +++ b/tests/init-global/neg/mutable-read4.scala @@ -7,4 +7,5 @@ object B: val boxB: Box = new Box(5) val boxA: Box = A.box val m: Int = boxB.value - val n: Int = boxA.value // error \ No newline at end of file + val n: Int = boxA.value +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/mutable-read5.check b/tests/init-global/neg/mutable-read5.check new file mode 100644 index 000000000000..0fa788588d97 --- /dev/null +++ b/tests/init-global/neg/mutable-read5.check @@ -0,0 +1,12 @@ +-- Warning: tests/init-global/neg/mutable-read5.scala:4:38 ------------------------------------------------------------- +4 | def name(s: String): Name = Name(0, chrs.length) + | ^^^^ + |Reading mutable state of object Names during initialization of object StdNames. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object StdNames: [ mutable-read5.scala:6 ] + |│ ^ + |├── val AnyRef: Names.Name = Names.name("AnyRef") [ mutable-read5.scala:7 ] + |│ ^^^^^^^^^^^^^^^^^^^^ + |└── def name(s: String): Name = Name(0, chrs.length) [ mutable-read5.scala:4 ] + | ^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/mutable-read5.scala b/tests/init-global/neg/mutable-read5.scala old mode 100755 new mode 100644 index c166295bf9fa..884f027c970e --- a/tests/init-global/neg/mutable-read5.scala +++ b/tests/init-global/neg/mutable-read5.scala @@ -1,9 +1,10 @@ object Names: class Name(val start: Int, val length: Int) var chrs: Array[Char] = new Array[Char](0x20000) - def name(s: String): Name = Name(0, chrs.length) // error + def name(s: String): Name = Name(0, chrs.length) object StdNames: val AnyRef: Names.Name = Names.name("AnyRef") val Array: Names.Name = Names.name("Array") - val List: Names.Name = Names.name("List") \ No newline at end of file + val List: Names.Name = Names.name("List") +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/mutable-read6.check b/tests/init-global/neg/mutable-read6.check new file mode 100644 index 000000000000..a43e62bafae0 --- /dev/null +++ b/tests/init-global/neg/mutable-read6.check @@ -0,0 +1,12 @@ +-- Warning: tests/init-global/neg/mutable-read6.scala:7:35 ------------------------------------------------------------- +7 | final def source: SourceFile = _source + | ^^^^^^^ + |Reading mutable state of object Contexts during initialization of object Implicits. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object Implicits: [ mutable-read6.scala:12 ] + |│ ^ + |├── val NoMatchingFailure: SearchFailure = SearchFailure(1, NoContext.source) [ mutable-read6.scala:15 ] + |│ ^^^^^^^^^^^^^^^^ + |└── final def source: SourceFile = _source [ mutable-read6.scala:7 ] + | ^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/mutable-read6.scala b/tests/init-global/neg/mutable-read6.scala old mode 100755 new mode 100644 index 8b00eeaf4216..ce6034769f60 --- a/tests/init-global/neg/mutable-read6.scala +++ b/tests/init-global/neg/mutable-read6.scala @@ -4,7 +4,7 @@ object Contexts: val NoContext: Context = new Context class Context: private var _source: SourceFile = null - final def source: SourceFile = _source // error + final def source: SourceFile = _source def setSource(source: SourceFile) = { this._source = source } @@ -12,4 +12,5 @@ object Contexts: object Implicits: import Contexts.* case class SearchFailure(tag: Int, source: SourceFile) - val NoMatchingFailure: SearchFailure = SearchFailure(1, NoContext.source) \ No newline at end of file + val NoMatchingFailure: SearchFailure = SearchFailure(1, NoContext.source) +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/mutable-read7.check b/tests/init-global/neg/mutable-read7.check new file mode 100644 index 000000000000..5198721ebf40 --- /dev/null +++ b/tests/init-global/neg/mutable-read7.check @@ -0,0 +1,16 @@ +-- Warning: tests/init-global/neg/mutable-read7.scala:7:17 ------------------------------------------------------------- +7 | if (Positioned.debug) { + | ^^^^^^^^^^^^^^^^ + |Reading mutable state of object Positioned during initialization of object Trees. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object Trees: [ mutable-read7.scala:11 ] + |│ ^ + |├── val emptyTree = new Tree [ mutable-read7.scala:13 ] + |│ ^^^^^^^^ + |├── class Tree extends Positioned [ mutable-read7.scala:12 ] + |│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + |├── abstract class Positioned: [ mutable-read7.scala:6 ] + |│ ^ + |└── if (Positioned.debug) { [ mutable-read7.scala:7 ] + | ^^^^^^^^^^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/mutable-read7.scala b/tests/init-global/neg/mutable-read7.scala old mode 100755 new mode 100644 index ad9d154d74f5..b840bdc11a5d --- a/tests/init-global/neg/mutable-read7.scala +++ b/tests/init-global/neg/mutable-read7.scala @@ -4,10 +4,11 @@ object Positioned: var nextId: Int = 0 abstract class Positioned: - if (Positioned.debug) { // error + if (Positioned.debug) { println("do debugging") } object Trees: class Tree extends Positioned - val emptyTree = new Tree \ No newline at end of file + val emptyTree = new Tree +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/mutable-read8.check b/tests/init-global/neg/mutable-read8.check new file mode 100644 index 000000000000..030208a605dd --- /dev/null +++ b/tests/init-global/neg/mutable-read8.check @@ -0,0 +1,14 @@ +-- Warning: tests/init-global/neg/mutable-read8.scala:6:12 ------------------------------------------------------------- +6 | if (Stats.monitored) println("record stats") + | ^^^^^^^^^^^^^^^ + |Reading mutable state of object Stats during initialization of object NoCompleter. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object NoCompleter extends LazyType [ mutable-read8.scala:11 ] + |│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + |├── class LazyType extends UncachedGroundType [ mutable-read8.scala:9 ] + |│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + |├── class UncachedGroundType { [ mutable-read8.scala:5 ] + |│ ^ + |└── if (Stats.monitored) println("record stats") [ mutable-read8.scala:6 ] + | ^^^^^^^^^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/mutable-read8.scala b/tests/init-global/neg/mutable-read8.scala old mode 100755 new mode 100644 index e830fa65be73..0e84fe534b26 --- a/tests/init-global/neg/mutable-read8.scala +++ b/tests/init-global/neg/mutable-read8.scala @@ -3,9 +3,10 @@ object Stats { } class UncachedGroundType { - if (Stats.monitored) println("record stats") // error + if (Stats.monitored) println("record stats") } class LazyType extends UncachedGroundType -object NoCompleter extends LazyType \ No newline at end of file +object NoCompleter extends LazyType +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/partial-ordering.check b/tests/init-global/neg/partial-ordering.check new file mode 100644 index 000000000000..d7a71995dd4c --- /dev/null +++ b/tests/init-global/neg/partial-ordering.check @@ -0,0 +1,13 @@ +-- Warning: tests/init-global/neg/partial-ordering.scala:1:7 ----------------------------------------------------------- +1 |object Names: + | ^ + | Cyclic initialization: object Names -> object MethodName -> object Names. Calling trace: + | ├── object Names: [ partial-ordering.scala:1 ] + | │ ^ + | ├── val ctorName: MethodName = MethodName.apply(ctorString) [ partial-ordering.scala:3 ] + | │ ^^^^^^^^^^ + | ├── object MethodName: [ partial-ordering.scala:6 ] + | │ ^ + | └── val ctor: MethodName = new MethodName(Names.ctorString) [ partial-ordering.scala:7 ] + | ^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/partial-ordering.scala b/tests/init-global/neg/partial-ordering.scala old mode 100755 new mode 100644 index 1bc1b251fb72..7cc1333706a9 --- a/tests/init-global/neg/partial-ordering.scala +++ b/tests/init-global/neg/partial-ordering.scala @@ -1,8 +1,9 @@ -object Names: // error +object Names: val ctorString = "" val ctorName: MethodName = MethodName.apply(ctorString) class MethodName(encoded: String) object MethodName: val ctor: MethodName = new MethodName(Names.ctorString) - def apply(name: String): MethodName = new MethodName(name) \ No newline at end of file + def apply(name: String): MethodName = new MethodName(name) +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/patmat-unapplySeq.check b/tests/init-global/neg/patmat-unapplySeq.check index 8f7a1f64631b..8131e730b8b2 100644 --- a/tests/init-global/neg/patmat-unapplySeq.check +++ b/tests/init-global/neg/patmat-unapplySeq.check @@ -1,5 +1,5 @@ --- Error: tests/init-global/neg/patmat-unapplySeq.scala:8:32 ----------------------------------------------------------- -8 | def apply(i: Int): Box = array(i) // error +-- Warning: tests/init-global/neg/patmat-unapplySeq.scala:8:32 --------------------------------------------------------- +8 | def apply(i: Int): Box = array(i) | ^^^^^^^^ |Reading mutable state of object A during initialization of object B. |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: @@ -7,5 +7,6 @@ |│ ^ |├── case A(b) => [ patmat-unapplySeq.scala:17 ] |│ ^^^^ - |└── def apply(i: Int): Box = array(i) // error [ patmat-unapplySeq.scala:8 ] + |└── def apply(i: Int): Box = array(i) [ patmat-unapplySeq.scala:8 ] | ^^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/patmat-unapplySeq.scala b/tests/init-global/neg/patmat-unapplySeq.scala index 81c853a6e19f..3f0f1c60c801 100644 --- a/tests/init-global/neg/patmat-unapplySeq.scala +++ b/tests/init-global/neg/patmat-unapplySeq.scala @@ -5,7 +5,7 @@ object A: array(0) = new Box(10) def length: Int = array.length - def apply(i: Int): Box = array(i) // error + def apply(i: Int): Box = array(i) def drop(n: Int): Seq[Box] = array.toSeq def toSeq: Seq[Box] = array.toSeq @@ -15,3 +15,5 @@ object A: object B: A.array match case A(b) => + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/patmat-unapplySeq2.check b/tests/init-global/neg/patmat-unapplySeq2.check new file mode 100644 index 000000000000..57a67452c10f --- /dev/null +++ b/tests/init-global/neg/patmat-unapplySeq2.check @@ -0,0 +1,12 @@ +-- Warning: tests/init-global/neg/patmat-unapplySeq2.scala:8:32 -------------------------------------------------------- +8 | def apply(i: Int): Box = array(i) + | ^^^^^^^^ + |Reading mutable state of object A during initialization of object B. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object B: [ patmat-unapplySeq2.scala:15 ] + |│ ^ + |├── case A(b*) => [ patmat-unapplySeq2.scala:17 ] + |│ ^^^^^ + |└── def apply(i: Int): Box = array(i) [ patmat-unapplySeq2.scala:8 ] + | ^^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/patmat-unapplySeq2.scala b/tests/init-global/neg/patmat-unapplySeq2.scala index adab9495db49..c890a09efd2e 100644 --- a/tests/init-global/neg/patmat-unapplySeq2.scala +++ b/tests/init-global/neg/patmat-unapplySeq2.scala @@ -5,7 +5,7 @@ object A: array(0) = new Box(10) def length: Int = array.length - def apply(i: Int): Box = array(i) // error + def apply(i: Int): Box = array(i) def drop(n: Int): Seq[Box] = array.toSeq def toSeq: Seq[Box] = array.toSeq @@ -15,3 +15,5 @@ object A: object B: A.array match case A(b*) => + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/patmat.check b/tests/init-global/neg/patmat.check new file mode 100644 index 000000000000..e05d144db7ce --- /dev/null +++ b/tests/init-global/neg/patmat.check @@ -0,0 +1,27 @@ +-- Warning: tests/init-global/neg/patmat.scala:1:7 --------------------------------------------------------------------- +1 |object A: + | ^ + | Cyclic initialization: object A -> object B -> object A. Calling trace: + | ├── object A: [ patmat.scala:1 ] + | │ ^ + | ├── case Some(x) => println(x * 2 + B.a.size) [ patmat.scala:4 ] + | │ ^ + | ├── object B: [ patmat.scala:7 ] + | │ ^ + | └── if A.a.isEmpty then println(xs.size) [ patmat.scala:12 ] + | ^ +-- Warning: tests/init-global/neg/patmat.scala:29:9 -------------------------------------------------------------------- +29 | object Inner: + | ^ + | Cyclic initialization: object Inner -> object C -> object Inner. Calling trace: + | ├── object Inner: [ patmat.scala:29 ] + | │ ^ + | ├── case Box(f) => f() [ patmat.scala:35 ] + | │ ^^^ + | ├── val foo: () => Int = () => C.a [ patmat.scala:32 ] + | │ ^ + | ├── object C: [ patmat.scala:18 ] + | │ ^ + | └── val a: Int = Inner.b [ patmat.scala:27 ] + | ^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/patmat.scala b/tests/init-global/neg/patmat.scala index 126e66e7cf7b..05f6ea0cdbac 100644 --- a/tests/init-global/neg/patmat.scala +++ b/tests/init-global/neg/patmat.scala @@ -1,4 +1,4 @@ -object A: // error +object A: val a: Option[Int] = Some(3) a match case Some(x) => println(x * 2 + B.a.size) @@ -26,7 +26,7 @@ object C: val a: Int = Inner.b - object Inner: // error + object Inner: val b: Int = 10 val foo: () => Int = () => C.a @@ -34,3 +34,5 @@ object C: (Box(foo): Box[() => Int] | Holder[Int]) match case Box(f) => f() case Holder(x) => x + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/return.check b/tests/init-global/neg/return.check new file mode 100644 index 000000000000..a420b2bab4c3 --- /dev/null +++ b/tests/init-global/neg/return.check @@ -0,0 +1,11 @@ +-- Warning: tests/init-global/neg/return.scala:4:31 -------------------------------------------------------------------- +4 | return (a: Int) => a + B.n + | ^^^ + | Access uninitialized field value n. Calling trace: + | ├── object B: [ return.scala:8 ] + | │ ^ + | ├── val n = A.foo(-10)(20) [ return.scala:9 ] + | │ ^^^^^^^^^^^^^^ + | └── return (a: Int) => a + B.n [ return.scala:4 ] + | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/return.scala b/tests/init-global/neg/return.scala old mode 100755 new mode 100644 index 5cbf6915fc0e..442b0f200f45 --- a/tests/init-global/neg/return.scala +++ b/tests/init-global/neg/return.scala @@ -1,10 +1,12 @@ object A: def foo(x: Int): Int => Int = if x <= 0 then - return (a: Int) => a + B.n // error + return (a: Int) => a + B.n (a: Int) => a * a + x object B: val n = A.foo(-10)(20) + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/return2.check b/tests/init-global/neg/return2.check new file mode 100644 index 000000000000..e0d9a6e33b14 --- /dev/null +++ b/tests/init-global/neg/return2.check @@ -0,0 +1,15 @@ +-- Warning: tests/init-global/neg/return2.scala:3:30 ------------------------------------------------------------------- +3 | val f = (a: Int) => a + B.n + | ^^^ + | Access uninitialized field value n. Calling trace: + | ├── object B: [ return2.scala:12 ] + | │ ^ + | ├── val n = A.foo(-10)(20) [ return2.scala:13 ] + | │ ^^^^^^^^^^^^^^ + | └── val f = (a: Int) => a + B.n [ return2.scala:3 ] + | ^^^ +-- Warning: tests/init-global/neg/return2.scala:6:18 ------------------------------------------------------------------- +6 | val g = () => return f + | ^^^^^^^^ + | Non local returns are no longer supported; use `boundary` and `boundary.break` in `scala.util` instead +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/return2.scala b/tests/init-global/neg/return2.scala old mode 100755 new mode 100644 index 6a4dec50c2dd..3c93fe9120c6 --- a/tests/init-global/neg/return2.scala +++ b/tests/init-global/neg/return2.scala @@ -1,6 +1,6 @@ object A: def foo(x: Int): Int => Int = - val f = (a: Int) => a + B.n // error + val f = (a: Int) => a + B.n var i = 0 val g = () => return f @@ -11,3 +11,5 @@ object A: object B: val n = A.foo(-10)(20) + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/t5366.check b/tests/init-global/neg/t5366.check new file mode 100644 index 000000000000..3aeda68fd96f --- /dev/null +++ b/tests/init-global/neg/t5366.check @@ -0,0 +1,21 @@ +-- Warning: tests/init-global/neg/t5366.scala:3:12 --------------------------------------------------------------------- +3 |case object ObjA extends IdAndMsg(1) + | ^ + | Cyclic initialization: object ObjA -> object IdAndMsg -> object ObjA. Calling trace: + | ├── case object ObjA extends IdAndMsg(1) [ t5366.scala:3 ] + | │ ^ + | ├── object IdAndMsg { [ t5366.scala:6 ] + | │ ^ + | └── val values = List(ObjA , ObjB) [ t5366.scala:7 ] + | ^^^^ +-- Warning: tests/init-global/neg/t5366.scala:6:7 ---------------------------------------------------------------------- +6 |object IdAndMsg { + | ^ + | Cyclic initialization: object IdAndMsg -> object ObjB -> object IdAndMsg. Calling trace: + | ├── object IdAndMsg { [ t5366.scala:6 ] + | │ ^ + | ├── val values = List(ObjA , ObjB) [ t5366.scala:7 ] + | │ ^^^^ + | └── case object ObjB extends IdAndMsg(2) [ t5366.scala:4 ] + | ^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/t5366.scala b/tests/init-global/neg/t5366.scala index 854bdfe0544b..2283b79bfb8f 100644 --- a/tests/init-global/neg/t5366.scala +++ b/tests/init-global/neg/t5366.scala @@ -1,9 +1,9 @@ class IdAndMsg(val id: Int, val msg: String = "") -case object ObjA extends IdAndMsg(1) // error +case object ObjA extends IdAndMsg(1) case object ObjB extends IdAndMsg(2) -object IdAndMsg { // error +object IdAndMsg { val values = List(ObjA , ObjB) } @@ -12,4 +12,5 @@ object Test { ObjA println(IdAndMsg.values) } -} \ No newline at end of file +} +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/t9115.check b/tests/init-global/neg/t9115.check new file mode 100644 index 000000000000..a55c2eb151a1 --- /dev/null +++ b/tests/init-global/neg/t9115.check @@ -0,0 +1,21 @@ +-- Warning: tests/init-global/neg/t9115.scala:4:14 --------------------------------------------------------------------- +4 | case object D1 extends Z(aaa) + | ^ + | Cyclic initialization: object D1 -> object D -> object D1. Calling trace: + | ├── case object D1 extends Z(aaa) [ t9115.scala:4 ] + | │ ^^^ + | ├── object D { [ t9115.scala:1 ] + | │ ^ + | └── println(D1) [ t9115.scala:6 ] + | ^^ +-- Warning: tests/init-global/neg/t9115.scala:1:7 ---------------------------------------------------------------------- +1 |object D { + | ^ + | Cyclic initialization: object D -> object D2 -> object D. Calling trace: + | ├── object D { [ t9115.scala:1 ] + | │ ^ + | ├── println(D2) [ t9115.scala:7 ] + | │ ^^ + | └── case object D2 extends Z(aaa) // 'null' when calling D.D2 first time [ t9115.scala:5 ] + | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/t9115.scala b/tests/init-global/neg/t9115.scala index a3020c6939a8..aa9573554260 100644 --- a/tests/init-global/neg/t9115.scala +++ b/tests/init-global/neg/t9115.scala @@ -1,8 +1,10 @@ -object D { // error +object D { def aaa = 1 //that’s the reason class Z (depends: Any) - case object D1 extends Z(aaa) // 'null' when calling D.D1 first time // error + case object D1 extends Z(aaa) case object D2 extends Z(aaa) // 'null' when calling D.D2 first time println(D1) println(D2) } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/t9261.check b/tests/init-global/neg/t9261.check new file mode 100644 index 000000000000..dbda32347e74 --- /dev/null +++ b/tests/init-global/neg/t9261.check @@ -0,0 +1,9 @@ +-- Warning: tests/init-global/neg/t9261.scala:2:12 --------------------------------------------------------------------- +2 |case object Buy extends OrderType(Sell) + | ^ + | Cyclic initialization: object Buy -> object Sell -> object Buy. Calling trace: + | ├── case object Buy extends OrderType(Sell) [ t9261.scala:2 ] + | │ ^^^^ + | └── case object Sell extends OrderType(Buy) [ t9261.scala:3 ] + | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/t9261.scala b/tests/init-global/neg/t9261.scala index 1e23bedb9b6a..9eb7f255492c 100644 --- a/tests/init-global/neg/t9261.scala +++ b/tests/init-global/neg/t9261.scala @@ -1,3 +1,5 @@ sealed abstract class OrderType(val reverse: OrderType) -case object Buy extends OrderType(Sell) // error +case object Buy extends OrderType(Sell) case object Sell extends OrderType(Buy) + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/t9312.check b/tests/init-global/neg/t9312.check new file mode 100644 index 000000000000..d6f1b00b1a09 --- /dev/null +++ b/tests/init-global/neg/t9312.check @@ -0,0 +1,29 @@ +-- Warning: tests/init-global/neg/t9312.scala:18:11 -------------------------------------------------------------------- +18 | object Child1 extends Child + | ^ + | Cyclic initialization: object Child1 -> object Parent -> object Child1. Calling trace: + | ├── object Child1 extends Child [ t9312.scala:18 ] + | │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ├── trait Child { [ t9312.scala:12 ] + | │ ^ + | ├── val parent = Parent [ t9312.scala:14 ] + | │ ^^^^^^ + | ├── object Parent { [ t9312.scala:11 ] + | │ ^ + | └── final val children = Set(Child1, Child2) [ t9312.scala:21 ] + | ^^^^^^ +-- Warning: tests/init-global/neg/t9312.scala:11:9 --------------------------------------------------------------------- +11 | object Parent { + | ^ + | Cyclic initialization: object Parent -> object Child2 -> object Parent. Calling trace: + | ├── object Parent { [ t9312.scala:11 ] + | │ ^ + | ├── final val children = Set(Child1, Child2) [ t9312.scala:21 ] + | │ ^^^^^^ + | ├── object Child2 extends Child [ t9312.scala:19 ] + | │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ├── trait Child { [ t9312.scala:12 ] + | │ ^ + | └── val parent = Parent [ t9312.scala:14 ] + | ^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/t9312.scala b/tests/init-global/neg/t9312.scala index d88093a2f67a..7dc9af580162 100644 --- a/tests/init-global/neg/t9312.scala +++ b/tests/init-global/neg/t9312.scala @@ -8,16 +8,18 @@ object DeadLockTest { } - object Parent { // error + object Parent { trait Child { Thread.sleep(2000) // ensure concurrent behavior val parent = Parent def siblings = parent.children - this } - object Child1 extends Child // error + object Child1 extends Child object Child2 extends Child final val children = Set(Child1, Child2) } } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/t9360.check b/tests/init-global/neg/t9360.check new file mode 100644 index 000000000000..23ceea224a10 --- /dev/null +++ b/tests/init-global/neg/t9360.check @@ -0,0 +1,21 @@ +-- Warning: tests/init-global/neg/t9360.scala:8:9 ---------------------------------------------------------------------- +8 | object AObj extends BaseClass(s) + | ^ + | Cyclic initialization: object AObj -> object Obj -> object AObj. Calling trace: + | ├── object AObj extends BaseClass(s) [ t9360.scala:8 ] + | │ ^ + | ├── object Obj { [ t9360.scala:5 ] + | │ ^ + | └── val list = List(AObj, BObj) [ t9360.scala:12 ] + | ^^^^ +-- Warning: tests/init-global/neg/t9360.scala:5:7 ---------------------------------------------------------------------- +5 |object Obj { + | ^ + | Cyclic initialization: object Obj -> object BObj -> object Obj. Calling trace: + | ├── object Obj { [ t9360.scala:5 ] + | │ ^ + | ├── val list = List(AObj, BObj) [ t9360.scala:12 ] + | │ ^^^^ + | └── object BObj extends BaseClass(s) [ t9360.scala:10 ] + | ^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/t9360.scala b/tests/init-global/neg/t9360.scala index 2ec0c740d739..0fca843cd01d 100644 --- a/tests/init-global/neg/t9360.scala +++ b/tests/init-global/neg/t9360.scala @@ -2,10 +2,10 @@ class BaseClass(s: String) { def print: Unit = () } -object Obj { // error +object Obj { val s: String = "hello" - object AObj extends BaseClass(s) // error + object AObj extends BaseClass(s) object BObj extends BaseClass(s) @@ -23,3 +23,5 @@ object ObjectInit { Obj.print } } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/unapply-implicit-arg.check b/tests/init-global/neg/unapply-implicit-arg.check new file mode 100644 index 000000000000..4e45d79e7e14 --- /dev/null +++ b/tests/init-global/neg/unapply-implicit-arg.check @@ -0,0 +1,9 @@ +-- Warning: tests/init-global/neg/unapply-implicit-arg.scala:11:16 ----------------------------------------------------- +11 | val i2: Int = i2 match + | ^^ + | Access uninitialized field value i2. Calling trace: + | ├── object Bar { [ unapply-implicit-arg.scala:1 ] + | │ ^ + | └── val i2: Int = i2 match [ unapply-implicit-arg.scala:11 ] + | ^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/unapply-implicit-arg.scala b/tests/init-global/neg/unapply-implicit-arg.scala index bf41fbbf9412..dd8d03821d0a 100644 --- a/tests/init-global/neg/unapply-implicit-arg.scala +++ b/tests/init-global/neg/unapply-implicit-arg.scala @@ -8,7 +8,8 @@ object Bar { given Foo = new Foo val i1: Int = 0 - val i2: Int = i2 match // error + val i2: Int = i2 match case Bar(i) => i case _ => 0 -} \ No newline at end of file +} +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/unapply-implicit-arg2.check b/tests/init-global/neg/unapply-implicit-arg2.check new file mode 100644 index 000000000000..ec317d59f1bd --- /dev/null +++ b/tests/init-global/neg/unapply-implicit-arg2.check @@ -0,0 +1,13 @@ +-- Warning: tests/init-global/neg/unapply-implicit-arg2.scala:7:51 ----------------------------------------------------- +7 | if i == 0 then Some(f1.m1(i1)) else Some(f1.m2(i2)) + | ^^ + | Access uninitialized field value i2. Calling trace: + | ├── object Bar { [ unapply-implicit-arg2.scala:1 ] + | │ ^ + | ├── case Bar(i) => i [ unapply-implicit-arg2.scala:12 ] + | │ ^^^^^^ + | ├── def unapply(using f1: Foo)(i: Int): Option[Int] = [ unapply-implicit-arg2.scala:6 ] + | │ ^ + | └── if i == 0 then Some(f1.m1(i1)) else Some(f1.m2(i2)) [ unapply-implicit-arg2.scala:7 ] + | ^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/unapply-implicit-arg2.scala b/tests/init-global/neg/unapply-implicit-arg2.scala index c0a16faac377..b180e5eee495 100644 --- a/tests/init-global/neg/unapply-implicit-arg2.scala +++ b/tests/init-global/neg/unapply-implicit-arg2.scala @@ -4,7 +4,7 @@ object Bar { def m2(i: Int) = i+2 } def unapply(using f1: Foo)(i: Int): Option[Int] = - if i == 0 then Some(f1.m1(i1)) else Some(f1.m2(i2)) // error + if i == 0 then Some(f1.m1(i1)) else Some(f1.m2(i2)) given Foo = new Foo val i1: Int = 0 @@ -12,3 +12,5 @@ object Bar { case Bar(i) => i case _ => 0 } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/unapply-implicit-arg3.check b/tests/init-global/neg/unapply-implicit-arg3.check new file mode 100644 index 000000000000..3bb9c0ad2930 --- /dev/null +++ b/tests/init-global/neg/unapply-implicit-arg3.check @@ -0,0 +1,15 @@ +-- Warning: tests/init-global/neg/unapply-implicit-arg3.scala:4:25 ----------------------------------------------------- +4 | def m2(i: Int) = i + i2 + | ^^ + | Access uninitialized field value i2. Calling trace: + | ├── object Bar { [ unapply-implicit-arg3.scala:1 ] + | │ ^ + | ├── case Bar(i) => i [ unapply-implicit-arg3.scala:12 ] + | │ ^^^^^^ + | ├── def unapply(using f1: Foo)(i: Int): Option[Int] = [ unapply-implicit-arg3.scala:6 ] + | │ ^ + | ├── if i == 0 then Some(f1.m1(i)) else Some(f1.m2(i)) [ unapply-implicit-arg3.scala:7 ] + | │ ^^^^^^^^ + | └── def m2(i: Int) = i + i2 [ unapply-implicit-arg3.scala:4 ] + | ^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/unapply-implicit-arg3.scala b/tests/init-global/neg/unapply-implicit-arg3.scala index efa348f6cfdb..3bf923eeeb4e 100644 --- a/tests/init-global/neg/unapply-implicit-arg3.scala +++ b/tests/init-global/neg/unapply-implicit-arg3.scala @@ -1,7 +1,7 @@ object Bar { class Foo { def m1(i: Int) = i + i1 - def m2(i: Int) = i + i2 // error + def m2(i: Int) = i + i2 } def unapply(using f1: Foo)(i: Int): Option[Int] = if i == 0 then Some(f1.m1(i)) else Some(f1.m2(i)) @@ -12,3 +12,5 @@ object Bar { case Bar(i) => i case _ => 0 } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/unapplySeq-implicit-arg.check b/tests/init-global/neg/unapplySeq-implicit-arg.check new file mode 100644 index 000000000000..d021cd1f5d94 --- /dev/null +++ b/tests/init-global/neg/unapplySeq-implicit-arg.check @@ -0,0 +1,9 @@ +-- Warning: tests/init-global/neg/unapplySeq-implicit-arg.scala:11:20 -------------------------------------------------- +11 | val i2: Int = Seq(i2) match + | ^^ + | Access uninitialized field value i2. Calling trace: + | ├── object Bar { [ unapplySeq-implicit-arg.scala:1 ] + | │ ^ + | └── val i2: Int = Seq(i2) match [ unapplySeq-implicit-arg.scala:11 ] + | ^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/unapplySeq-implicit-arg.scala b/tests/init-global/neg/unapplySeq-implicit-arg.scala index e58635a3090f..1ec3ab6fa79a 100644 --- a/tests/init-global/neg/unapplySeq-implicit-arg.scala +++ b/tests/init-global/neg/unapplySeq-implicit-arg.scala @@ -8,7 +8,9 @@ object Bar { given Foo = new Foo val i1: Int = 0 - val i2: Int = Seq(i2) match // error + val i2: Int = Seq(i2) match case Bar(i) => i case _ => 0 } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/unapplySeq-implicit-arg2.check b/tests/init-global/neg/unapplySeq-implicit-arg2.check new file mode 100644 index 000000000000..2e5164d7b405 --- /dev/null +++ b/tests/init-global/neg/unapplySeq-implicit-arg2.check @@ -0,0 +1,13 @@ +-- Warning: tests/init-global/neg/unapplySeq-implicit-arg2.scala:4:9 --------------------------------------------------- +4 | Some(i1 +: seqi) + | ^^ + |Access uninitialized field value i1. Calling trace: + |├── object Bar { [ unapplySeq-implicit-arg2.scala:1 ] + |│ ^ + |├── case Bar(i) => i [ unapplySeq-implicit-arg2.scala:7 ] + |│ ^^^^^^ + |├── def unapplySeq(using f1: Foo)(using f2: Foo)(seqi: Seq[Int])(using Foo): Option[Seq[Int]] = [ unapplySeq-implicit-arg2.scala:3 ] + |│ ^ + |└── Some(i1 +: seqi) [ unapplySeq-implicit-arg2.scala:4 ] + | ^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/unapplySeq-implicit-arg2.scala b/tests/init-global/neg/unapplySeq-implicit-arg2.scala index 35f5105b84d2..7a48651a3a7a 100644 --- a/tests/init-global/neg/unapplySeq-implicit-arg2.scala +++ b/tests/init-global/neg/unapplySeq-implicit-arg2.scala @@ -1,10 +1,12 @@ object Bar { class Foo def unapplySeq(using f1: Foo)(using f2: Foo)(seqi: Seq[Int])(using Foo): Option[Seq[Int]] = - Some(i1 +: seqi) // error + Some(i1 +: seqi) given Foo = new Foo val i1: Int = Seq(0) match { case Bar(i) => i case _ => 0 } } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/unapplySeq-implicit-arg3.check b/tests/init-global/neg/unapplySeq-implicit-arg3.check new file mode 100644 index 000000000000..59ea56320452 --- /dev/null +++ b/tests/init-global/neg/unapplySeq-implicit-arg3.check @@ -0,0 +1,15 @@ +-- Warning: tests/init-global/neg/unapplySeq-implicit-arg3.scala:3:27 -------------------------------------------------- +3 | def m(seq: Seq[Int]) = i1 +: seq + | ^^ + |Access uninitialized field value i1. Calling trace: + |├── object Bar { [ unapplySeq-implicit-arg3.scala:1 ] + |│ ^ + |├── case Bar(i, _) => i [ unapplySeq-implicit-arg3.scala:9 ] + |│ ^^^^^^^^^ + |├── def unapplySeq(using f1: Foo)(seqi: Seq[Int])(using Foo): Option[Seq[Int]] = [ unapplySeq-implicit-arg3.scala:5 ] + |│ ^ + |├── Some(f1.m(seqi)) [ unapplySeq-implicit-arg3.scala:6 ] + |│ ^^^^^^^^^^ + |└── def m(seq: Seq[Int]) = i1 +: seq [ unapplySeq-implicit-arg3.scala:3 ] + | ^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/unapplySeq-implicit-arg3.scala b/tests/init-global/neg/unapplySeq-implicit-arg3.scala index 2b5cdd327e57..9efcac577bd3 100644 --- a/tests/init-global/neg/unapplySeq-implicit-arg3.scala +++ b/tests/init-global/neg/unapplySeq-implicit-arg3.scala @@ -1,6 +1,6 @@ object Bar { class Foo { - def m(seq: Seq[Int]) = i1 +: seq // error + def m(seq: Seq[Int]) = i1 +: seq } def unapplySeq(using f1: Foo)(seqi: Seq[Int])(using Foo): Option[Seq[Int]] = Some(f1.m(seqi)) @@ -10,3 +10,5 @@ object Bar { case _ => 0 } } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/i18628.scala b/tests/init-global/warn/i18628.scala similarity index 69% rename from tests/init-global/neg/i18628.scala rename to tests/init-global/warn/i18628.scala index 798b3204338c..afd5c14d0b7d 100644 --- a/tests/init-global/neg/i18628.scala +++ b/tests/init-global/warn/i18628.scala @@ -2,6 +2,6 @@ object Test: class Box(val x: Int) def recur(a: => Box, b: => Box): Int = - a.x + recur(a, b) + b.x // error // error + a.x + recur(a, b) + b.x // warn // warn recur(Box(1), Box(2)) \ No newline at end of file diff --git a/tests/init-global/neg/i18628_2.scala b/tests/init-global/warn/i18628_2.scala similarity index 73% rename from tests/init-global/neg/i18628_2.scala rename to tests/init-global/warn/i18628_2.scala index 4ad428035441..7f90f51ccc1a 100644 --- a/tests/init-global/neg/i18628_2.scala +++ b/tests/init-global/warn/i18628_2.scala @@ -2,6 +2,6 @@ object Test: class Box(val x: Int) def recur(a: => Box, b: Box): Int = - a.x + recur(a, b) + b.x // error + a.x + recur(a, b) + b.x // warn recur(Box(1), Box(2)) diff --git a/tests/init-global/neg/i18628_3.scala b/tests/init-global/warn/i18628_3.scala similarity index 67% rename from tests/init-global/neg/i18628_3.scala rename to tests/init-global/warn/i18628_3.scala index 101674cffb6f..0a14c7d4c73e 100644 --- a/tests/init-global/neg/i18628_3.scala +++ b/tests/init-global/warn/i18628_3.scala @@ -4,6 +4,6 @@ object Test: class Box(val x: Int) def recur(a: => Box, b: => Box): Int = - a.x + recur(a: @widen(5), b: @widen(5)) + b.x // error // error + a.x + recur(a: @widen(5), b: @widen(5)) + b.x // warn // warn recur(Box(1), Box(2)) \ No newline at end of file diff --git a/tests/init/neg/early-promote2.scala b/tests/init/neg/early-promote2.scala deleted file mode 100644 index 514aed36a8ed..000000000000 --- a/tests/init/neg/early-promote2.scala +++ /dev/null @@ -1,6 +0,0 @@ -class M { - println(this) // error - foo() - private val a = 5 // error - def foo() = a -} diff --git a/tests/init/neg/i15883.scala b/tests/init/neg/i15883.scala deleted file mode 100644 index 6f6e3066a878..000000000000 --- a/tests/init/neg/i15883.scala +++ /dev/null @@ -1,2 +0,0 @@ -val a = b -val b = 1 // error diff --git a/tests/init/neg/simple1.scala b/tests/init/neg/simple1.scala deleted file mode 100644 index 93fba24008b9..000000000000 --- a/tests/init/neg/simple1.scala +++ /dev/null @@ -1,4 +0,0 @@ -class Foo { - val len = name.size - val name: String = "Jack" // error -} \ No newline at end of file diff --git a/tests/init/neg/soundness4.scala b/tests/init/neg/soundness4.scala deleted file mode 100644 index 308856b5e870..000000000000 --- a/tests/init/neg/soundness4.scala +++ /dev/null @@ -1,3 +0,0 @@ -class Foo { - val a : Foo = this.a.a // error -} \ No newline at end of file diff --git a/tests/init/neg/AbstractFile.scala b/tests/init/warn/AbstractFile.scala similarity index 64% rename from tests/init/neg/AbstractFile.scala rename to tests/init/warn/AbstractFile.scala index f4f38982608a..bb8abc6e8322 100644 --- a/tests/init/neg/AbstractFile.scala +++ b/tests/init/warn/AbstractFile.scala @@ -4,6 +4,6 @@ abstract class AbstractFile { } class RemoteFile(url: String) extends AbstractFile { - val localFile: String = s"${url.##}.tmp" // error: usage of `localFile` before it's initialized + val localFile: String = s"${url.##}.tmp" // warn: usage of `localFile` before it's initialized def name: String = localFile } diff --git a/tests/init/neg/alias.scala b/tests/init/warn/alias.scala similarity index 63% rename from tests/init/neg/alias.scala rename to tests/init/warn/alias.scala index 79367b36d0c5..8e9cb56b75c0 100644 --- a/tests/init/neg/alias.scala +++ b/tests/init/warn/alias.scala @@ -1,5 +1,5 @@ class Foo { val self = this val x = self.n - val n = 10 // error + val n = 10 // warn } \ No newline at end of file diff --git a/tests/init/neg/apply.scala b/tests/init/warn/apply.scala similarity index 85% rename from tests/init/neg/apply.scala rename to tests/init/warn/apply.scala index 2847115cc73c..fffa4c59968f 100644 --- a/tests/init/neg/apply.scala +++ b/tests/init/warn/apply.scala @@ -6,7 +6,7 @@ object A: class B: val a = A(this) - val a2 = A.foo(this) // error + val a2 = A.foo(this) // warn val a3 = A.bar(this) // test receiver is ThisRef @@ -20,7 +20,7 @@ object O: class B: val a = A(this) - val a2 = A.foo(this) // error + val a2 = A.foo(this) // warn val a3 = A.bar(this) val b = new B @@ -38,7 +38,7 @@ class M(n: N): class B: val a = A(this) - val a2 = A.foo(this) // error + val a2 = A.foo(this) // warn val a3 = A.bar(this) end M diff --git a/tests/init/neg/apply2.scala b/tests/init/warn/apply2.scala old mode 100755 new mode 100644 similarity index 76% rename from tests/init/neg/apply2.scala rename to tests/init/warn/apply2.scala index c6c7fe5fedd2..b81dfa5e7a57 --- a/tests/init/neg/apply2.scala +++ b/tests/init/warn/apply2.scala @@ -3,7 +3,7 @@ object O: println(n) class B: - val a = A(this) // error + val a = A(this) // warn val b = new B val n = 10 diff --git a/tests/init/neg/as-instance-of-cold-field-access.scala b/tests/init/warn/as-instance-of-cold-field-access.scala similarity index 78% rename from tests/init/neg/as-instance-of-cold-field-access.scala rename to tests/init/warn/as-instance-of-cold-field-access.scala index c8de99e96d0e..caef6f42f623 100644 --- a/tests/init/neg/as-instance-of-cold-field-access.scala +++ b/tests/init/warn/as-instance-of-cold-field-access.scala @@ -1,7 +1,7 @@ final class MyAsInstanceOfClass(o: MyAsInstanceOfClass) { val other: MyAsInstanceOfClass = { if (o.asInstanceOf[MyAsInstanceOfClass].oRef ne null) o - else new MyAsInstanceOfClass(this) // error + else new MyAsInstanceOfClass(this) // warn } val oRef = o } diff --git a/tests/init/neg/by-name-error.scala b/tests/init/warn/by-name-error.scala similarity index 79% rename from tests/init/neg/by-name-error.scala rename to tests/init/warn/by-name-error.scala index 960bbe9bf7e9..8d3a690c7cfd 100644 --- a/tests/init/neg/by-name-error.scala +++ b/tests/init/warn/by-name-error.scala @@ -8,6 +8,6 @@ object Foo { } class A { - val foo = implicitly[Foo] // error + val foo = implicitly[Foo] // warn assert(foo eq foo.next) } \ No newline at end of file diff --git a/tests/init/neg/closureLeak.scala b/tests/init/warn/closureLeak.scala similarity index 83% rename from tests/init/neg/closureLeak.scala rename to tests/init/warn/closureLeak.scala index ae7db5124028..3e4e1f88102b 100644 --- a/tests/init/neg/closureLeak.scala +++ b/tests/init/warn/closureLeak.scala @@ -8,6 +8,6 @@ class Outer { } val l: List[A] = List(new A(5), new A(10)) - l.foreach(a => a.addX(this)) // error + l.foreach(a => a.addX(this)) // warn val p = 10 } diff --git a/tests/init/neg/cold-insert-hot-array.scala b/tests/init/warn/cold-insert-hot-array.scala similarity index 84% rename from tests/init/neg/cold-insert-hot-array.scala rename to tests/init/warn/cold-insert-hot-array.scala index a11d92b2a265..a6c4b4aaebfd 100644 --- a/tests/init/neg/cold-insert-hot-array.scala +++ b/tests/init/warn/cold-insert-hot-array.scala @@ -3,7 +3,7 @@ object A: class B { var a = new Array[B](2) - A.foo(this, a) // error + A.foo(this, a) // warn println(a(0).i) val i = 99 } diff --git a/tests/init/neg/cycle-structure.scala b/tests/init/warn/cycle-structure.scala similarity index 64% rename from tests/init/neg/cycle-structure.scala rename to tests/init/warn/cycle-structure.scala index 1a02a31188b1..f3eb7560f414 100644 --- a/tests/init/neg/cycle-structure.scala +++ b/tests/init/warn/cycle-structure.scala @@ -1,11 +1,11 @@ case class A(b: B) { val x1 = b.x - val x = B(this) // error + val x = B(this) // warn val y = x.a } case class B(a: A) { val x1 = a.x - val x = A(this) // error + val x = A(this) // warn val h = x.b } diff --git a/tests/init/neg/cycle.scala b/tests/init/warn/cycle.scala similarity index 59% rename from tests/init/neg/cycle.scala rename to tests/init/warn/cycle.scala index 7d871795f0a2..f3733df03da4 100644 --- a/tests/init/neg/cycle.scala +++ b/tests/init/warn/cycle.scala @@ -1,11 +1,11 @@ class A(x: B) { println(x.b) - val a = new B(this) // error + val a = new B(this) // warn val d = a.b } class B(x: A) { println(x.a) - val b = new A(this) // error + val b = new A(this) // warn val d = b.a } \ No newline at end of file diff --git a/tests/init/neg/default-this.scala b/tests/init/warn/default-this.scala similarity index 89% rename from tests/init/neg/default-this.scala rename to tests/init/warn/default-this.scala index 1b0173fc134f..26b669bcbd40 100644 --- a/tests/init/neg/default-this.scala +++ b/tests/init/warn/default-this.scala @@ -6,7 +6,7 @@ class A { class B extends A { def updateThenCompare(c: Int): Boolean = { x = c - compare() // error + compare() // warn } val result = updateThenCompare(5) } diff --git a/tests/init/neg/early-promote.scala b/tests/init/warn/early-promote.scala similarity index 84% rename from tests/init/neg/early-promote.scala rename to tests/init/warn/early-promote.scala index fd226df347fb..1cd608d3f63b 100644 --- a/tests/init/neg/early-promote.scala +++ b/tests/init/warn/early-promote.scala @@ -24,7 +24,7 @@ class A { // checking A def c = new C } val b = new B() - println(b) // error: the checker simply issue warnings for objects that contain inner classes + println(b) // warn: the checker simply issue warnings for objects that contain inner classes val af = 42 } diff --git a/tests/init/warn/early-promote2.scala b/tests/init/warn/early-promote2.scala new file mode 100644 index 000000000000..8326aa851e21 --- /dev/null +++ b/tests/init/warn/early-promote2.scala @@ -0,0 +1,6 @@ +class M { + println(this) // warn + foo() + private val a = 5 // warn + def foo() = a +} diff --git a/tests/init/neg/early-promote3.scala b/tests/init/warn/early-promote3.scala similarity index 77% rename from tests/init/neg/early-promote3.scala rename to tests/init/warn/early-promote3.scala index ecb5bbedca69..a81b261d78ba 100644 --- a/tests/init/neg/early-promote3.scala +++ b/tests/init/warn/early-promote3.scala @@ -6,6 +6,6 @@ abstract class A { } class M extends A { - def bar() = promote(this) // error + def bar() = promote(this) // warn def promote(m: M) = m.foo() } diff --git a/tests/init/neg/early-promote4.scala b/tests/init/warn/early-promote4.scala similarity index 87% rename from tests/init/neg/early-promote4.scala rename to tests/init/warn/early-promote4.scala index 487a75c5516f..9d215b308200 100644 --- a/tests/init/neg/early-promote4.scala +++ b/tests/init/warn/early-promote4.scala @@ -16,5 +16,5 @@ class Outer { class Dummy { val m: Int = n + 4 - val n: Int = 10 // error + val n: Int = 10 // warn } diff --git a/tests/init/neg/early-promote5.scala b/tests/init/warn/early-promote5.scala similarity index 80% rename from tests/init/neg/early-promote5.scala rename to tests/init/warn/early-promote5.scala index 3f850b623ea3..bbcc63527fdf 100644 --- a/tests/init/neg/early-promote5.scala +++ b/tests/init/warn/early-promote5.scala @@ -14,11 +14,11 @@ class Outer { class Container { val o = new Outer - val m = new o.M(this) // error + val m = new o.M(this) // warn val s = "hello" } class Dummy { val m: Int = n + 4 - val n: Int = 10 // error + val n: Int = 10 // warn } diff --git a/tests/init/neg/escape1.scala b/tests/init/warn/escape1.scala similarity index 71% rename from tests/init/neg/escape1.scala rename to tests/init/warn/escape1.scala index 588f0933cfc3..ff0cb4ea3816 100644 --- a/tests/init/neg/escape1.scala +++ b/tests/init/warn/escape1.scala @@ -1,5 +1,5 @@ class Foo { - val a = Foo.bar(this) // error + val a = Foo.bar(this) // warn val b = "hello" } diff --git a/tests/init/neg/features-high-order.scala b/tests/init/warn/features-high-order.scala similarity index 81% rename from tests/init/neg/features-high-order.scala rename to tests/init/warn/features-high-order.scala index 60c15545cc14..6f758aeb6785 100644 --- a/tests/init/neg/features-high-order.scala +++ b/tests/init/warn/features-high-order.scala @@ -4,6 +4,6 @@ abstract class Parent { } class Child extends Parent { val a = f() - val b = "hello" // error + val b = "hello" // warn def message: String = b } diff --git a/tests/init/neg/features-linearization.scala b/tests/init/warn/features-linearization.scala similarity index 82% rename from tests/init/neg/features-linearization.scala rename to tests/init/warn/features-linearization.scala index 77d6a231d79a..d3c7b7b0db47 100644 --- a/tests/init/neg/features-linearization.scala +++ b/tests/init/warn/features-linearization.scala @@ -1,5 +1,5 @@ trait TA { - val x = "world" // error + val x = "world" // warn } trait TB { diff --git a/tests/init/neg/features-trees.scala b/tests/init/warn/features-trees.scala similarity index 76% rename from tests/init/neg/features-trees.scala rename to tests/init/warn/features-trees.scala index 867e6636bb12..32026785b3e5 100644 --- a/tests/init/neg/features-trees.scala +++ b/tests/init/warn/features-trees.scala @@ -2,5 +2,5 @@ class Trees { class ValDef { counter += 1 } class EmptyValDef extends ValDef val theEmptyValDef = new EmptyValDef - private var counter = 0 // error + private var counter = 0 // warn } diff --git a/tests/init/neg/final-fields.scala b/tests/init/warn/final-fields.scala similarity index 72% rename from tests/init/neg/final-fields.scala rename to tests/init/warn/final-fields.scala index 174ee9eeb79d..7d9d6280be70 100644 --- a/tests/init/neg/final-fields.scala +++ b/tests/init/warn/final-fields.scala @@ -29,10 +29,10 @@ object Test1 extends U { } object Test extends T { - override final val f1 = /*super.f1*/ 1 + f2 // error - override final val f2 = 2 // error - override final val f3 = {println(3); 3} // error - override val f4 = f3 + 1 // error + override final val f1 = /*super.f1*/ 1 + f2 // warn + override final val f2 = 2 // warn + override final val f3 = {println(3); 3} // warn + override val f4 = f3 + 1 // warn def g: 3 = { println("g"); 3 } final val x = g + 1 diff --git a/tests/init/neg/flow2.scala b/tests/init/warn/flow2.scala similarity index 73% rename from tests/init/neg/flow2.scala rename to tests/init/warn/flow2.scala index a0c5f89601ee..3bb4fa110e50 100644 --- a/tests/init/neg/flow2.scala +++ b/tests/init/warn/flow2.scala @@ -1,6 +1,6 @@ class Foo { val len = list.size - val list = List(4, 6) // error + val list = List(4, 6) // warn lazy val len2 = list2.size // ok val list2 = List(4, 6) diff --git a/tests/init/neg/function-loop.scala b/tests/init/warn/function-loop.scala similarity index 78% rename from tests/init/neg/function-loop.scala rename to tests/init/warn/function-loop.scala index 12048860c3a6..981e8f8215c5 100644 --- a/tests/init/neg/function-loop.scala +++ b/tests/init/warn/function-loop.scala @@ -2,5 +2,5 @@ class Foo { val f: Int => Foo = (x: Int) => if x > 0 then f(x) else this f(10).n - val n = 10 // error + val n = 10 // warn } \ No newline at end of file diff --git a/tests/init/neg/function1.scala b/tests/init/warn/function1.scala similarity index 60% rename from tests/init/neg/function1.scala rename to tests/init/warn/function1.scala index 15427f3de750..29a139b39bd2 100644 --- a/tests/init/neg/function1.scala +++ b/tests/init/warn/function1.scala @@ -4,9 +4,9 @@ class Foo { val fun2: Int => Int = n => 1 + n + list.size fun2(5) - List(5, 9).map(n => 2 + n + list.size) // error + List(5, 9).map(n => 2 + n + list.size) // warn - final val list = List(1, 2, 3) // error + final val list = List(1, 2, 3) // warn List(5, 9).map(n => 3 + n + list.size) } \ No newline at end of file diff --git a/tests/init/neg/function10.scala b/tests/init/warn/function10.scala similarity index 53% rename from tests/init/neg/function10.scala rename to tests/init/warn/function10.scala index 3d8a72aaa1ea..22260bb5d622 100644 --- a/tests/init/neg/function10.scala +++ b/tests/init/warn/function10.scala @@ -1,5 +1,5 @@ class Base { self => - (0 to 10).foreach { i => // error + (0 to 10).foreach { i => // warn println(a) } diff --git a/tests/init/neg/function11.scala b/tests/init/warn/function11.scala similarity index 89% rename from tests/init/neg/function11.scala rename to tests/init/warn/function11.scala index 278192d003aa..a50f7937b562 100644 --- a/tests/init/neg/function11.scala +++ b/tests/init/warn/function11.scala @@ -1,7 +1,7 @@ final class Capture { private var m: Boolean = false - (0 to 10).foreach { i => // error + (0 to 10).foreach { i => // warn f() } diff --git a/tests/init/neg/function2.scala b/tests/init/warn/function2.scala similarity index 70% rename from tests/init/neg/function2.scala rename to tests/init/warn/function2.scala index 0a0f44e2744e..045eb8f4289e 100644 --- a/tests/init/neg/function2.scala +++ b/tests/init/warn/function2.scala @@ -2,5 +2,5 @@ final class Foo { def fun: Int => Int = n => n + x.size fun(5) - val x = "hello" // error + val x = "hello" // warn } \ No newline at end of file diff --git a/tests/init/neg/hybrid1.scala b/tests/init/warn/hybrid1.scala similarity index 87% rename from tests/init/neg/hybrid1.scala rename to tests/init/warn/hybrid1.scala index 94c7a43bfbcd..f1a4665954c9 100644 --- a/tests/init/neg/hybrid1.scala +++ b/tests/init/warn/hybrid1.scala @@ -17,5 +17,5 @@ class Y { new C - val n = 10 // error + val n = 10 // warn } diff --git a/tests/init/neg/hybrid2.scala b/tests/init/warn/hybrid2.scala similarity index 84% rename from tests/init/neg/hybrid2.scala rename to tests/init/warn/hybrid2.scala index a9f8246fd58d..6d901d810a64 100644 --- a/tests/init/neg/hybrid2.scala +++ b/tests/init/warn/hybrid2.scala @@ -15,5 +15,5 @@ class Y { val x = new X x.b.g - val n = 10 // error + val n = 10 // warn } diff --git a/tests/init/neg/hybrid4.scala b/tests/init/warn/hybrid4.scala similarity index 75% rename from tests/init/neg/hybrid4.scala rename to tests/init/warn/hybrid4.scala index 6243fbf2d5f4..8237d0e8244a 100644 --- a/tests/init/neg/hybrid4.scala +++ b/tests/init/warn/hybrid4.scala @@ -8,5 +8,5 @@ class Foo { } val bar: Bar = new Bar - val list = List(1, 2, 3) // error + val list = List(1, 2, 3) // warn } diff --git a/tests/init/neg/hybrid5.scala b/tests/init/warn/hybrid5.scala similarity index 86% rename from tests/init/neg/hybrid5.scala rename to tests/init/warn/hybrid5.scala index 54c781b8835d..4f7f5baad771 100644 --- a/tests/init/neg/hybrid5.scala +++ b/tests/init/warn/hybrid5.scala @@ -15,5 +15,5 @@ class Foo { def g = new Foo.this.Inner } - val list = List(1, 2, 3) // error + val list = List(1, 2, 3) // warn } diff --git a/tests/init/neg/hybrid6.scala b/tests/init/warn/hybrid6.scala similarity index 81% rename from tests/init/neg/hybrid6.scala rename to tests/init/warn/hybrid6.scala index bbecc16942e5..58cbaa76979f 100644 --- a/tests/init/neg/hybrid6.scala +++ b/tests/init/warn/hybrid6.scala @@ -11,5 +11,5 @@ class Foo { def g = list } - val list = List(1, 2, 3) // error + val list = List(1, 2, 3) // warn } diff --git a/tests/init/neg/i10549b.scala b/tests/init/warn/i10549b.scala similarity index 81% rename from tests/init/neg/i10549b.scala rename to tests/init/warn/i10549b.scala index 7353844b3927..b0dd305c7e27 100644 --- a/tests/init/neg/i10549b.scala +++ b/tests/init/warn/i10549b.scala @@ -4,6 +4,6 @@ class Wrap { abstract class E[+T] { def foo: T } object E { final val A: E[Nothing] = new E { def foo = ref } - val ref = qux(A) // error + val ref = qux(A) // warn } } diff --git a/tests/init/neg/i11572.scala b/tests/init/warn/i11572.scala similarity index 90% rename from tests/init/neg/i11572.scala rename to tests/init/warn/i11572.scala index 59fa3c1fbc43..2a32a8bdd540 100644 --- a/tests/init/neg/i11572.scala +++ b/tests/init/warn/i11572.scala @@ -5,7 +5,7 @@ class A { trait Bounded { type T >: Cov[Int] <: Cov[String] } - val t: Bounded = new Bounded { // error + val t: Bounded = new Bounded { // warn // Note: using this instead of t produces an error (as expected) override type T >: t.T <: t.T } diff --git a/tests/init/neg/i12544.scala b/tests/init/warn/i12544.scala similarity index 86% rename from tests/init/neg/i12544.scala rename to tests/init/warn/i12544.scala index 2692c27134e0..4856f653a912 100644 --- a/tests/init/neg/i12544.scala +++ b/tests/init/warn/i12544.scala @@ -13,7 +13,7 @@ object Enum: def f(e: Enum): Enum = e class B() { def foo() = n + 1 } - g(new B()) // error + g(new B()) // warn val n: Int = 10 @main def main(): Unit = println(Enum.b) diff --git a/tests/init/neg/i15363.scala b/tests/init/warn/i15363.scala similarity index 78% rename from tests/init/neg/i15363.scala rename to tests/init/warn/i15363.scala index 01a2bdfcf530..87ca08ea916e 100644 --- a/tests/init/neg/i15363.scala +++ b/tests/init/warn/i15363.scala @@ -1,6 +1,6 @@ class A: // should report one error here - val b = new B(this) // error + val b = new B(this) // warn val m = 10 val n = 20 diff --git a/tests/init/neg/i15459.scala b/tests/init/warn/i15459.scala similarity index 81% rename from tests/init/neg/i15459.scala rename to tests/init/warn/i15459.scala index 4d54f31f7af8..72779ef0c7c1 100644 --- a/tests/init/neg/i15459.scala +++ b/tests/init/warn/i15459.scala @@ -1,6 +1,6 @@ class Sup: val a = 10 - println(this) // error + println(this) // warn class Sub extends Sup: val b = 20 diff --git a/tests/init/warn/i15883.scala b/tests/init/warn/i15883.scala new file mode 100644 index 000000000000..71c46494dbac --- /dev/null +++ b/tests/init/warn/i15883.scala @@ -0,0 +1,2 @@ +val a = b +val b = 1 // warn diff --git a/tests/init/neg/i4031.scala b/tests/init/warn/i4031.scala similarity index 78% rename from tests/init/neg/i4031.scala rename to tests/init/warn/i4031.scala index 8340296340e7..d43ea244b65d 100644 --- a/tests/init/neg/i4031.scala +++ b/tests/init/warn/i4031.scala @@ -1,7 +1,7 @@ object App { trait A { type L >: Any} def upcast(a: A, x: Any): a.L = x - val p: A { type L <: Nothing } = p // error + val p: A { type L <: Nothing } = p // warn def coerce(x: Any): Int = upcast(p, x) def main(args: Array[String]): Unit = { diff --git a/tests/init/neg/i4042.scala b/tests/init/warn/i4042.scala similarity index 87% rename from tests/init/neg/i4042.scala rename to tests/init/warn/i4042.scala index 58c884a5690d..284f97a352c9 100644 --- a/tests/init/neg/i4042.scala +++ b/tests/init/warn/i4042.scala @@ -5,7 +5,7 @@ object App { class T[A <: X](val a: A)(val value: a.R) - object O { val x : Y & X = x } // error + object O { val x : Y & X = x } // warn val a = new T[Y & X](O.x)(u) a.value diff --git a/tests/init/neg/i50.scala b/tests/init/warn/i50.scala similarity index 64% rename from tests/init/neg/i50.scala rename to tests/init/warn/i50.scala index 9131fb263f48..7c860bc007fa 100644 --- a/tests/init/neg/i50.scala +++ b/tests/init/warn/i50.scala @@ -1,5 +1,5 @@ class C[T] { val a: T = method def method = b - val b: T = a // error + val b: T = a // warn } \ No newline at end of file diff --git a/tests/init/neg/i5854.scala b/tests/init/warn/i5854.scala similarity index 63% rename from tests/init/neg/i5854.scala rename to tests/init/warn/i5854.scala index 05fa1033dd2c..60060394bdcd 100644 --- a/tests/init/neg/i5854.scala +++ b/tests/init/warn/i5854.scala @@ -1,5 +1,5 @@ class B { val a: String = (((1: Any): b.A): Nothing): String - val b: { type A >: Any <: Nothing } = loop() // error + val b: { type A >: Any <: Nothing } = loop() // warn def loop(): Nothing = loop() } diff --git a/tests/init/neg/inherit-non-hot.scala b/tests/init/warn/inherit-non-hot.scala similarity index 86% rename from tests/init/neg/inherit-non-hot.scala rename to tests/init/warn/inherit-non-hot.scala index 44be67351630..28520ea9c621 100644 --- a/tests/init/neg/inherit-non-hot.scala +++ b/tests/init/warn/inherit-non-hot.scala @@ -3,7 +3,7 @@ object Foo { abstract class A { var b: B = null def toB: B = - if b == null then b = new B(this) // error + if b == null then b = new B(this) // warn b } diff --git a/tests/init/neg/inlined-method.scala b/tests/init/warn/inlined-method.scala similarity index 70% rename from tests/init/neg/inlined-method.scala rename to tests/init/warn/inlined-method.scala index 4af473837f0f..e6ea86ba33c9 100644 --- a/tests/init/neg/inlined-method.scala +++ b/tests/init/warn/inlined-method.scala @@ -5,4 +5,4 @@ class InlineError { object Assertion: transparent inline def failAssert(inline message: => Any): Unit = - scala.runtime.Scala3RunTime.assertFailed(message) // error \ No newline at end of file + scala.runtime.Scala3RunTime.assertFailed(message) // warn \ No newline at end of file diff --git a/tests/init/neg/inner-case.scala b/tests/init/warn/inner-case.scala similarity index 82% rename from tests/init/neg/inner-case.scala rename to tests/init/warn/inner-case.scala index 20a9b1d2684f..317d77376aa9 100644 --- a/tests/init/neg/inner-case.scala +++ b/tests/init/warn/inner-case.scala @@ -4,7 +4,7 @@ class Foo { } val a = Inner(5) // ok - println(a) // error + println(a) // warn var count = 0 println(a) // ok diff --git a/tests/init/neg/inner-first.scala b/tests/init/warn/inner-first.scala similarity index 69% rename from tests/init/neg/inner-first.scala rename to tests/init/warn/inner-first.scala index cd7b28a30b62..be3c7d824dc5 100644 --- a/tests/init/neg/inner-first.scala +++ b/tests/init/warn/inner-first.scala @@ -1,6 +1,6 @@ class A: class B: - println(this) // error + println(this) // warn val n = 10 def foo() = println(m) new B diff --git a/tests/init/neg/inner-loop.scala b/tests/init/warn/inner-loop.scala similarity index 88% rename from tests/init/neg/inner-loop.scala rename to tests/init/warn/inner-loop.scala index c6d5c615580c..8b63eb9507dc 100644 --- a/tests/init/neg/inner-loop.scala +++ b/tests/init/warn/inner-loop.scala @@ -3,7 +3,7 @@ class Outer { outer => val x = 5 + outer.n } val inner = new Inner - val n = 6 // error + val n = 6 // warn } class Outer2 { outer => @@ -28,7 +28,7 @@ class Test { // If we change policy to check more eagerly, // the check has to avoid loop here. - println(outer) // error + println(outer) // warn val m = 10 } \ No newline at end of file diff --git a/tests/init/neg/inner-new.scala b/tests/init/warn/inner-new.scala similarity index 80% rename from tests/init/neg/inner-new.scala rename to tests/init/warn/inner-new.scala index d09dc5193dbf..2ecaf5e544e1 100644 --- a/tests/init/neg/inner-new.scala +++ b/tests/init/warn/inner-new.scala @@ -4,7 +4,7 @@ class Foo { } val a = new Inner // ok - println(a) // error + println(a) // warn var count = 0 println(a) // ok diff --git a/tests/init/neg/inner-pat_iuli.scala b/tests/init/warn/inner-pat_iuli.scala similarity index 92% rename from tests/init/neg/inner-pat_iuli.scala rename to tests/init/warn/inner-pat_iuli.scala index e5010cca98ec..bd84fee43d97 100644 --- a/tests/init/neg/inner-pat_iuli.scala +++ b/tests/init/warn/inner-pat_iuli.scala @@ -20,5 +20,5 @@ trait Blox { self: MyCodes => class MyCodes extends AnyRef with Ops with Blox { val a = b - val b: Int = 10 // error + val b: Int = 10 // warn } diff --git a/tests/init/neg/inner1.scala b/tests/init/warn/inner1.scala similarity index 80% rename from tests/init/neg/inner1.scala rename to tests/init/warn/inner1.scala index d39c3ba2ac77..9220eda882cf 100644 --- a/tests/init/neg/inner1.scala +++ b/tests/init/warn/inner1.scala @@ -1,7 +1,7 @@ class Foo { new this.Inner - val list = List(1, 2, 3) // error, as Inner access `this.list` + val list = List(1, 2, 3) // warn, as Inner access `this.list` val inner: Inner = new this.Inner // ok, `list` is instantiated lib.escape(inner) // ok, can promote inner early diff --git a/tests/init/neg/inner11.scala b/tests/init/warn/inner11.scala similarity index 93% rename from tests/init/neg/inner11.scala rename to tests/init/warn/inner11.scala index 04098be8a3fd..2ea6d25f5d6f 100644 --- a/tests/init/neg/inner11.scala +++ b/tests/init/warn/inner11.scala @@ -12,7 +12,7 @@ object NameKinds { class ClassifiedNameKind(tag: Int, val infoString: String) extends NameKind(tag) { type ThisInfo = Info val info: Info = new Info - println(info.kind) // error + println(info.kind) // warn val n = 10 } } diff --git a/tests/init/neg/inner15.scala b/tests/init/warn/inner15.scala similarity index 84% rename from tests/init/neg/inner15.scala rename to tests/init/warn/inner15.scala index 59d1daac404f..7c01cd8275d7 100644 --- a/tests/init/neg/inner15.scala +++ b/tests/init/warn/inner15.scala @@ -15,5 +15,5 @@ class B extends A { new Inner1 new Inner2 - override val x = "world" // error + override val x = "world" // warn } \ No newline at end of file diff --git a/tests/init/neg/inner16.scala b/tests/init/warn/inner16.scala similarity index 87% rename from tests/init/neg/inner16.scala rename to tests/init/warn/inner16.scala index 61271396a074..c49cba8a88be 100644 --- a/tests/init/neg/inner16.scala +++ b/tests/init/warn/inner16.scala @@ -13,5 +13,5 @@ class A { val inner = new Inner val b = new O.B - val y = 10 // error + val y = 10 // warn } \ No newline at end of file diff --git a/tests/init/neg/inner17.scala b/tests/init/warn/inner17.scala similarity index 78% rename from tests/init/neg/inner17.scala rename to tests/init/warn/inner17.scala index 756278cd5130..4daad38ea36b 100644 --- a/tests/init/neg/inner17.scala +++ b/tests/init/warn/inner17.scala @@ -9,5 +9,5 @@ class A { } class C extends A { - override val f: Int = 20 // error + override val f: Int = 20 // warn } \ No newline at end of file diff --git a/tests/init/neg/inner19.scala b/tests/init/warn/inner19.scala similarity index 79% rename from tests/init/neg/inner19.scala rename to tests/init/warn/inner19.scala index 2e502eddc24c..91cf406dbc6a 100644 --- a/tests/init/neg/inner19.scala +++ b/tests/init/warn/inner19.scala @@ -15,5 +15,5 @@ class A { class B extends A { println((new O.B).f) O.C(4) - override val n = 50 // error because line 16 + override val n = 50 // warn because line 16 } \ No newline at end of file diff --git a/tests/init/neg/inner20.scala b/tests/init/warn/inner20.scala similarity index 84% rename from tests/init/neg/inner20.scala rename to tests/init/warn/inner20.scala index 1553e09eeeb0..2a868f8b88f5 100644 --- a/tests/init/neg/inner20.scala +++ b/tests/init/warn/inner20.scala @@ -14,5 +14,5 @@ class A { class B extends A { val o = new O println((new o.B).f) - override val n = 50 // error + override val n = 50 // warn } \ No newline at end of file diff --git a/tests/init/neg/inner21.scala b/tests/init/warn/inner21.scala similarity index 71% rename from tests/init/neg/inner21.scala rename to tests/init/warn/inner21.scala index c2277163acc3..232de8fbd0cc 100644 --- a/tests/init/neg/inner21.scala +++ b/tests/init/warn/inner21.scala @@ -8,7 +8,7 @@ class X { A.foo A.bar - val name = "jack" // error + val name = "jack" // warn } @@ -22,5 +22,5 @@ class Y { (new A).foo (new A).bar - val name = "jack" // error + val name = "jack" // warn } \ No newline at end of file diff --git a/tests/init/neg/inner22.scala b/tests/init/warn/inner22.scala similarity index 92% rename from tests/init/neg/inner22.scala rename to tests/init/warn/inner22.scala index aa5a381f2d49..055a9d9bed7d 100644 --- a/tests/init/neg/inner22.scala +++ b/tests/init/warn/inner22.scala @@ -28,5 +28,5 @@ class D { new C - val x = 10 // error + val x = 10 // warn } \ No newline at end of file diff --git a/tests/init/neg/inner23.scala b/tests/init/warn/inner23.scala similarity index 77% rename from tests/init/neg/inner23.scala rename to tests/init/warn/inner23.scala index 5d373c649ce2..a5985a8d805c 100644 --- a/tests/init/neg/inner23.scala +++ b/tests/init/warn/inner23.scala @@ -9,5 +9,5 @@ class Trees { } val theEmptyValDef = new EmptyValDef - val name = "hello" // error + val name = "hello" // warn } diff --git a/tests/init/neg/inner24.scala b/tests/init/warn/inner24.scala similarity index 84% rename from tests/init/neg/inner24.scala rename to tests/init/warn/inner24.scala index f8a60c1bb311..3c28546b10cc 100644 --- a/tests/init/neg/inner24.scala +++ b/tests/init/warn/inner24.scala @@ -14,5 +14,5 @@ class Bar extends Foo { val b = new B override def foo(x: Int) = x + id - val id = 100 // error + val id = 100 // warn } \ No newline at end of file diff --git a/tests/init/neg/inner25.scala b/tests/init/warn/inner25.scala similarity index 91% rename from tests/init/neg/inner25.scala rename to tests/init/warn/inner25.scala index 8cf99539b849..a9538dee6462 100644 --- a/tests/init/neg/inner25.scala +++ b/tests/init/warn/inner25.scala @@ -8,7 +8,7 @@ class A[K, V] { self => } } - println(new O) // error + println(new O) // warn val a = 10 } \ No newline at end of file diff --git a/tests/init/neg/inner29.scala b/tests/init/warn/inner29.scala similarity index 83% rename from tests/init/neg/inner29.scala rename to tests/init/warn/inner29.scala index 740352db1e4e..03350a5266b8 100644 --- a/tests/init/neg/inner29.scala +++ b/tests/init/warn/inner29.scala @@ -15,7 +15,7 @@ class C extends B(5) { override def f: Int = x } - val a = new E // error: init too late + val a = new E // warn: init too late val x = 10 } \ No newline at end of file diff --git a/tests/init/neg/inner30.scala b/tests/init/warn/inner30.scala similarity index 93% rename from tests/init/neg/inner30.scala rename to tests/init/warn/inner30.scala index 01bb5754d485..84cc46cbca1a 100644 --- a/tests/init/neg/inner30.scala +++ b/tests/init/warn/inner30.scala @@ -17,5 +17,5 @@ object Scanners { } val m: Int = n * 2 - val n = 10 // error + val n = 10 // warn } \ No newline at end of file diff --git a/tests/init/neg/inner4.scala b/tests/init/warn/inner4.scala similarity index 77% rename from tests/init/neg/inner4.scala rename to tests/init/warn/inner4.scala index 5fc4d2b9e053..66a39da03909 100644 --- a/tests/init/neg/inner4.scala +++ b/tests/init/warn/inner4.scala @@ -6,5 +6,5 @@ class Foo(val foo1: Foo) { new this.Inner new foo1.Inner - val name = "hello" // error + val name = "hello" // warn } diff --git a/tests/init/neg/inner5.scala b/tests/init/warn/inner5.scala similarity index 76% rename from tests/init/neg/inner5.scala rename to tests/init/warn/inner5.scala index 20f4aa1bdaeb..f91573e98cb6 100644 --- a/tests/init/neg/inner5.scala +++ b/tests/init/warn/inner5.scala @@ -4,7 +4,7 @@ class Foo { } new B - val a = 3 // error + val a = 3 // warn def foo(x: Int) = a + x } \ No newline at end of file diff --git a/tests/init/neg/inner6.scala b/tests/init/warn/inner6.scala similarity index 91% rename from tests/init/neg/inner6.scala rename to tests/init/warn/inner6.scala index 42b68fe2d8ea..7f0436dc6924 100644 --- a/tests/init/neg/inner6.scala +++ b/tests/init/warn/inner6.scala @@ -18,6 +18,6 @@ class Child extends Parent { new InnerA new InnerB - val x = 10 // error + val x = 10 // warn override def foo: Int = x * x } diff --git a/tests/init/neg/inner7.scala b/tests/init/warn/inner7.scala similarity index 81% rename from tests/init/neg/inner7.scala rename to tests/init/warn/inner7.scala index bdac38cc31d8..5e0df53f0888 100644 --- a/tests/init/neg/inner7.scala +++ b/tests/init/warn/inner7.scala @@ -11,6 +11,6 @@ class Child extends Parent { class InnerA extends Inner1 new InnerA - override val list = List(4, 5) // error + override val list = List(4, 5) // warn override def foo: Int = list.size } diff --git a/tests/init/neg/inner9.scala b/tests/init/warn/inner9.scala similarity index 83% rename from tests/init/neg/inner9.scala rename to tests/init/warn/inner9.scala index db5198ea0138..a7379ef4b7fe 100644 --- a/tests/init/neg/inner9.scala +++ b/tests/init/warn/inner9.scala @@ -6,7 +6,7 @@ object Flags { new Flags.Inner val a = this.b + 3 - val b = 5 // error + val b = 5 // warn } object Flags2 { diff --git a/tests/init/neg/insert-cold-subtype-to-array.scala b/tests/init/warn/insert-cold-subtype-to-array.scala similarity index 84% rename from tests/init/neg/insert-cold-subtype-to-array.scala rename to tests/init/warn/insert-cold-subtype-to-array.scala index 82eee1935a95..6f4bf9bca73e 100644 --- a/tests/init/neg/insert-cold-subtype-to-array.scala +++ b/tests/init/warn/insert-cold-subtype-to-array.scala @@ -3,6 +3,6 @@ object A: class B: var a = new Array[B](2) - A.foo(this, a) // error + A.foo(this, a) // warn println(a(0).i) val i = 99 \ No newline at end of file diff --git a/tests/init/neg/java1.scala b/tests/init/warn/java1.scala similarity index 91% rename from tests/init/neg/java1.scala rename to tests/init/warn/java1.scala index 1eff09cb6ff1..36044413d2ea 100644 --- a/tests/init/neg/java1.scala +++ b/tests/init/warn/java1.scala @@ -8,4 +8,4 @@ class A extends Spliterator.OfDouble: def tryAdvance(x$0: java.util.function.DoubleConsumer): Boolean = false val m = n + 1 - val n = 10 // error + val n = 10 // warn diff --git a/tests/init/neg/lazy.scala b/tests/init/warn/lazy.scala similarity index 69% rename from tests/init/neg/lazy.scala rename to tests/init/warn/lazy.scala index 0f3047bc0d1b..a895714b0f9a 100644 --- a/tests/init/neg/lazy.scala +++ b/tests/init/warn/lazy.scala @@ -1,11 +1,11 @@ class Foo { val len = list.size - val list = List(4, 6) // error + val list = List(4, 6) // warn lazy val len2 = list2.size // ok val list2 = List(4, 6) lazy val len3 = name.size val len4 = len3 + 4 - val name = "hello" // error + val name = "hello" // warn } diff --git a/tests/init/neg/lazylist2.scala b/tests/init/warn/lazylist2.scala similarity index 89% rename from tests/init/neg/lazylist2.scala rename to tests/init/warn/lazylist2.scala index 18072676fa4c..618364f49a98 100644 --- a/tests/init/neg/lazylist2.scala +++ b/tests/init/warn/lazylist2.scala @@ -26,7 +26,7 @@ final class Test1 { a.head // ok b.head // ok - val x: LazyList[Int] = 5 #:: y // error + val x: LazyList[Int] = 5 #:: y // warn val y: LazyList[Int] = 10 #:: x } @@ -37,7 +37,7 @@ final class Test2 { } final class Test3 { - val a: LazyList[Int] = n #:: (a: @unchecked) // error + val a: LazyList[Int] = n #:: (a: @unchecked) // warn a.head val n: Int = 20 } \ No newline at end of file diff --git a/tests/init/neg/leak-warm.scala b/tests/init/warn/leak-warm.scala similarity index 91% rename from tests/init/neg/leak-warm.scala rename to tests/init/warn/leak-warm.scala index bc5539ce9c0b..712a4e5fed69 100644 --- a/tests/init/neg/leak-warm.scala +++ b/tests/init/warn/leak-warm.scala @@ -16,5 +16,5 @@ object leakWarm { val c = new C(1, 2) val d = new D(3, 4) val l: List[A] = List(c, d) - val l2 = l.map(_.m()) // error + val l2 = l.map(_.m()) // warn } diff --git a/tests/init/neg/local-class.scala b/tests/init/warn/local-class.scala similarity index 84% rename from tests/init/neg/local-class.scala rename to tests/init/warn/local-class.scala index 20e77912dce8..14f203a738c3 100644 --- a/tests/init/neg/local-class.scala +++ b/tests/init/warn/local-class.scala @@ -12,5 +12,5 @@ class Outer { foo - val n = 10 // error + val n = 10 // warn } diff --git a/tests/init/neg/override1.scala b/tests/init/warn/override1.scala similarity index 84% rename from tests/init/neg/override1.scala rename to tests/init/warn/override1.scala index c9c9fed3ecd8..b247470c19d5 100644 --- a/tests/init/neg/override1.scala +++ b/tests/init/warn/override1.scala @@ -15,6 +15,6 @@ class Qux(x: Int) extends Bar { } class Yun extends Bar { - override val x: Int = 10 // error + override val x: Int = 10 // warn def foo(n: Int) = x + n } diff --git a/tests/init/neg/override10.scala b/tests/init/warn/override10.scala similarity index 75% rename from tests/init/neg/override10.scala rename to tests/init/warn/override10.scala index 6b8b0e7101db..0c49d7c63113 100644 --- a/tests/init/neg/override10.scala +++ b/tests/init/warn/override10.scala @@ -5,5 +5,5 @@ trait Foo { class Bar extends Foo { f() - val message = "hello" // error + val message = "hello" // warn } \ No newline at end of file diff --git a/tests/init/neg/override14.scala b/tests/init/warn/override14.scala similarity index 76% rename from tests/init/neg/override14.scala rename to tests/init/warn/override14.scala index 451a12087103..0d773e61f9b2 100644 --- a/tests/init/neg/override14.scala +++ b/tests/init/warn/override14.scala @@ -1,5 +1,5 @@ abstract class A { - val x = f(this) // error + val x = f(this) // warn val y = 10 def f(a: A): Int diff --git a/tests/init/neg/override15.scala b/tests/init/warn/override15.scala similarity index 81% rename from tests/init/neg/override15.scala rename to tests/init/warn/override15.scala index 0f22430cf6a6..ca3e32abb35e 100644 --- a/tests/init/neg/override15.scala +++ b/tests/init/warn/override15.scala @@ -1,6 +1,6 @@ abstract class A { val g = (n: Int) => n + y - val x: Int = f(g) // error + val x: Int = f(g) // warn val y: Int = 10 def f(m: Int => Int): Int diff --git a/tests/init/neg/override17.scala b/tests/init/warn/override17.scala similarity index 76% rename from tests/init/neg/override17.scala rename to tests/init/warn/override17.scala index 72bd8db9a246..cbeaaed37bea 100644 --- a/tests/init/neg/override17.scala +++ b/tests/init/warn/override17.scala @@ -3,7 +3,7 @@ class A { self : B => } trait B { - val x = 10 // error + val x = 10 // warn } class C extends A with B diff --git a/tests/init/neg/override18.scala b/tests/init/warn/override18.scala similarity index 88% rename from tests/init/neg/override18.scala rename to tests/init/warn/override18.scala index 61edaf6d8c8f..3c2ca3e7af5d 100644 --- a/tests/init/neg/override18.scala +++ b/tests/init/warn/override18.scala @@ -10,7 +10,7 @@ class B extends A { class C extends A { val x = f - val y = x // error + val y = x // warn def f: Int = y } diff --git a/tests/init/neg/override19.scala b/tests/init/warn/override19.scala similarity index 79% rename from tests/init/neg/override19.scala rename to tests/init/warn/override19.scala index 8e1f6a832323..61d17bb93597 100644 --- a/tests/init/neg/override19.scala +++ b/tests/init/warn/override19.scala @@ -5,6 +5,6 @@ abstract class A extends Product { case class B(x: Int, y: String) extends A case class C(x: Int) extends A { - val y = 10 // error + val y = 10 // warn def productArity: Int = y } \ No newline at end of file diff --git a/tests/init/neg/override2.scala b/tests/init/warn/override2.scala similarity index 89% rename from tests/init/neg/override2.scala rename to tests/init/warn/override2.scala index f9964f60ad29..3adae93c23c9 100644 --- a/tests/init/neg/override2.scala +++ b/tests/init/warn/override2.scala @@ -8,7 +8,7 @@ trait Foo { } class Bar extends Foo { - val y = "hello" // error + val y = "hello" // warn foo(5) bar(10) diff --git a/tests/init/neg/override20.scala b/tests/init/warn/override20.scala similarity index 75% rename from tests/init/neg/override20.scala rename to tests/init/warn/override20.scala index 65ece64c6020..4f1f7b452f75 100644 --- a/tests/init/neg/override20.scala +++ b/tests/init/warn/override20.scala @@ -2,7 +2,7 @@ class A { self : B => val y = f } -trait B(x: Int) { // error +trait B(x: Int) { // warn def f: Int = x } diff --git a/tests/init/neg/override21.scala b/tests/init/warn/override21.scala similarity index 86% rename from tests/init/neg/override21.scala rename to tests/init/warn/override21.scala index 332ce702a9fc..84c319949cb7 100644 --- a/tests/init/neg/override21.scala +++ b/tests/init/warn/override21.scala @@ -10,7 +10,7 @@ class Child extends Parent { this.z val m = this.x - val y = "hello" // error + val y = "hello" // warn def bar = y.size } \ No newline at end of file diff --git a/tests/init/neg/override22.scala b/tests/init/warn/override22.scala similarity index 87% rename from tests/init/neg/override22.scala rename to tests/init/warn/override22.scala index 7de6f03aa837..f7fc1b312e4e 100644 --- a/tests/init/neg/override22.scala +++ b/tests/init/warn/override22.scala @@ -9,7 +9,7 @@ class Child extends Parent { val y = "hello" this.foo - val m = this.x // error + val m = this.x // warn this.z def bar = m.size + 6 diff --git a/tests/init/neg/override23.scala b/tests/init/warn/override23.scala similarity index 87% rename from tests/init/neg/override23.scala rename to tests/init/warn/override23.scala index 3ada767bfafc..2af45c953ae5 100644 --- a/tests/init/neg/override23.scala +++ b/tests/init/warn/override23.scala @@ -10,7 +10,7 @@ class Child(o: String) extends Parent(o) { this.foo this.z - val y = "hello" // error + val y = "hello" // warn def bar = y.size } \ No newline at end of file diff --git a/tests/init/neg/override24.scala b/tests/init/warn/override24.scala similarity index 91% rename from tests/init/neg/override24.scala rename to tests/init/warn/override24.scala index 9adfac27bb02..feaa07396755 100644 --- a/tests/init/neg/override24.scala +++ b/tests/init/warn/override24.scala @@ -15,7 +15,7 @@ class Bar extends Foo { foo(4) - val name = "bar" // error + val name = "bar" // warn foo(4) } \ No newline at end of file diff --git a/tests/init/neg/override25.scala b/tests/init/warn/override25.scala similarity index 85% rename from tests/init/neg/override25.scala rename to tests/init/warn/override25.scala index 9554b4296a9f..e5d5d7f8e34f 100644 --- a/tests/init/neg/override25.scala +++ b/tests/init/warn/override25.scala @@ -1,4 +1,4 @@ -trait Foo(x: Int) { // error +trait Foo(x: Int) { // warn def name: String = "hello" def f: Int = x diff --git a/tests/init/neg/override26.scala b/tests/init/warn/override26.scala similarity index 85% rename from tests/init/neg/override26.scala rename to tests/init/warn/override26.scala index 37e83898bfcc..98a30477ee74 100644 --- a/tests/init/neg/override26.scala +++ b/tests/init/warn/override26.scala @@ -11,6 +11,6 @@ trait Bar { this: Foo => } class Qux extends Foo with Bar { - val x = "hello" // error + val x = "hello" // warn def title = x } diff --git a/tests/init/neg/override27.scala b/tests/init/warn/override27.scala similarity index 73% rename from tests/init/neg/override27.scala rename to tests/init/warn/override27.scala index 4b3a79ac233b..ae9ffe6ad63f 100644 --- a/tests/init/neg/override27.scala +++ b/tests/init/warn/override27.scala @@ -1,6 +1,6 @@ abstract class Base { def f: Int - val a = f // error + val a = f // warn } class Derived extends Base { @@ -10,7 +10,7 @@ class Derived extends Base { } class Derived2 extends Base { - val b = 30 // error + val b = 30 // warn def f = g def g: Int = b + a diff --git a/tests/init/neg/override28.scala b/tests/init/warn/override28.scala similarity index 72% rename from tests/init/neg/override28.scala rename to tests/init/warn/override28.scala index 8e77f8acb3ba..60ba0bff6c76 100644 --- a/tests/init/neg/override28.scala +++ b/tests/init/warn/override28.scala @@ -6,5 +6,5 @@ abstract class Base(val x: Int) { class C(x: Int) extends Base(x) { - val d = f // error + val d = f // warn } \ No newline at end of file diff --git a/tests/init/neg/override29.scala b/tests/init/warn/override29.scala similarity index 78% rename from tests/init/neg/override29.scala rename to tests/init/warn/override29.scala index e0070eb10218..5c640e2fcc0e 100644 --- a/tests/init/neg/override29.scala +++ b/tests/init/warn/override29.scala @@ -1,5 +1,5 @@ trait A { - var a = 20 // error + var a = 20 // warn def f: Int = a } diff --git a/tests/init/neg/override3.scala b/tests/init/warn/override3.scala similarity index 91% rename from tests/init/neg/override3.scala rename to tests/init/warn/override3.scala index 51759320e1b5..74fae84a547a 100644 --- a/tests/init/neg/override3.scala +++ b/tests/init/warn/override3.scala @@ -13,7 +13,7 @@ class Bar1 extends Foo { } class Qux extends Bar1 { - val u = "hello" // error + val u = "hello" // warn override def foo(n: Int) = u + "world" } diff --git a/tests/init/neg/override30.scala b/tests/init/warn/override30.scala similarity index 79% rename from tests/init/neg/override30.scala rename to tests/init/warn/override30.scala index adb4c2e00d2b..1677574130d4 100644 --- a/tests/init/neg/override30.scala +++ b/tests/init/warn/override30.scala @@ -10,6 +10,6 @@ class Bar extends Foo { } class Qux extends Bar { - val a = 30 // error + val a = 30 // warn override def f = a } \ No newline at end of file diff --git a/tests/init/neg/override31.scala b/tests/init/warn/override31.scala similarity index 84% rename from tests/init/neg/override31.scala rename to tests/init/warn/override31.scala index d902f4a6dc54..baffab3ad08e 100644 --- a/tests/init/neg/override31.scala +++ b/tests/init/warn/override31.scala @@ -11,5 +11,5 @@ class Bar extends Foo { class Qux extends Bar { init override def f = a - private val a = 30 // error + private val a = 30 // warn } \ No newline at end of file diff --git a/tests/init/neg/override32.scala b/tests/init/warn/override32.scala similarity index 80% rename from tests/init/neg/override32.scala rename to tests/init/warn/override32.scala index 09970a9bd392..b9a4e7eae178 100644 --- a/tests/init/neg/override32.scala +++ b/tests/init/warn/override32.scala @@ -6,7 +6,7 @@ trait Foo { } trait Bar { - final val m: String = "hello" // error + final val m: String = "hello" // warn def foo(n: Int) = m } diff --git a/tests/init/neg/override33.scala b/tests/init/warn/override33.scala similarity index 85% rename from tests/init/neg/override33.scala rename to tests/init/warn/override33.scala index b093dc570f04..04d27be6777c 100644 --- a/tests/init/neg/override33.scala +++ b/tests/init/warn/override33.scala @@ -8,7 +8,7 @@ abstract class Foo { } trait Bar { - val name: String = "Foo" // error + val name: String = "Foo" // warn def title: String = name } diff --git a/tests/init/neg/override34.scala b/tests/init/warn/override34.scala similarity index 79% rename from tests/init/neg/override34.scala rename to tests/init/warn/override34.scala index 6cf3e3cf4b4d..e4a21e861eb2 100644 --- a/tests/init/neg/override34.scala +++ b/tests/init/warn/override34.scala @@ -5,7 +5,7 @@ abstract class Foo { } trait Bar { - val name: String = "Foo" // error + val name: String = "Foo" // warn } class Qux extends Foo with Bar { diff --git a/tests/init/neg/override35.scala b/tests/init/warn/override35.scala similarity index 77% rename from tests/init/neg/override35.scala rename to tests/init/warn/override35.scala index 958ed1ff9d2f..1769f7b3a361 100644 --- a/tests/init/neg/override35.scala +++ b/tests/init/warn/override35.scala @@ -10,6 +10,6 @@ trait Bar { } class Qux extends Foo with Bar { - private val x = 30 // error + private val x = 30 // warn override def f = x } \ No newline at end of file diff --git a/tests/init/neg/override36.scala b/tests/init/warn/override36.scala similarity index 87% rename from tests/init/neg/override36.scala rename to tests/init/warn/override36.scala index 6df0891d5b27..2fedf7ff6bcb 100644 --- a/tests/init/neg/override36.scala +++ b/tests/init/warn/override36.scala @@ -14,5 +14,5 @@ class Bar extends Foo { class Qux extends Bar { init override def h = a - private val a = 30 // error + private val a = 30 // warn } \ No newline at end of file diff --git a/tests/init/neg/override38.scala b/tests/init/warn/override38.scala similarity index 77% rename from tests/init/neg/override38.scala rename to tests/init/warn/override38.scala index dd47b0438980..feb962cd5029 100644 --- a/tests/init/neg/override38.scala +++ b/tests/init/warn/override38.scala @@ -1,7 +1,7 @@ abstract class A { def f: Int - (1 to 10).foreach { i => // error + (1 to 10).foreach { i => // warn f } diff --git a/tests/init/neg/override39.scala b/tests/init/warn/override39.scala similarity index 82% rename from tests/init/neg/override39.scala rename to tests/init/warn/override39.scala index 723e71554da2..34f25cee2022 100644 --- a/tests/init/neg/override39.scala +++ b/tests/init/warn/override39.scala @@ -6,6 +6,6 @@ abstract class Parent extends Product { } case class Child(x: Int) extends Parent { - val m = 10 // error + val m = 10 // warn def productArity: Int = m } \ No newline at end of file diff --git a/tests/init/neg/override4.scala b/tests/init/warn/override4.scala similarity index 82% rename from tests/init/neg/override4.scala rename to tests/init/warn/override4.scala index 1489e1c2508b..1a63d2b3b59b 100644 --- a/tests/init/neg/override4.scala +++ b/tests/init/warn/override4.scala @@ -12,7 +12,7 @@ class Bar extends Foo { } class Bar2 extends Bar { - val mymap: mutable.Map[Int, String] = mutable.Map.empty // error + val mymap: mutable.Map[Int, String] = mutable.Map.empty // warn override def enter(k: Int, v: String) = { mymap(k) = v diff --git a/tests/init/neg/override40.scala b/tests/init/warn/override40.scala similarity index 80% rename from tests/init/neg/override40.scala rename to tests/init/warn/override40.scala index 2f081a9de30b..305210158d54 100644 --- a/tests/init/neg/override40.scala +++ b/tests/init/warn/override40.scala @@ -6,5 +6,5 @@ abstract class A { class B extends A { this.getClass f - val a = 20 // error + val a = 20 // warn } \ No newline at end of file diff --git a/tests/init/neg/override41.scala b/tests/init/warn/override41.scala similarity index 82% rename from tests/init/neg/override41.scala rename to tests/init/warn/override41.scala index bfd5bc18f3d6..6cb58ae326aa 100644 --- a/tests/init/neg/override41.scala +++ b/tests/init/warn/override41.scala @@ -11,5 +11,5 @@ class Child extends Parent { def show = println(name) - val name = "child" // error + val name = "child" // warn } \ No newline at end of file diff --git a/tests/init/neg/override42.scala b/tests/init/warn/override42.scala similarity index 81% rename from tests/init/neg/override42.scala rename to tests/init/warn/override42.scala index b4a53b977852..39a4d5097215 100644 --- a/tests/init/neg/override42.scala +++ b/tests/init/warn/override42.scala @@ -12,5 +12,5 @@ class Bar { def show = println(name) - val name = "child" // error + val name = "child" // warn } diff --git a/tests/init/neg/override43.scala b/tests/init/warn/override43.scala similarity index 83% rename from tests/init/neg/override43.scala rename to tests/init/warn/override43.scala index 2d55742c3ecd..ab8ec95133d6 100644 --- a/tests/init/neg/override43.scala +++ b/tests/init/warn/override43.scala @@ -8,6 +8,6 @@ final class Child extends Parent { def g() = foo() g() + b - val b = 10 // error + val b = 10 // warn g() } \ No newline at end of file diff --git a/tests/init/neg/override44.scala b/tests/init/warn/override44.scala similarity index 83% rename from tests/init/neg/override44.scala rename to tests/init/warn/override44.scala index ed7a0ae30b7a..50e7691d6fee 100644 --- a/tests/init/neg/override44.scala +++ b/tests/init/warn/override44.scala @@ -8,6 +8,6 @@ class Child extends Parent { def g() = foo() g() + b - val b = 10 // error + val b = 10 // warn g() } \ No newline at end of file diff --git a/tests/init/neg/override45.scala b/tests/init/warn/override45.scala similarity index 81% rename from tests/init/neg/override45.scala rename to tests/init/warn/override45.scala index dbf767239e6b..7eb0ba2f8cca 100644 --- a/tests/init/neg/override45.scala +++ b/tests/init/warn/override45.scala @@ -8,5 +8,5 @@ class Child extends Parent { val x = a val y = b override def f: Int = z - val z = 30 // error + val z = 30 // warn } \ No newline at end of file diff --git a/tests/init/neg/override46.scala b/tests/init/warn/override46.scala similarity index 75% rename from tests/init/neg/override46.scala rename to tests/init/warn/override46.scala index 397ec85a6984..f10d4516439c 100644 --- a/tests/init/neg/override46.scala +++ b/tests/init/warn/override46.scala @@ -1,5 +1,5 @@ trait TA { - val x = "world" // error + val x = "world" // warn } trait TB { this: TA => diff --git a/tests/init/neg/override5.scala b/tests/init/warn/override5.scala similarity index 78% rename from tests/init/neg/override5.scala rename to tests/init/warn/override5.scala index 061a41dc3fc2..fe9e3bfbde70 100644 --- a/tests/init/neg/override5.scala +++ b/tests/init/warn/override5.scala @@ -5,7 +5,7 @@ trait Foo { } class Bar extends Foo { - val name = "Jack" // error + val name = "Jack" // warn } @@ -16,7 +16,7 @@ trait Zen { } class Tao extends Zen { - val name = "Jack" // error + val name = "Jack" // warn } diff --git a/tests/init/neg/override6.scala b/tests/init/warn/override6.scala similarity index 70% rename from tests/init/neg/override6.scala rename to tests/init/warn/override6.scala index 0c04ea91300d..e8103d999151 100644 --- a/tests/init/neg/override6.scala +++ b/tests/init/warn/override6.scala @@ -4,5 +4,5 @@ trait Foo { } class Bar extends Foo { - val name = "Jack" // error + val name = "Jack" // warn } \ No newline at end of file diff --git a/tests/init/neg/override7.scala b/tests/init/warn/override7.scala similarity index 87% rename from tests/init/neg/override7.scala rename to tests/init/warn/override7.scala index 0a36f02b2790..41fbcd00be69 100644 --- a/tests/init/neg/override7.scala +++ b/tests/init/warn/override7.scala @@ -7,7 +7,7 @@ trait Foo { } class Bar(val name: String) extends Foo { - val title = "Mr." // error + val title = "Mr." // warn def getName = name // ok: name is a Param field diff --git a/tests/init/neg/override8.scala b/tests/init/warn/override8.scala similarity index 93% rename from tests/init/neg/override8.scala rename to tests/init/warn/override8.scala index 526fd5a7f3a3..272143011efc 100644 --- a/tests/init/neg/override8.scala +++ b/tests/init/warn/override8.scala @@ -6,7 +6,7 @@ trait Foo { } trait Bar { - val m = "hello" // error + val m = "hello" // warn def foo(n: Int) = m diff --git a/tests/init/neg/override9.scala b/tests/init/warn/override9.scala similarity index 64% rename from tests/init/neg/override9.scala rename to tests/init/warn/override9.scala index 1b4d32b3e5a3..12dbfde19ec3 100644 --- a/tests/init/neg/override9.scala +++ b/tests/init/warn/override9.scala @@ -1,6 +1,6 @@ trait Foo { def name: String - val message = "hello, " + name // error + val message = "hello, " + name // warn } class Bar extends Foo { diff --git a/tests/init/neg/polyfun.scala b/tests/init/warn/polyfun.scala similarity index 72% rename from tests/init/neg/polyfun.scala rename to tests/init/warn/polyfun.scala index a3a3ecc76814..5ac11721c061 100644 --- a/tests/init/neg/polyfun.scala +++ b/tests/init/warn/polyfun.scala @@ -4,5 +4,5 @@ class Test { println(n) arg } - val n = m.apply(arg = 23) // error + val n = m.apply(arg = 23) // warn } diff --git a/tests/init/neg/private.scala b/tests/init/warn/private.scala similarity index 84% rename from tests/init/neg/private.scala rename to tests/init/warn/private.scala index 658860ab577c..215f0db3deee 100644 --- a/tests/init/neg/private.scala +++ b/tests/init/warn/private.scala @@ -6,7 +6,7 @@ class A(a: Int) { class B extends A(3) { foo() println(a) - val a = 3 // error + val a = 3 // warn } class C extends A(3) { diff --git a/tests/init/neg/promote-warm.scala b/tests/init/warn/promote-warm.scala similarity index 84% rename from tests/init/neg/promote-warm.scala rename to tests/init/warn/promote-warm.scala index c9f9268f1fbd..c776d37a924e 100644 --- a/tests/init/neg/promote-warm.scala +++ b/tests/init/warn/promote-warm.scala @@ -6,7 +6,7 @@ class PromoteWarm: a.foo() val a = new A - val b = new B(a) // error + val b = new B(a) // warn val n = 10 def foo() = println(n) diff --git a/tests/init/neg/promote.scala b/tests/init/warn/promote.scala similarity index 82% rename from tests/init/neg/promote.scala rename to tests/init/warn/promote.scala index 70e951d78f6f..a97122d57a62 100644 --- a/tests/init/neg/promote.scala +++ b/tests/init/warn/promote.scala @@ -4,6 +4,6 @@ class Wrap { abstract class E[+T] { def foo: T } object E { final val A: E[Nothing] = new E { def foo = ref } - val ref = qux(A) // error + val ref = qux(A) // warn } } \ No newline at end of file diff --git a/tests/init/neg/promotion-loop.scala b/tests/init/warn/promotion-loop.scala similarity index 86% rename from tests/init/neg/promotion-loop.scala rename to tests/init/warn/promotion-loop.scala index 7f6856c34cae..c94422daca76 100644 --- a/tests/init/neg/promotion-loop.scala +++ b/tests/init/warn/promotion-loop.scala @@ -13,7 +13,7 @@ class Test { test => } val b = new B - println(b) // error + println(b) // warn val n = 10 } \ No newline at end of file diff --git a/tests/init/neg/promotion-segment.scala b/tests/init/warn/promotion-segment.scala similarity index 85% rename from tests/init/neg/promotion-segment.scala rename to tests/init/warn/promotion-segment.scala index 56968ce79c56..542ee23623f1 100644 --- a/tests/init/neg/promotion-segment.scala +++ b/tests/init/warn/promotion-segment.scala @@ -8,5 +8,5 @@ class Outer: def bar(c: C) = c.foo() - bar(new C) // error + bar(new C) // warn val m = 10 diff --git a/tests/init/neg/promotion-segment2.scala b/tests/init/warn/promotion-segment2.scala similarity index 87% rename from tests/init/neg/promotion-segment2.scala rename to tests/init/warn/promotion-segment2.scala index d3ba8dedf0ce..39cd7129950f 100644 --- a/tests/init/neg/promotion-segment2.scala +++ b/tests/init/warn/promotion-segment2.scala @@ -8,5 +8,5 @@ class Outer: def bar(c: C) = c.foo() - bar(new C) // error + bar(new C) // warn val m = 10 diff --git a/tests/init/neg/promotion-segment3.scala b/tests/init/warn/promotion-segment3.scala similarity index 82% rename from tests/init/neg/promotion-segment3.scala rename to tests/init/warn/promotion-segment3.scala index 9e62291953d3..5dab2224743b 100644 --- a/tests/init/neg/promotion-segment3.scala +++ b/tests/init/warn/promotion-segment3.scala @@ -6,6 +6,6 @@ class A: def bar(b: B) = new b.C().foo() - bar(new B) // error + bar(new B) // warn val m = 10 diff --git a/tests/init/neg/secondary-ctor.scala b/tests/init/warn/secondary-ctor.scala similarity index 87% rename from tests/init/neg/secondary-ctor.scala rename to tests/init/warn/secondary-ctor.scala index d96e149529d0..92a77b11b57a 100644 --- a/tests/init/neg/secondary-ctor.scala +++ b/tests/init/warn/secondary-ctor.scala @@ -15,5 +15,5 @@ class C(b: B) extends A(b) { class D { val b = new B(this) - val c = new C(b, 5) // error + val c = new C(b, 5) // warn } diff --git a/tests/init/neg/secondary-ctor2.scala b/tests/init/warn/secondary-ctor2.scala similarity index 91% rename from tests/init/neg/secondary-ctor2.scala rename to tests/init/warn/secondary-ctor2.scala index 462ff2dbcfaa..5518bbf974e7 100644 --- a/tests/init/neg/secondary-ctor2.scala +++ b/tests/init/warn/secondary-ctor2.scala @@ -21,5 +21,5 @@ class C(b: B) extends A(b) { class D { val b = new B(this) - val c = new C(b, 5) // error + val c = new C(b, 5) // warn } diff --git a/tests/init/neg/secondary-ctor3.scala b/tests/init/warn/secondary-ctor3.scala similarity index 94% rename from tests/init/neg/secondary-ctor3.scala rename to tests/init/warn/secondary-ctor3.scala index 3bbfc413e262..ed01c6fcbe30 100644 --- a/tests/init/neg/secondary-ctor3.scala +++ b/tests/init/warn/secondary-ctor3.scala @@ -35,5 +35,5 @@ def foo() = class D { val b = new B(this) - val c = new C(b, 5) // error + val c = new C(b, 5) // warn } diff --git a/tests/init/neg/secondary-ctor4.check b/tests/init/warn/secondary-ctor4.check similarity index 84% rename from tests/init/neg/secondary-ctor4.check rename to tests/init/warn/secondary-ctor4.check index 2c89cfe9f289..3909af5ac336 100644 --- a/tests/init/neg/secondary-ctor4.check +++ b/tests/init/warn/secondary-ctor4.check @@ -1,10 +1,10 @@ --- Error: tests/init/neg/secondary-ctor4.scala:54:14 ------------------------------------------------------------------- -54 | val c = new C(b, 5) // error +-- Warning: tests/init/warn/secondary-ctor4.scala:54:14 ---------------------------------------------------------------- +54 | val c = new C(b, 5) // warn | ^^^^^^^^^^^ | Problematic object instantiation: arg 1 is not transitively initialized (Hot). Calling trace: | ├── class D { [ secondary-ctor4.scala:52 ] | │ ^ - | └── val c = new C(b, 5) // error [ secondary-ctor4.scala:54 ] + | └── val c = new C(b, 5) // warn [ secondary-ctor4.scala:54 ] | ^^^^^^^^^^^ | | It leads to the following error during object initialization: @@ -21,15 +21,15 @@ | │ ^ | └── println(b.n) [ secondary-ctor4.scala:23 ] | ^^^ --- Error: tests/init/neg/secondary-ctor4.scala:42:4 -------------------------------------------------------------------- -42 | new A(new B(new D)) // error +-- Warning: tests/init/warn/secondary-ctor4.scala:42:4 ----------------------------------------------------------------- +42 | new A(new B(new D)) // warn | ^^^^^^^^^^^^^^^^^^^ |Problematic object instantiation: the outer M.this and arg 1 are not transitively initialized (Hot). Calling trace: |├── class N(d: D) extends M(d) { [ secondary-ctor4.scala:59 ] |│ ^ |├── def this(d: D) = { [ secondary-ctor4.scala:7 ] |│ ^ - |└── new A(new B(new D)) // error [ secondary-ctor4.scala:42 ] + |└── new A(new B(new D)) // warn [ secondary-ctor4.scala:42 ] | ^^^^^^^^^^^^^^^^^^^ | |It leads to the following error during object initialization: diff --git a/tests/init/neg/secondary-ctor4.scala b/tests/init/warn/secondary-ctor4.scala similarity index 90% rename from tests/init/neg/secondary-ctor4.scala rename to tests/init/warn/secondary-ctor4.scala index e80630002638..9c53034ee597 100644 --- a/tests/init/neg/secondary-ctor4.scala +++ b/tests/init/warn/secondary-ctor4.scala @@ -10,7 +10,7 @@ class M(x: Int) { class L1(x: Int) { val n: Int = 5 } class A(b: B, x: Int) { - println(d.n) + println(d.n) class L2(x: Int) { val n: Int = 5 } @@ -39,7 +39,7 @@ class M(x: Int) { val n: Int = 10 } - new A(new B(new D)) // error + new A(new B(new D)) // warn trait T { val m: Int = 10 @@ -51,7 +51,7 @@ class M(x: Int) { class D { val b = new B(this) - val c = new C(b, 5) // error + val c = new C(b, 5) // warn } } } diff --git a/tests/init/warn/simple1.scala b/tests/init/warn/simple1.scala new file mode 100644 index 000000000000..9f8ce2f5c487 --- /dev/null +++ b/tests/init/warn/simple1.scala @@ -0,0 +1,4 @@ +class Foo { + val len = name.size + val name: String = "Jack" // warn +} \ No newline at end of file diff --git a/tests/init/neg/simple2.scala b/tests/init/warn/simple2.scala similarity index 86% rename from tests/init/neg/simple2.scala rename to tests/init/warn/simple2.scala index 70a7f8407c6b..63fa64d5a113 100644 --- a/tests/init/neg/simple2.scala +++ b/tests/init/warn/simple2.scala @@ -4,7 +4,7 @@ class Box(x: Int) { List(3, 4, 5).map(_ * 2) - private var a = "hello" // error + private var a = "hello" // warn def f(m: Int) = m + a.size } diff --git a/tests/init/neg/simple3.scala b/tests/init/warn/simple3.scala similarity index 64% rename from tests/init/neg/simple3.scala rename to tests/init/warn/simple3.scala index 70de74b35bd4..245f982a807b 100644 --- a/tests/init/neg/simple3.scala +++ b/tests/init/warn/simple3.scala @@ -1,5 +1,5 @@ class Foo { val list = List(4, 6) val n = len + 5 - val len = list.size // error + val len = list.size // warn } diff --git a/tests/init/neg/simple5.scala b/tests/init/warn/simple5.scala similarity index 68% rename from tests/init/neg/simple5.scala rename to tests/init/warn/simple5.scala index 9c9d7d053830..bd9506076d26 100644 --- a/tests/init/neg/simple5.scala +++ b/tests/init/warn/simple5.scala @@ -6,7 +6,7 @@ class Foo { b - val name = "Jack" // error + val name = "Jack" // warn } class Bar { @@ -17,5 +17,5 @@ class Bar { b - val name = "Jack" // error + val name = "Jack" // warn } \ No newline at end of file diff --git a/tests/init/neg/soundness1.scala b/tests/init/warn/soundness1.scala similarity index 81% rename from tests/init/neg/soundness1.scala rename to tests/init/warn/soundness1.scala index d528b374f004..4d71c3e52747 100644 --- a/tests/init/neg/soundness1.scala +++ b/tests/init/warn/soundness1.scala @@ -20,10 +20,10 @@ object Test2: object Test3: class A(b: B) { println(b.a2) - val b2 = new B(this) // error + val b2 = new B(this) // warn } class B(a: A) { println(a.b2) - val a2 = new A(this) // error + val a2 = new A(this) // warn } diff --git a/tests/init/neg/soundness2.scala b/tests/init/warn/soundness2.scala similarity index 50% rename from tests/init/neg/soundness2.scala rename to tests/init/warn/soundness2.scala index 3d2821377111..6015ea46c3d7 100644 --- a/tests/init/neg/soundness2.scala +++ b/tests/init/warn/soundness2.scala @@ -1,4 +1,4 @@ class C(c: C) { val d = c.c2 - val c2 = new C(this) // error + val c2 = new C(this) // warn } diff --git a/tests/init/warn/soundness4.scala b/tests/init/warn/soundness4.scala new file mode 100644 index 000000000000..24060f2be083 --- /dev/null +++ b/tests/init/warn/soundness4.scala @@ -0,0 +1,3 @@ +class Foo { + val a : Foo = this.a.a // warn +} \ No newline at end of file diff --git a/tests/init/neg/soundness6.scala b/tests/init/warn/soundness6.scala similarity index 58% rename from tests/init/neg/soundness6.scala rename to tests/init/warn/soundness6.scala index 09d55dba292c..2893c3a4e301 100644 --- a/tests/init/neg/soundness6.scala +++ b/tests/init/warn/soundness6.scala @@ -1,5 +1,5 @@ class C(c: C) { println(c.n) - val c2 = new C(this) // error + val c2 = new C(this) // warn val n = 10 } diff --git a/tests/init/neg/structural.scala b/tests/init/warn/structural.scala similarity index 86% rename from tests/init/neg/structural.scala rename to tests/init/warn/structural.scala index 27b37a04bef7..bf20529a8007 100644 --- a/tests/init/neg/structural.scala +++ b/tests/init/warn/structural.scala @@ -8,5 +8,5 @@ class Test { n + x } - val n = m(23) // error + val n = m(23) // warn } diff --git a/tests/init/neg/super-resolution.scala b/tests/init/warn/super-resolution.scala similarity index 82% rename from tests/init/neg/super-resolution.scala rename to tests/init/warn/super-resolution.scala index d2674bc597e1..6fa295ed5187 100644 --- a/tests/init/neg/super-resolution.scala +++ b/tests/init/warn/super-resolution.scala @@ -16,8 +16,8 @@ trait N extends A with B: class C extends A with M with N: foo() - val a = 10 // error - val b = 20 // error - val m = 30 // error + val a = 10 // warn + val b = 20 // warn + val m = 30 // warn val n = 40 diff --git a/tests/init/neg/super-resolution2.scala b/tests/init/warn/super-resolution2.scala similarity index 84% rename from tests/init/neg/super-resolution2.scala rename to tests/init/warn/super-resolution2.scala index 283fb25a467d..5009e2f3aa64 100644 --- a/tests/init/neg/super-resolution2.scala +++ b/tests/init/warn/super-resolution2.scala @@ -15,6 +15,6 @@ class N extends A with B: new Inner - val m = 30 // error - val n = 40 // error + val m = 30 // warn + val n = 40 // warn val a = 50 diff --git a/tests/init/neg/super-resolution3.scala b/tests/init/warn/super-resolution3.scala similarity index 81% rename from tests/init/neg/super-resolution3.scala rename to tests/init/warn/super-resolution3.scala index 4d510ef22e61..e1b7a2ba3541 100644 --- a/tests/init/neg/super-resolution3.scala +++ b/tests/init/warn/super-resolution3.scala @@ -21,7 +21,7 @@ trait N extends A with B: class C extends A with M with N: new Inner() - val a = 10 // error - val b = 20 // error - val m = 30 // error - val n = 40 // error + val a = 10 // warn + val b = 20 // warn + val m = 30 // warn + val n = 40 // warn diff --git a/tests/init/neg/super.scala b/tests/init/warn/super.scala similarity index 87% rename from tests/init/neg/super.scala rename to tests/init/warn/super.scala index 5a8e72cce65f..9b0b88136f20 100644 --- a/tests/init/neg/super.scala +++ b/tests/init/warn/super.scala @@ -20,11 +20,11 @@ class Bar extends A, B, C: override def foo() = n * n - val n = 10 // error + val n = 10 // warn class Qux extends A, B, C: super.foo() override def foo() = n * n - val n = 10 // error + val n = 10 // warn diff --git a/tests/init/neg/t3273.scala b/tests/init/warn/t3273.scala similarity index 90% rename from tests/init/neg/t3273.scala rename to tests/init/warn/t3273.scala index 141e544bdfeb..297b3bbf0d44 100644 --- a/tests/init/neg/t3273.scala +++ b/tests/init/warn/t3273.scala @@ -1,8 +1,8 @@ import scala.language.implicitConversions object Test { - val num1: LazyList[Int] = 1 #:: num1.map(_ + 1) // error - val num2: LazyList[Int] = 1 #:: num2.iterator.map(_ + 1).to(LazyList) // error + val num1: LazyList[Int] = 1 #:: num1.map(_ + 1) // warn + val num2: LazyList[Int] = 1 #:: num2.iterator.map(_ + 1).to(LazyList) // warn def main(args: Array[String]): Unit = { val x1 = (num1 take 10).toList diff --git a/tests/init/neg/trait1.scala b/tests/init/warn/trait1.scala similarity index 79% rename from tests/init/neg/trait1.scala rename to tests/init/warn/trait1.scala index 48eae248fee7..d5c30569c4ee 100644 --- a/tests/init/neg/trait1.scala +++ b/tests/init/warn/trait1.scala @@ -3,7 +3,7 @@ abstract class A(x: Int) { foo() } -trait B(val y: Int) // error +trait B(val y: Int) // warn class C extends A(10) with B(20) { def foo(): Unit = println(y) diff --git a/tests/init/neg/trait2.scala b/tests/init/warn/trait2.scala similarity index 83% rename from tests/init/neg/trait2.scala rename to tests/init/warn/trait2.scala index 6011c259b73f..1b5bfded5730 100644 --- a/tests/init/neg/trait2.scala +++ b/tests/init/warn/trait2.scala @@ -3,7 +3,7 @@ abstract class A(x: Int) { foo() } -trait B(val y: Int) // error +trait B(val y: Int) // warn class D { class C extends A(10) with B(20) { diff --git a/tests/init/neg/trees.scala b/tests/init/warn/trees.scala similarity index 78% rename from tests/init/neg/trees.scala rename to tests/init/warn/trees.scala index 836f02e9c551..96ae170075c5 100644 --- a/tests/init/neg/trees.scala +++ b/tests/init/warn/trees.scala @@ -3,5 +3,5 @@ class Trees { class ValDef { counter += 1 } class EmptyValDef extends ValDef val theEmptyValDef = new EmptyValDef - private var counter = 0 // error + private var counter = 0 // warn } diff --git a/tests/init/neg/unsound1.scala b/tests/init/warn/unsound1.scala similarity index 80% rename from tests/init/neg/unsound1.scala rename to tests/init/warn/unsound1.scala index 3854504c8478..b017d1cd9f37 100644 --- a/tests/init/neg/unsound1.scala +++ b/tests/init/warn/unsound1.scala @@ -1,5 +1,5 @@ class A(m: Int) { - if (m > 0) println(foo(m - 1).a2.n) // error + if (m > 0) println(foo(m - 1).a2.n) // warn def foo(n: Int): B = if (n % 2 == 0) new B(new A(n - 1), foo(n - 1).a1) diff --git a/tests/init/neg/unsound2.scala b/tests/init/warn/unsound2.scala similarity index 88% rename from tests/init/neg/unsound2.scala rename to tests/init/warn/unsound2.scala index 5ae0c624c32e..d8b017f2c7db 100644 --- a/tests/init/neg/unsound2.scala +++ b/tests/init/warn/unsound2.scala @@ -2,7 +2,7 @@ case class A(x: Int) { def foo(y: Int): B = if (y > 10) then B(bar(y - 1), foo(y - 1).getN) else B(bar(y), 10) def bar(y: Int): A = if (y > 10) then A(y - 1) else this class B(a: A, b: Int) { - def getN: Int = a.n // error + def getN: Int = a.n // warn def getB: Int = b } println(foo(x).getB) diff --git a/tests/init/neg/unsound3.scala b/tests/init/warn/unsound3.scala similarity index 72% rename from tests/init/neg/unsound3.scala rename to tests/init/warn/unsound3.scala index 9ede5c7f97d0..021505cb9931 100644 --- a/tests/init/neg/unsound3.scala +++ b/tests/init/warn/unsound3.scala @@ -7,7 +7,7 @@ class C { def foo(): B = { x += 1 val newB = new B(this) - if (x < 12) then foo().getC().b else newB // error + if (x < 12) then foo().getC().b else newB // warn } val b = foo() } \ No newline at end of file diff --git a/tests/init/neg/unsound4.scala b/tests/init/warn/unsound4.scala similarity index 70% rename from tests/init/neg/unsound4.scala rename to tests/init/warn/unsound4.scala index 8a6e26fe8a6b..2b1a69723342 100644 --- a/tests/init/neg/unsound4.scala +++ b/tests/init/warn/unsound4.scala @@ -1,4 +1,4 @@ class A { def foo(x: Int): A = if (x < 5) then this else foo(x - 1).aAgain - val aAgain = foo(5) // error + val aAgain = foo(5) // warn } \ No newline at end of file diff --git a/tests/neg-custom-args/sourcepath2/hi/A.check b/tests/neg-custom-args/sourcepath2/hi/A.check index 61d4798a34e7..1fac6b1147ef 100644 --- a/tests/neg-custom-args/sourcepath2/hi/A.check +++ b/tests/neg-custom-args/sourcepath2/hi/A.check @@ -1,6 +1,7 @@ --- Error: tests/neg-custom-args/sourcepath2/hi/A.scala:3:6 ------------------------------------------------------------- -3 |class Hello { // error +-- Warning: tests/neg-custom-args/sourcepath2/hi/A.scala:3:6 ----------------------------------------------------------- +3 |class Hello { // warn | ^ | class Hello is in the wrong directory. | It was declared to be in package | But it is found in directory hi +No warnings can be incurred under -Werror. diff --git a/tests/neg-custom-args/sourcepath2/hi/A.scala b/tests/neg-custom-args/sourcepath2/hi/A.scala index c332f2494e15..039910e55ce7 100644 --- a/tests/neg-custom-args/sourcepath2/hi/A.scala +++ b/tests/neg-custom-args/sourcepath2/hi/A.scala @@ -1,5 +1,6 @@ // Missing `package hi` -class Hello { // error +class Hello { // warn val x: Int = 1 } +// nopos-error: werror \ No newline at end of file diff --git a/tests/neg-deep-subtype/3324b.scala b/tests/neg-deep-subtype/3324b.scala deleted file mode 100644 index df0cc5432eff..000000000000 --- a/tests/neg-deep-subtype/3324b.scala +++ /dev/null @@ -1,11 +0,0 @@ -//> using options -Xfatal-warnings - -class C[T] { - val x: Any = ??? - if (x.isInstanceOf[List[String]]) // error: unchecked - if (x.isInstanceOf[T]) // error: unchecked - x match { - case x: List[String] => // error: unchecked - case x: T => // error: unchecked - } -} diff --git a/tests/neg-deep-subtype/3324f.scala b/tests/neg-deep-subtype/3324f.scala deleted file mode 100644 index 445da5cb25a0..000000000000 --- a/tests/neg-deep-subtype/3324f.scala +++ /dev/null @@ -1,11 +0,0 @@ -//> using options -Xfatal-warnings - -trait C[T] -class D[T] - -class Test { - def foo[T](x: C[T]) = x match { - case _: D[T] => // error - case _: C[Int] => // error - } -} \ No newline at end of file diff --git a/tests/neg-deep-subtype/i3324.scala b/tests/neg-deep-subtype/i3324.scala deleted file mode 100644 index 9b1060836430..000000000000 --- a/tests/neg-deep-subtype/i3324.scala +++ /dev/null @@ -1,6 +0,0 @@ -//> using options -Xfatal-warnings - -class Foo { - def foo(x: Any): Boolean = - x.isInstanceOf[List[String]] // error -} diff --git a/tests/neg-macros/i9570.check b/tests/neg-macros/i9570.check new file mode 100644 index 000000000000..16b71d317b7c --- /dev/null +++ b/tests/neg-macros/i9570.check @@ -0,0 +1,5 @@ +-- Warning: tests/neg-macros/i9570.scala:15:21 ------------------------------------------------------------------------- +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. diff --git a/tests/neg-macros/i9570.scala b/tests/neg-macros/i9570.scala index 9242fd2e9bbd..8afd76fc7181 100644 --- a/tests/neg-macros/i9570.scala +++ b/tests/neg-macros/i9570.scala @@ -12,7 +12,7 @@ object Macros { private def sizeImpl(e: Expr[HList], n:Int)(using qctx:Quotes): Expr[Int] = { import quotes.reflect.* e match { - case '{HCons(_,$t)} => // error if run with fatal warinings in BootstrappedOnlyCompilationTests + case '{HCons(_,$t)} => // warn (in .check file) sizeImpl(t,n+1) case '{HNil} => Expr(n) } @@ -24,3 +24,5 @@ object Macros { } } + +// nopos-error No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg-macros/macro-deprecation.check b/tests/neg-macros/macro-deprecation.check new file mode 100644 index 000000000000..5ce8a2427127 --- /dev/null +++ b/tests/neg-macros/macro-deprecation.check @@ -0,0 +1,5 @@ +-- Deprecation Warning: tests/neg-macros/macro-deprecation.scala:5:18 -------------------------------------------------- +5 |inline def f = ${ impl } // warn (in .check file) + | ^^^^ + | method impl is deprecated +No warnings can be incurred under -Werror. diff --git a/tests/neg-macros/macro-deprecation.scala b/tests/neg-macros/macro-deprecation.scala index ad1cdda001bb..0bbf4d5faa1e 100644 --- a/tests/neg-macros/macro-deprecation.scala +++ b/tests/neg-macros/macro-deprecation.scala @@ -2,5 +2,7 @@ import scala.quoted.* -inline def f = ${ impl } // error +inline def f = ${ impl } // warn (in .check file) @deprecated def impl(using Quotes) = '{1} + +// nopos-error No warnings can be incurred under -Werror. diff --git a/tests/neg-scalajs/enumeration-warnings.check b/tests/neg-scalajs/enumeration-warnings.check index b356a150daa5..5d791be5928a 100644 --- a/tests/neg-scalajs/enumeration-warnings.check +++ b/tests/neg-scalajs/enumeration-warnings.check @@ -1,60 +1,61 @@ --- Error: tests/neg-scalajs/enumeration-warnings.scala:6:4 ------------------------------------------------------------- -6 | Value // error +-- Warning: tests/neg-scalajs/enumeration-warnings.scala:6:4 ----------------------------------------------------------- +6 | Value // warn | ^^^^^ | Could not transform call to scala.Enumeration.Value. | The resulting program is unlikely to function properly as this operation requires reflection. --- Error: tests/neg-scalajs/enumeration-warnings.scala:10:9 ------------------------------------------------------------ -10 | Value(4) // error +-- Warning: tests/neg-scalajs/enumeration-warnings.scala:10:9 ---------------------------------------------------------- +10 | Value(4) // warn | ^^^^^^^^ | Could not transform call to scala.Enumeration.Value. | The resulting program is unlikely to function properly as this operation requires reflection. --- Error: tests/neg-scalajs/enumeration-warnings.scala:15:15 ----------------------------------------------------------- -15 | val a = Value(null) // error +-- Warning: tests/neg-scalajs/enumeration-warnings.scala:15:15 --------------------------------------------------------- +15 | val a = Value(null) // warn | ^^^^^^^^^^^ | Passing null as name to scala.Enumeration.Value requires reflection at run-time. | The resulting program is unlikely to function properly. --- Error: tests/neg-scalajs/enumeration-warnings.scala:16:15 ----------------------------------------------------------- -16 | val b = Value(10, null) // error +-- Warning: tests/neg-scalajs/enumeration-warnings.scala:16:15 --------------------------------------------------------- +16 | val b = Value(10, null) // warn | ^^^^^^^^^^^^^^^ | Passing null as name to scala.Enumeration.Value requires reflection at run-time. | The resulting program is unlikely to function properly. --- Error: tests/neg-scalajs/enumeration-warnings.scala:20:10 ----------------------------------------------------------- -20 | val a = new Val // error +-- Warning: tests/neg-scalajs/enumeration-warnings.scala:20:10 --------------------------------------------------------- +20 | val a = new Val // warn | ^^^^^^^ | Calls to the non-string constructors of scala.Enumeration.Val require reflection at run-time. | The resulting program is unlikely to function properly. --- Error: tests/neg-scalajs/enumeration-warnings.scala:21:10 ----------------------------------------------------------- -21 | val b = new Val(10) // error +-- Warning: tests/neg-scalajs/enumeration-warnings.scala:21:10 --------------------------------------------------------- +21 | val b = new Val(10) // warn | ^^^^^^^^^^^ | Calls to the non-string constructors of scala.Enumeration.Val require reflection at run-time. | The resulting program is unlikely to function properly. --- Error: tests/neg-scalajs/enumeration-warnings.scala:25:10 ----------------------------------------------------------- -25 | val a = new Val(null) // error +-- Warning: tests/neg-scalajs/enumeration-warnings.scala:25:10 --------------------------------------------------------- +25 | val a = new Val(null) // warn | ^^^^^^^^^^^^^ | Passing null as name to a constructor of scala.Enumeration.Val requires reflection at run-time. | The resulting program is unlikely to function properly. --- Error: tests/neg-scalajs/enumeration-warnings.scala:26:10 ----------------------------------------------------------- -26 | val b = new Val(10, null) // error +-- Warning: tests/neg-scalajs/enumeration-warnings.scala:26:10 --------------------------------------------------------- +26 | val b = new Val(10, null) // warn | ^^^^^^^^^^^^^^^^^ | Passing null as name to a constructor of scala.Enumeration.Val requires reflection at run-time. | The resulting program is unlikely to function properly. --- Error: tests/neg-scalajs/enumeration-warnings.scala:30:31 ----------------------------------------------------------- -30 | protected class Val1 extends Val // error +-- Warning: tests/neg-scalajs/enumeration-warnings.scala:30:31 --------------------------------------------------------- +30 | protected class Val1 extends Val // warn | ^^^ | Calls to the non-string constructors of scala.Enumeration.Val require reflection at run-time. | The resulting program is unlikely to function properly. --- Error: tests/neg-scalajs/enumeration-warnings.scala:31:31 ----------------------------------------------------------- -31 | protected class Val2 extends Val(1) // error +-- Warning: tests/neg-scalajs/enumeration-warnings.scala:31:31 --------------------------------------------------------- +31 | protected class Val2 extends Val(1) // warn | ^^^^^^ | Calls to the non-string constructors of scala.Enumeration.Val require reflection at run-time. | The resulting program is unlikely to function properly. --- Error: tests/neg-scalajs/enumeration-warnings.scala:35:31 ----------------------------------------------------------- -35 | protected class Val1 extends Val(null) // error +-- Warning: tests/neg-scalajs/enumeration-warnings.scala:35:31 --------------------------------------------------------- +35 | protected class Val1 extends Val(null) // warn | ^^^^^^^^^ | Passing null as name to a constructor of scala.Enumeration.Val requires reflection at run-time. | The resulting program is unlikely to function properly. --- Error: tests/neg-scalajs/enumeration-warnings.scala:36:31 ----------------------------------------------------------- -36 | protected class Val2 extends Val(1, null) // error +-- Warning: tests/neg-scalajs/enumeration-warnings.scala:36:31 --------------------------------------------------------- +36 | protected class Val2 extends Val(1, null) // warn | ^^^^^^^^^^^^ | 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. diff --git a/tests/neg-scalajs/enumeration-warnings.scala b/tests/neg-scalajs/enumeration-warnings.scala index b48ffc9500e3..10536fef4ba6 100644 --- a/tests/neg-scalajs/enumeration-warnings.scala +++ b/tests/neg-scalajs/enumeration-warnings.scala @@ -3,35 +3,37 @@ class UnableToTransformValue extends Enumeration { val a = { println("oh, oh!") - Value // error + Value // warn } val b = { println("oh, oh!") - Value(4) // error + Value(4) // warn } } class ValueWithNullName extends Enumeration { - val a = Value(null) // error - val b = Value(10, null) // error + val a = Value(null) // warn + val b = Value(10, null) // warn } class NewValWithNoName extends Enumeration { - val a = new Val // error - val b = new Val(10) // error + val a = new Val // warn + val b = new Val(10) // warn } class NewValWithNullName extends Enumeration { - val a = new Val(null) // error - val b = new Val(10, null) // error + val a = new Val(null) // warn + val b = new Val(10, null) // warn } class ExtendsValWithNoName extends Enumeration { - protected class Val1 extends Val // error - protected class Val2 extends Val(1) // error + protected class Val1 extends Val // warn + protected class Val2 extends Val(1) // warn } class ExtendsValWithNullName extends Enumeration { - protected class Val1 extends Val(null) // error - protected class Val2 extends Val(1, null) // error + protected class Val1 extends Val(null) // warn + protected class Val2 extends Val(1, null) // warn } + +// nopos-error: No warnings can be incurred under -Werror. diff --git a/tests/neg/14034b.scala b/tests/neg/14034b.scala deleted file mode 100644 index 84f9ab3579c8..000000000000 --- a/tests/neg/14034b.scala +++ /dev/null @@ -1,15 +0,0 @@ -//> using options -Xfatal-warnings -deprecation - -@deprecated trait Exp -@deprecated val exp = 1 - -def test1 = exp // error -def test2(a: Exp) = () // error - -type Foo0 = Exp // error -type Foo = Option[Exp] // error -type Bar = Option[exp.type] // error -type Baz = Exp | Int // error -type Quux = [X] =>> X match - case Exp => Int // error -type Quuz[A <: Exp] = Int // error diff --git a/tests/neg/17284.scala b/tests/neg/17284.scala deleted file mode 100644 index 8f588233245a..000000000000 --- a/tests/neg/17284.scala +++ /dev/null @@ -1,14 +0,0 @@ -//> using options -Werror -explain - -def test = - 451.synchronized {} // error - -def test2 = - val x: Integer = 451 - x.synchronized {} // error - -def test3 = - true.synchronized {} // error - -def test4 = - true.hashCode() // success diff --git a/tests/neg/18493.check b/tests/neg/18493.check deleted file mode 100644 index 79a2872e71e8..000000000000 --- a/tests/neg/18493.check +++ /dev/null @@ -1,8 +0,0 @@ --- [E030] Match case Unreachable Error: tests/neg/18493.scala:6:9 ------------------------------------------------------ -6 | case "abc" => // error - | ^^^^^ - | Unreachable case --- [E030] Match case Unreachable Error: tests/neg/18493.scala:12:9 ----------------------------------------------------- -12 | case "abc" => // error - | ^^^^^ - | Unreachable case diff --git a/tests/neg/adhoc-extension/B.scala b/tests/neg/adhoc-extension/B.scala index 2343a9bc0060..efa783f87178 100644 --- a/tests/neg/adhoc-extension/B.scala +++ b/tests/neg/adhoc-extension/B.scala @@ -1,10 +1,11 @@ //> using options -source future -feature -Xfatal-warnings package adhoc -class B extends A // error: adhoc-extension (under -strict -feature -Xfatal-warnings) -class C extends A // error +class B extends A // warn: adhoc-extension (under -strict -feature -Xfatal-warnings) +class C extends A // warn object O { - val a = new A {} // error - object E extends A // error -} \ No newline at end of file + val a = new A {} // warn + object E extends A // warn +} +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/avoid-warn-deprecation.scala b/tests/neg/avoid-warn-deprecation.scala deleted file mode 100644 index 45baf7addb86..000000000000 --- a/tests/neg/avoid-warn-deprecation.scala +++ /dev/null @@ -1,11 +0,0 @@ -//> using options -Xfatal-warnings -feature - -object A { - @deprecated("use bar instead of this one", "0.2.3") - def foo: Int = 3 -} - -object B { - A.foo -} -// nopos-error there was 1 deprecation warning; re-run with -deprecation for details diff --git a/tests/neg/capt-wf.scala b/tests/neg/capt-wf.scala index fbd334726e55..61dde899a585 100644 --- a/tests/neg/capt-wf.scala +++ b/tests/neg/capt-wf.scala @@ -13,12 +13,12 @@ def test(c: Cap, other: String): Unit = val x3a: () -> String = s1 val s2 = () => if x1 == null then "" else "abc" val x4: C^{s2} = ??? // OK - val x5: C^{c, c} = ??? // error: redundant // error: redundant + val x5: C^{c, c} = ??? // warn: redundant // warn: redundant // val x6: C^{c}^{c} = ??? // would be syntax error - val x7: Cap^{c} = ??? // error: redundant + val x7: Cap^{c} = ??? // warn: redundant // val x8: C^{c}^{cap} = ??? // would be syntax error - val x9: C^{c, cap} = ??? // error: redundant - val x10: C^{cap, c} = ??? // error: redundant + val x9: C^{c, cap} = ??? // warn: redundant + val x10: C^{cap, c} = ??? // warn: redundant def even(n: Int): Boolean = if n == 0 then true else odd(n - 1) def odd(n: Int): Boolean = if n == 1 then true else even(n - 1) @@ -34,4 +34,5 @@ def test(c: Cap, other: String): Unit = if n == 0 then true else od(n - 1) val y3: String^{ev} = ??? // error cs is empty - () \ No newline at end of file + () +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/classtag-typetest/3_1-migration.scala b/tests/neg/classtag-typetest/3_1-migration.scala index 41e0537a6dc1..fb8f3beedc48 100644 --- a/tests/neg/classtag-typetest/3_1-migration.scala +++ b/tests/neg/classtag-typetest/3_1-migration.scala @@ -5,4 +5,5 @@ import scala.reflect.ClassTag def f3_1m[T: ClassTag](x: Any): Unit = x match - case _: T => // error + case _: T => // warn +// nopos-error: No warnings can be incurred under -Werror. diff --git a/tests/neg/classtag-typetest/3_1.scala b/tests/neg/classtag-typetest/3_1.scala index d9101ff2ae57..798489bb90fa 100644 --- a/tests/neg/classtag-typetest/3_1.scala +++ b/tests/neg/classtag-typetest/3_1.scala @@ -5,4 +5,5 @@ import scala.reflect.ClassTag def f3_1[T: ClassTag](x: Any): Unit = x match - case _: T => // error + case _: T => // warn +// nopos-error: No warnings can be incurred under -Werror. diff --git a/tests/neg/i10247.scala b/tests/neg/i10247.scala deleted file mode 100644 index fc6268720a6d..000000000000 --- a/tests/neg/i10247.scala +++ /dev/null @@ -1,28 +0,0 @@ -//> using options -Xfatal-warnings -deprecation - -def usered = Color.Red // error: value Red is deprecated - -object DeprecatedContainer { - @deprecated("no foo", "0.1") val foo = 23 -} - -enum Day { - - @deprecated("no more Mondays!", "0.1") case Monday - -} - -enum Color { - - @deprecated("no Red", "0.1") case Red - - @deprecated("no Generic", "0.1") case Generic(rgb: Int) - - def useFoo1 = DeprecatedContainer.foo // error // check that only enum cases are avoided - def useMonday = Day.Monday // error // check that enum cases are declared in this enum - -} - -object Color { - def useFoo2 = DeprecatedContainer.foo // error // check that only enum cases are avoided -} diff --git a/tests/neg/i10930.scala b/tests/neg/i10930.scala deleted file mode 100644 index 5f8a0ca1ba76..000000000000 --- a/tests/neg/i10930.scala +++ /dev/null @@ -1,15 +0,0 @@ -//> using options -Xfatal-warnings - -import language.future -@main def Test = - type LeafElem[X] = X match - case String => Char - case Array[t] => LeafElem[t] - case Iterable[t] => LeafElem[t] - case AnyVal => X - - def leafElem[X](x: X): LeafElem[X] = x match - case x: String => x.charAt(0) // error - case x: Array[t] => leafElem(x(1)) // error - case x: Iterable[t] => leafElem(x.head) // error - case x: AnyVal => x // error diff --git a/tests/neg/i10994.scala b/tests/neg/i10994.scala deleted file mode 100644 index f5f237f22dd6..000000000000 --- a/tests/neg/i10994.scala +++ /dev/null @@ -1,4 +0,0 @@ -//> using options -Xfatal-warnings - -def foo = true match - case (b: Boolean): Boolean => () // error diff --git a/tests/neg/i11022.check b/tests/neg/i11022.check deleted file mode 100644 index 55bdb0526264..000000000000 --- a/tests/neg/i11022.check +++ /dev/null @@ -1,20 +0,0 @@ --- Error: tests/neg/i11022.scala:10:7 ---------------------------------------------------------------------------------- -10 |val a: CaseClass = CaseClass(42) // error: deprecated type // error: deprecated apply method - | ^^^^^^^^^ - | class CaseClass is deprecated: no CaseClass --- Error: tests/neg/i11022.scala:10:19 --------------------------------------------------------------------------------- -10 |val a: CaseClass = CaseClass(42) // error: deprecated type // error: deprecated apply method - | ^^^^^^^^^ - | class CaseClass is deprecated: no CaseClass --- Error: tests/neg/i11022.scala:11:7 ---------------------------------------------------------------------------------- -11 |val b: CaseClass = new CaseClass(42) // error: deprecated type // error: deprecated class - | ^^^^^^^^^ - | class CaseClass is deprecated: no CaseClass --- Error: tests/neg/i11022.scala:11:23 --------------------------------------------------------------------------------- -11 |val b: CaseClass = new CaseClass(42) // error: deprecated type // error: deprecated class - | ^^^^^^^^^ - | class CaseClass is deprecated: no CaseClass --- Error: tests/neg/i11022.scala:12:14 --------------------------------------------------------------------------------- -12 |val c: Unit = CaseClass(42).magic() // error: deprecated apply method - | ^^^^^^^^^ - | class CaseClass is deprecated: no CaseClass diff --git a/tests/neg/i11022.scala b/tests/neg/i11022.scala deleted file mode 100644 index 14bc600666f9..000000000000 --- a/tests/neg/i11022.scala +++ /dev/null @@ -1,13 +0,0 @@ -//> using options -Xfatal-warnings -deprecation - -@deprecated("no CaseClass") -case class CaseClass(rgb: Int): - def magic(): Unit = () - -object CaseClass: - def notDeprecated(): Unit = () - -val a: CaseClass = CaseClass(42) // error: deprecated type // error: deprecated apply method -val b: CaseClass = new CaseClass(42) // error: deprecated type // error: deprecated class -val c: Unit = CaseClass(42).magic() // error: deprecated apply method -val d: Unit = CaseClass.notDeprecated() // compiles diff --git a/tests/neg/i11225b.check b/tests/neg/i11225b.check new file mode 100644 index 000000000000..12ec80515e6f --- /dev/null +++ b/tests/neg/i11225b.check @@ -0,0 +1,6 @@ +-- Error: tests/neg/i11225b.scala:6:26 --------------------------------------------------------------------------------- +6 | private var cached: A = _ // error + | ^ + | `= _` has been deprecated; use `= uninitialized` instead. + | `uninitialized` can be imported with `scala.compiletime.uninitialized`. + | This construct can be rewritten automatically under -rewrite -source 3.4-migration. diff --git a/tests/neg/i11225b.scala b/tests/neg/i11225b.scala index a9dd1d3d2227..c2b94571e06c 100644 --- a/tests/neg/i11225b.scala +++ b/tests/neg/i11225b.scala @@ -1,4 +1,4 @@ -//> using options -source future -deprecation -Xfatal-warnings +//> using options -source future -deprecation import compiletime.uninitialized @@ -10,3 +10,4 @@ class Memo[A](x: => A): known = true cached = x cached + diff --git a/tests/neg/i11333.check b/tests/neg/i11333.check deleted file mode 100644 index ba5723488899..000000000000 --- a/tests/neg/i11333.check +++ /dev/null @@ -1,30 +0,0 @@ --- [E167] Lossy Conversion Error: tests/neg/i11333.scala:4:19 ---------------------------------------------------------- -4 | val f1: Float = 123456789 // error - | ^^^^^^^^^ - | Widening conversion from Int to Float loses precision. - | Write `.toFloat` instead. --- [E167] Lossy Conversion Error: tests/neg/i11333.scala:5:19 ---------------------------------------------------------- -5 | val d1: Double = 1234567890123456789L // error - | ^^^^^^^^^^^^^^^^^^^^ - | Widening conversion from Long to Double loses precision. - | Write `.toDouble` instead. --- [E167] Lossy Conversion Error: tests/neg/i11333.scala:6:19 ---------------------------------------------------------- -6 | val f2: Float = 123456789L // error - | ^^^^^^^^^^ - | Widening conversion from Long to Float loses precision. - | Write `.toFloat` instead. --- [E167] Lossy Conversion Error: tests/neg/i11333.scala:12:21 --------------------------------------------------------- -12 | val f1_b: Float = i1 // error - | ^^ - | Widening conversion from Int to Float loses precision. - | Write `.toFloat` instead. --- [E167] Lossy Conversion Error: tests/neg/i11333.scala:13:21 --------------------------------------------------------- -13 | val d1_b: Double = l1 // error - | ^^ - | Widening conversion from Long to Double loses precision. - | Write `.toDouble` instead. --- [E167] Lossy Conversion Error: tests/neg/i11333.scala:14:21 --------------------------------------------------------- -14 | val f2_b: Float = l2 // error - | ^^ - | Widening conversion from Long to Float loses precision. - | Write `.toFloat` instead. diff --git a/tests/neg/i11333.scala b/tests/neg/i11333.scala deleted file mode 100644 index bbdcceaf7e1e..000000000000 --- a/tests/neg/i11333.scala +++ /dev/null @@ -1,14 +0,0 @@ -//> using options -Xfatal-warnings - -class C: - val f1: Float = 123456789 // error - val d1: Double = 1234567890123456789L // error - val f2: Float = 123456789L // error - - inline val i1 = 123456789 - inline val l1 = 1234567890123456789L - inline val l2 = 123456789L - - val f1_b: Float = i1 // error - val d1_b: Double = l1 // error - val f2_b: Float = l2 // error diff --git a/tests/neg/i11963a.scala b/tests/neg/i11963a.scala deleted file mode 100644 index 0eb2f557624f..000000000000 --- a/tests/neg/i11963a.scala +++ /dev/null @@ -1,3 +0,0 @@ -//> using options -Xfatal-warnings - -open trait Foo // error diff --git a/tests/neg/i11963b.scala b/tests/neg/i11963b.scala deleted file mode 100644 index 76097b225896..000000000000 --- a/tests/neg/i11963b.scala +++ /dev/null @@ -1,3 +0,0 @@ -//> using options -Xfatal-warnings - -open abstract class Foo // error diff --git a/tests/neg/i11963c.scala b/tests/neg/i11963c.scala deleted file mode 100644 index f58f68c72368..000000000000 --- a/tests/neg/i11963c.scala +++ /dev/null @@ -1,8 +0,0 @@ -//> using options -Xfatal-warnings - -object Test { - def foo: Any = { - open class Bar // error - new Bar - } -} diff --git a/tests/neg/i12188/Test.scala b/tests/neg/i12188/Test.scala index 66864438694e..9bbbf6431b13 100644 --- a/tests/neg/i12188/Test.scala +++ b/tests/neg/i12188/Test.scala @@ -7,5 +7,7 @@ case class PC2(b: Int) extends P def Test = MatchTest.test(PC2(10): P) def foo(x: P): Unit = - x match // error - case _: PC1 => \ No newline at end of file + x match // warn + case _: PC1 => + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i12597.scala b/tests/neg/i12597.scala deleted file mode 100644 index b8859a0ae991..000000000000 --- a/tests/neg/i12597.scala +++ /dev/null @@ -1,7 +0,0 @@ -//> using options -Xfatal-warnings -deprecation - -@main def Test = - val a: IArray[Int] = IArray(2) - val b: IArray[Any] = a - val c = b.toArray // error: deprecated - c(0) = "" diff --git a/tests/neg/i13440.scala b/tests/neg/i13440.scala deleted file mode 100644 index 443215c621ef..000000000000 --- a/tests/neg/i13440.scala +++ /dev/null @@ -1,9 +0,0 @@ -//> using options -Xfatal-warnings - -import language.`3.0-migration` - -def given = 42 // error - -case class C(enum: List[Int] = Nil) { // error - val s = s"$enum" // error -} diff --git a/tests/neg/i13946/BadPrinter.scala b/tests/neg/i13946/BadPrinter.scala index 46913d2c2805..39e8a921d498 100644 --- a/tests/neg/i13946/BadPrinter.scala +++ b/tests/neg/i13946/BadPrinter.scala @@ -2,5 +2,6 @@ // in BadPrinter.scala import language.future -class BadPrinter extends Printer: // error +class BadPrinter extends Printer: // warn override def print(s: String): Unit = println("Bad!!!") +// nopos-error: No warnings can be incurred under -Werror. diff --git a/tests/neg/i14386.scala b/tests/neg/i14386.scala index be0b2497ed5f..d9647da49525 100644 --- a/tests/neg/i14386.scala +++ b/tests/neg/i14386.scala @@ -42,7 +42,8 @@ def braced() = s"""begin ${ val level = 10 - val msg = "hello, world" // error he lets me off with a warning - log(level, msg) // error + val msg = "hello, world" // warn he lets me off with a warning + log(level, msg) // warn } end""" +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i14705.scala b/tests/neg/i14705.scala deleted file mode 100644 index 9ffb4443416e..000000000000 --- a/tests/neg/i14705.scala +++ /dev/null @@ -1,5 +0,0 @@ -//> using options -Xfatal-warnings - -val n = Nil -val b = n.head.isInstanceOf[String] // error - diff --git a/tests/neg/i15503h.scala b/tests/neg/i15503h.scala deleted file mode 100644 index cef1f6cf566f..000000000000 --- a/tests/neg/i15503h.scala +++ /dev/null @@ -1,20 +0,0 @@ -//> using options -Xfatal-warnings -Wunused:linted - -import collection.mutable.Set // error - -class A { - private val a = 1 // error - val b = 2 // OK - - private def c = 2 // error - def d(using x:Int): Int = b // ok - def e(x: Int) = 1 // OK - def f = - val x = 1 // error - def f = 2 // error - 3 - - def g(x: Int): Int = x match - case x:1 => 0 // OK - case _ => 1 -} \ No newline at end of file diff --git a/tests/neg/i16876/Test.scala b/tests/neg/i16876/Test.scala index 2dd6bfb34421..71a01128990e 100644 --- a/tests/neg/i16876/Test.scala +++ b/tests/neg/i16876/Test.scala @@ -4,8 +4,7 @@ object Foo { private def myMethod(a: Int, b: Int, c: Int) = adder // ok myMethod(1, 2, 3) - private def myMethodFailing(a: Int, b: Int, c: Int) = a + 0 // error // error + 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. \ No newline at end of file diff --git a/tests/neg/i17612b.check b/tests/neg/i17612b.check index 75e8b7312833..ae5b071d6187 100644 --- a/tests/neg/i17612b.check +++ b/tests/neg/i17612b.check @@ -1,32 +1,33 @@ --- Error: tests/neg/i17612b/i17612b.scala:21:15 ------------------------------------------------------------------------ -21 | class Derived(x : Int, x3: Int, y: Int, z2: Int) extends BaseB, BaseC(x3), Base(x, y + 1, z2): // error // error / for x, y translated to private[this] x field & shadowing var Base.x, Base.y +-- Warning: tests/neg/i17612b/i17612b.scala:21:15 ---------------------------------------------------------------------- +21 | class Derived(x : Int, x3: Int, y: Int, z2: Int) extends BaseB, BaseC(x3), Base(x, y + 1, z2): // warn // warn / for x, y translated to private[this] x field & shadowing var Base.x, Base.y | ^ | value x in class Derived shadows field x inherited from trait Base --- Error: tests/neg/i17612b/i17612b.scala:21:33 ------------------------------------------------------------------------ -21 | class Derived(x : Int, x3: Int, y: Int, z2: Int) extends BaseB, BaseC(x3), Base(x, y + 1, z2): // error // error / for x, y translated to private[this] x field & shadowing var Base.x, Base.y +-- Warning: tests/neg/i17612b/i17612b.scala:21:33 ---------------------------------------------------------------------- +21 | class Derived(x : Int, x3: Int, y: Int, z2: Int) extends BaseB, BaseC(x3), Base(x, y + 1, z2): // warn // warn / for x, y translated to private[this] x field & shadowing var Base.x, Base.y | ^ | value y in class Derived shadows field y inherited from trait Base --- Error: tests/neg/i17612b/i17612b.scala:23:2 ------------------------------------------------------------------------- -23 | private val shadowed2 = 2 + 2 // error (In Scala 2 we cannot do that got the warning) +-- Warning: tests/neg/i17612b/i17612b.scala:23:2 ----------------------------------------------------------------------- +23 | private val shadowed2 = 2 + 2 // warn (In Scala 2 we cannot do that got the warning) | ^ | value shadowed2 in class Derived shadows field shadowed2 inherited from trait Base --- Error: tests/neg/i17612b/i17612b.scala:24:2 ------------------------------------------------------------------------- -24 | private[this] val shadowed3 = 3 + 3 // error +-- Warning: tests/neg/i17612b/i17612b.scala:24:2 ----------------------------------------------------------------------- +24 | private[this] val shadowed3 = 3 + 3 // warn | ^ | value shadowed3 in class Derived shadows field shadowed3 inherited from trait Base --- Error: tests/neg/i17612b/i17612b.scala:26:2 ------------------------------------------------------------------------- -26 | private val shadowed5 = 5 + 5 // error +-- Warning: tests/neg/i17612b/i17612b.scala:26:2 ----------------------------------------------------------------------- +26 | private val shadowed5 = 5 + 5 // warn | ^ | value shadowed5 in class Derived shadows field shadowed5 inherited from trait Base --- Error: tests/neg/i17612b/i17612b.scala:41:20 ------------------------------------------------------------------------ -41 | class UnderDerived(x: Int, y: Int, z: Int) extends Derived(x, 1, y, z) // error // error // error +-- Warning: tests/neg/i17612b/i17612b.scala:41:20 ---------------------------------------------------------------------- +41 | class UnderDerived(x: Int, y: Int, z: Int) extends Derived(x, 1, y, z) // warn // warn // warn | ^ | value x in class UnderDerived shadows field x inherited from trait Base --- Error: tests/neg/i17612b/i17612b.scala:41:28 ------------------------------------------------------------------------ -41 | class UnderDerived(x: Int, y: Int, z: Int) extends Derived(x, 1, y, z) // error // error // error +-- Warning: tests/neg/i17612b/i17612b.scala:41:28 ---------------------------------------------------------------------- +41 | class UnderDerived(x: Int, y: Int, z: Int) extends Derived(x, 1, y, z) // warn // warn // warn | ^ | value y in class UnderDerived shadows field y inherited from trait Base --- Error: tests/neg/i17612b/i17612b.scala:41:36 ------------------------------------------------------------------------ -41 | class UnderDerived(x: Int, y: Int, z: Int) extends Derived(x, 1, y, z) // error // error // error +-- Warning: tests/neg/i17612b/i17612b.scala:41:36 ---------------------------------------------------------------------- +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. diff --git a/tests/neg/i17612b/i17612b.scala b/tests/neg/i17612b/i17612b.scala index d16feb240c2a..a1aa1973cea2 100644 --- a/tests/neg/i17612b/i17612b.scala +++ b/tests/neg/i17612b/i17612b.scala @@ -18,12 +18,12 @@ object i17612b: trait BaseB trait BaseC(var x2: Int) - class Derived(x : Int, x3: Int, y: Int, z2: Int) extends BaseB, BaseC(x3), Base(x, y + 1, z2): // error // error / for x, y translated to private[this] x field & shadowing var Base.x, Base.y + class Derived(x : Int, x3: Int, y: Int, z2: Int) extends BaseB, BaseC(x3), Base(x, y + 1, z2): // warn // warn / for x, y translated to private[this] x field & shadowing var Base.x, Base.y private def hello() = 4 - private val shadowed2 = 2 + 2 // error (In Scala 2 we cannot do that got the warning) - private[this] val shadowed3 = 3 + 3 // error + private val shadowed2 = 2 + 2 // warn (In Scala 2 we cannot do that got the warning) + private[this] val shadowed3 = 3 + 3 // warn - private val shadowed5 = 5 + 5 // error + private val shadowed5 = 5 + 5 // warn private val notShadowed2 = -4 val lambda: Int => Int => Int = @@ -38,7 +38,8 @@ object i17612b: override def toString = s"x : ${x.toString}, y : ${y.toString}" - class UnderDerived(x: Int, y: Int, z: Int) extends Derived(x, 1, y, z) // error // error // error + class UnderDerived(x: Int, y: Int, z: Int) extends Derived(x, 1, y, z) // warn // warn // warn def main(args: Array[String]) = val derived = new Derived(1, 1, 1, 1) +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i17613a.scala b/tests/neg/i17613a.scala deleted file mode 100644 index d0e413098cec..000000000000 --- a/tests/neg/i17613a.scala +++ /dev/null @@ -1,23 +0,0 @@ -//> using options -Xfatal-warnings -Xlint:type-parameter-shadow - -object i17613a: - class B: - type T = Int - trait D - - def foobar[D](in: D) = in.toString // error method parameter shadows some other type - type MySeq[D] = Seq[D] // error type member's parameter shadows some other type - - class Foo[T](t: T): // error class parameter shadows some other type - def bar[T](w: T) = w.toString // error a type parameter shadows another type parameter - - // even deeply nested... - class C[M[List[_]]] // error - type E[M[List[_]]] = Int // error - def foo[N[M[List[_]]]] = ??? // error - - // ...but not between type parameters in the same list - class F[A, M[N[A]]] - type G[A, M[L[A]]] = Int - def bar[A, N[M[L[A]]]] = ??? - def main(args: Array[String]) = println("Test for type parameter shadow") diff --git a/tests/neg/i17613b.check b/tests/neg/i17613b.check index d8cf8618fb27..15dd2f6451e6 100644 --- a/tests/neg/i17613b.check +++ b/tests/neg/i17613b.check @@ -1,56 +1,61 @@ --- Error: tests/neg/i17613b/i17613b.scala:9:13 ------------------------------------------------------------------------- -9 | def foobar[ImTrait](in: D) = in.toString // error - | ^^^^^^^ - | Type parameter ImTrait for method foobar shadows the type defined by trait ImTrait in object importTry --- Error: tests/neg/i17613b/i17613b.scala:10:13 ------------------------------------------------------------------------ -10 | type MySeq[ImTrait] = Seq[D] // error +-- Warning: tests/neg/i17613b/i17613b.scala:7:18 ----------------------------------------------------------------------- +7 | trait Typeclass[T] + | ^ + | Type parameter T for trait Typeclass shadows the type defined by type T in class B +-- Warning: tests/neg/i17613b/i17613b.scala:10:13 ---------------------------------------------------------------------- +10 | def foobar[ImTrait](in: D) = in.toString // warn + | ^^^^^^^ + | Type parameter ImTrait for method foobar shadows the type defined by trait ImTrait in object importTry +-- Warning: tests/neg/i17613b/i17613b.scala:11:13 ---------------------------------------------------------------------- +11 | type MySeq[ImTrait] = Seq[D] // warn | ^^^^^^^ | Type parameter ImTrait for type MySeq shadows the type defined by trait ImTrait in object importTry --- Error: tests/neg/i17613b/i17613b.scala:12:14 ------------------------------------------------------------------------ -12 | def foobar2[ImClass](in: D) = in.toString // error +-- Warning: tests/neg/i17613b/i17613b.scala:13:14 ---------------------------------------------------------------------- +13 | def foobar2[ImClass](in: D) = in.toString // warn | ^^^^^^^ | Type parameter ImClass for method foobar2 shadows the type defined by class ImClass in object importTry --- Error: tests/neg/i17613b/i17613b.scala:13:14 ------------------------------------------------------------------------ -13 | type MySeq2[ImClass] = Seq[D] // error +-- Warning: tests/neg/i17613b/i17613b.scala:14:14 ---------------------------------------------------------------------- +14 | type MySeq2[ImClass] = Seq[D] // warn | ^^^^^^^ | Type parameter ImClass for type MySeq2 shadows the type defined by class ImClass in object importTry --- Error: tests/neg/i17613b/i17613b.scala:16:24 ------------------------------------------------------------------------ -16 | type TypeLambda[A] = [ImTrait] =>> Map[ImTrait, B] // error +-- Warning: tests/neg/i17613b/i17613b.scala:17:24 ---------------------------------------------------------------------- +17 | type TypeLambda[A] = [ImTrait] =>> Map[ImTrait, B] | ^^^^^^^ | Type parameter ImTrait for type TypeLambda shadows the type defined by trait ImTrait in object importTry --- Error: tests/neg/i17613b/i17613b.scala:17:21 ------------------------------------------------------------------------ -17 | type PolyFun[A] = [ImTrait] => ImTrait => B // error +-- Warning: tests/neg/i17613b/i17613b.scala:18:21 ---------------------------------------------------------------------- +18 | type PolyFun[A] = [ImTrait] => ImTrait => B // warn | ^^^^^^^ | Type parameter ImTrait for type PolyFun shadows the type defined by trait ImTrait in object importTry --- Error: tests/neg/i17613b/i17613b.scala:23:12 ------------------------------------------------------------------------ -23 | class Foo[T](t: T): // error class parameter shadows some other type +-- Warning: tests/neg/i17613b/i17613b.scala:24:12 ---------------------------------------------------------------------- +24 | class Foo[T](t: T): // warn class parameter shadows some other type | ^ | Type parameter T for class Foo shadows the type defined by type T in class B --- Error: tests/neg/i17613b/i17613b.scala:27:15 ------------------------------------------------------------------------ -27 | def intType[List1](x: T) = x.toString() // error +-- Warning: tests/neg/i17613b/i17613b.scala:28:15 ---------------------------------------------------------------------- +28 | def intType[List1](x: T) = x.toString() // warn | ^^^^^ | Type parameter List1 for method intType shadows an explicitly renamed type : List1 --- Error: tests/neg/i17613b/i17613b.scala:32:10 ------------------------------------------------------------------------ -32 | given [Int]: Ordering[Int]() // error +-- Warning: tests/neg/i17613b/i17613b.scala:33:10 ---------------------------------------------------------------------- +33 | given [Int]: Typeclass[Int]() // warn | ^^^ - | Type parameter Int for method given_Ordering_Int shadows the type defined by class Int in package scala --- Error: tests/neg/i17613b/i17613b.scala:34:12 ------------------------------------------------------------------------ -34 | class C[M[List[_]]] // error List not renamed here + | Type parameter Int for method given_Typeclass_Int shadows the type defined by class Int in package scala +-- Warning: tests/neg/i17613b/i17613b.scala:35:12 ---------------------------------------------------------------------- +35 | class C[M[List[_]]] // warn List not renamed here | ^^^^^^^ | Type parameter List for class C shadows the type defined by type List in package scala --- Error: tests/neg/i17613b/i17613b.scala:35:11 ------------------------------------------------------------------------ -35 | type E[M[Int[_]]] = Int // error +-- Warning: tests/neg/i17613b/i17613b.scala:36:11 ---------------------------------------------------------------------- +36 | type E[M[Int[_]]] = Int // warn | ^^^^^^ | Type parameter Int for type E shadows the type defined by class Int in package scala --- Error: tests/neg/i17613b/i17613b.scala:37:14 ------------------------------------------------------------------------ -37 | def foo[N[M[List[_]]]] = // error +-- Warning: tests/neg/i17613b/i17613b.scala:38:14 ---------------------------------------------------------------------- +38 | def foo[N[M[List[_]]]] = // warn | ^^^^^^^ | Type parameter List for method foo shadows the type defined by type List in package scala --- Error: tests/neg/i17613b/i17613b.scala:40:11 ------------------------------------------------------------------------ -40 | type Z[ImClassR] = Int // error +-- Warning: tests/neg/i17613b/i17613b.scala:41:11 ---------------------------------------------------------------------- +41 | type Z[ImClassR] = Int // warn | ^^^^^^^^ | Type parameter ImClassR for type Z shadows an explicitly renamed type : ImClassR --- Error: tests/neg/i17613b/i17613b.scala:41:18 ------------------------------------------------------------------------ -41 | class InnerCl[ImClassR] // error +-- Warning: tests/neg/i17613b/i17613b.scala:42:18 ---------------------------------------------------------------------- +42 | class InnerCl[ImClassR] // warn | ^^^^^^^^ | Type parameter ImClassR for class InnerCl shadows an explicitly renamed type : ImClassR +No warnings can be incurred under -Werror. diff --git a/tests/neg/i17613b/i17613b.scala b/tests/neg/i17613b/i17613b.scala index b0c4f11b949c..42506a274a65 100644 --- a/tests/neg/i17613b/i17613b.scala +++ b/tests/neg/i17613b/i17613b.scala @@ -1,44 +1,47 @@ -//> using options -Xfatal-warnings -Xlint:type-parameter-shadow +//> using options -Xlint:type-parameter-shadow -Xfatal-warnings object i17613b: import importTry._ class B: type T = Int + trait Typeclass[T] trait D - def foobar[ImTrait](in: D) = in.toString // error - type MySeq[ImTrait] = Seq[D] // error + def foobar[ImTrait](in: D) = in.toString // warn + type MySeq[ImTrait] = Seq[D] // warn - def foobar2[ImClass](in: D) = in.toString // error - type MySeq2[ImClass] = Seq[D] // error + def foobar2[ImClass](in: D) = in.toString // warn + type MySeq2[ImClass] = Seq[D] // warn - given [A]: Ordering[Int]() - type TypeLambda[A] = [ImTrait] =>> Map[ImTrait, B] // error - type PolyFun[A] = [ImTrait] => ImTrait => B // error + given [A]: Typeclass[Int]() // warn + type TypeLambda[A] = [ImTrait] =>> Map[ImTrait, B] + type PolyFun[A] = [ImTrait] => ImTrait => B // warn type MatchType[A] = A match { case String => Int case ImTrait => Boolean } - class Foo[T](t: T): // error class parameter shadows some other type + class Foo[T](t: T): // warn class parameter shadows some other type import scala.collection.immutable.{List => List1} def bar[List](w: T) = w.toString // no warning due to the explicit import renaming - def intType[List1](x: T) = x.toString() // error + def intType[List1](x: T) = x.toString() // warn type Y[List] = Int // no warning - given [A]: Ordering[A]() - given [Int]: Ordering[Int]() // error + given [A]: Typeclass[A]() + given [Int]: Typeclass[Int]() // warn - class C[M[List[_]]] // error List not renamed here - type E[M[Int[_]]] = Int // error + class C[M[List[_]]] // warn List not renamed here + type E[M[Int[_]]] = Int // warn - def foo[N[M[List[_]]]] = // error + def foo[N[M[List[_]]]] = // warn import importTry.{ImClass => ImClassR} def inner[ImClass] = // no warning - type Z[ImClassR] = Int // error - class InnerCl[ImClassR] // error + type Z[ImClassR] = Int // warn + class InnerCl[ImClassR] // warn 5 - def main(args: Array[String]) = println("Test for type parameter shadow") \ No newline at end of file + def main(args: Array[String]) = println("Test for type parameter shadow") + + // nopos-error fatal warnings diff --git a/tests/neg/i18722.scala b/tests/neg/i18722.scala deleted file mode 100644 index c68390b76201..000000000000 --- a/tests/neg/i18722.scala +++ /dev/null @@ -1,9 +0,0 @@ -//> using options -Werror -explain - -def f1: Unit = null // error -def f2: Unit = 1 // error -def f3: Unit = "a" // error -val i: Int = 1 -def f4: Unit = i // error -val u: Unit = () -def f5: Unit = u diff --git a/tests/neg/i18862-3.4.scala b/tests/neg/i18862-3.4.scala deleted file mode 100644 index a30c8c8f1a59..000000000000 --- a/tests/neg/i18862-3.4.scala +++ /dev/null @@ -1,6 +0,0 @@ -//> using options -Werror - -import scala.language.`3.4` - -def f(x: Int*): Unit = () -def test(xs: List[Int]): Unit = f(xs: _*) // error: migration warning diff --git a/tests/neg/i18862-future-migration.scala b/tests/neg/i18862-future-migration.scala deleted file mode 100644 index ff8ba1c377c3..000000000000 --- a/tests/neg/i18862-future-migration.scala +++ /dev/null @@ -1,6 +0,0 @@ -//> using options -Werror - -import scala.language.`future-migration` - -def f(x: Int*): Unit = () -def test(xs: List[Int]): Unit = f(xs: _*) // error: migration warning diff --git a/tests/neg/i18867-3.4.scala b/tests/neg/i18867-3.4.scala deleted file mode 100644 index c5fd2976c8b0..000000000000 --- a/tests/neg/i18867-3.4.scala +++ /dev/null @@ -1,7 +0,0 @@ -//> using options -Werror - -import language.`3.4` - -def foo(x: Int) = x - -def test = foo _ // error diff --git a/tests/neg/i18867.scala b/tests/neg/i18867.scala deleted file mode 100644 index 722347a613f5..000000000000 --- a/tests/neg/i18867.scala +++ /dev/null @@ -1,5 +0,0 @@ -//> using options -Werror - -def foo(x: Int) = x - -def test = foo _ // error diff --git a/tests/neg/i2333.scala b/tests/neg/i2333.scala deleted file mode 100644 index 67cddbc73f48..000000000000 --- a/tests/neg/i2333.scala +++ /dev/null @@ -1,11 +0,0 @@ -//> using options -Xfatal-warnings -deprecation - -@deprecated("bla", "2.11.0") class Foo { - println("") - def this(x: Int) = this() -} - -object Test { - new Foo // error: deprecated - new Foo(1) // error: deprecated -} \ No newline at end of file diff --git a/tests/neg/i2673.scala b/tests/neg/i2673.scala deleted file mode 100644 index 62c787fa00fb..000000000000 --- a/tests/neg/i2673.scala +++ /dev/null @@ -1,6 +0,0 @@ -//> using options -Xfatal-warnings - -package Foos - -class Foo // error -class foo diff --git a/tests/neg/i2673b.scala b/tests/neg/i2673b.scala deleted file mode 100644 index 26e09ec3297e..000000000000 --- a/tests/neg/i2673b.scala +++ /dev/null @@ -1,6 +0,0 @@ -//> using options -Xfatal-warnings - -package Foos - -class Bar // error -object bar diff --git a/tests/neg/i2673c.scala b/tests/neg/i2673c.scala deleted file mode 100644 index 575d8c25d9e0..000000000000 --- a/tests/neg/i2673c.scala +++ /dev/null @@ -1,8 +0,0 @@ -//> using options -Xfatal-warnings - -package Foos - -object Outer { - case class X() // error - object x -} diff --git a/tests/neg/i4812.check b/tests/neg/i4812.check deleted file mode 100644 index f4aee0e35dde..000000000000 --- a/tests/neg/i4812.check +++ /dev/null @@ -1,42 +0,0 @@ --- [E092] Pattern Match Error: tests/neg/i4812.scala:8:11 -------------------------------------------------------------- -8 | case prev: A => // error: the type test for A cannot be checked at runtime - | ^ - | the type test for A cannot be checked at runtime because it's a local class - | - | longer explanation available when compiling with `-explain` --- [E092] Pattern Match Error: tests/neg/i4812.scala:18:11 ------------------------------------------------------------- -18 | case prev: A => // error: the type test for A cannot be checked at runtime - | ^ - | the type test for A cannot be checked at runtime because it's a local class - | - | longer explanation available when compiling with `-explain` --- [E092] Pattern Match Error: tests/neg/i4812.scala:28:11 ------------------------------------------------------------- -28 | case prev: A => // error: the type test for A cannot be checked at runtime - | ^ - | the type test for A cannot be checked at runtime because it's a local class - | - | longer explanation available when compiling with `-explain` --- [E092] Pattern Match Error: tests/neg/i4812.scala:38:11 ------------------------------------------------------------- -38 | case prev: A => // error: the type test for A cannot be checked at runtime - | ^ - | the type test for A cannot be checked at runtime because it's a local class - | - | longer explanation available when compiling with `-explain` --- [E092] Pattern Match Error: tests/neg/i4812.scala:50:13 ------------------------------------------------------------- -50 | case prev: A => // error: the type test for A cannot be checked at runtime - | ^ - | the type test for A cannot be checked at runtime because it's a local class - | - | longer explanation available when compiling with `-explain` --- [E092] Pattern Match Error: tests/neg/i4812.scala:60:11 ------------------------------------------------------------- -60 | case prev: A => // error: the type test for A cannot be checked at runtime - | ^ - | the type test for A cannot be checked at runtime because it's a local class - | - | longer explanation available when compiling with `-explain` --- [E092] Pattern Match Error: tests/neg/i4812.scala:96:11 ------------------------------------------------------------- -96 | case x: B => // error: the type test for B cannot be checked at runtime - | ^ - | the type test for B cannot be checked at runtime because it's a local class - | - | longer explanation available when compiling with `-explain` diff --git a/tests/neg/i4936b.scala b/tests/neg/i4936b.scala deleted file mode 100644 index 58c240e92309..000000000000 --- a/tests/neg/i4936b.scala +++ /dev/null @@ -1,3 +0,0 @@ -//> using options -Xfatal-warnings - -final object Foo // error diff --git a/tests/neg/i4986d.scala b/tests/neg/i4986d.scala index 909221bea5f0..73c92822a291 100644 --- a/tests/neg/i4986d.scala +++ b/tests/neg/i4986d.scala @@ -3,10 +3,10 @@ trait Foo[A] type Fooable[A] = { - def foo(implicit @annotation.implicitNotFound("There's no Foo[${A}]") ev: Foo[A]): Any // error + def foo(implicit @annotation.implicitNotFound("There's no Foo[${A}]") ev: Foo[A]): Any // warn type InnerFooable = { - def foo(implicit @annotation.implicitNotFound("There's no Foo[${A}]") ev: Foo[A]): Any // error + def foo(implicit @annotation.implicitNotFound("There's no Foo[${A}]") ev: Foo[A]): Any // warn } } @@ -22,3 +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. \ No newline at end of file diff --git a/tests/neg/i5013.scala b/tests/neg/i5013.scala deleted file mode 100644 index adf09e2cf3be..000000000000 --- a/tests/neg/i5013.scala +++ /dev/null @@ -1,11 +0,0 @@ -//> using options -Xfatal-warnings - -class Foo { - - def foo1: Unit = 2 // error: A pure expression does nothing in statement position - - def foo2: Unit = { - 3 // error: A pure expression does nothing in statement position - 4 // error: A pure expression does nothing in statement position - } -} diff --git a/tests/neg/i6190b.scala b/tests/neg/i6190b.scala deleted file mode 100644 index 42270c1a984c..000000000000 --- a/tests/neg/i6190b.scala +++ /dev/null @@ -1,5 +0,0 @@ -//> using options -Xfatal-warnings - -case class Rule(name: String) - -def foo = List("1", "2").map(Rule) // error diff --git a/tests/neg/i7821b.scala b/tests/neg/i7821b.scala deleted file mode 100644 index f82a38d259e1..000000000000 --- a/tests/neg/i7821b.scala +++ /dev/null @@ -1,13 +0,0 @@ -//> using options -Xfatal-warnings - -object Test { - - { def f(x: Int, y: Int): Int = f(x, y) } // error - { def f(x: Int, y: Int): Int = { f(x, y) } } // error - { def f(x: Int, y: Int): Int = f(y, x) } // error - { def f(x: Int, y: Int): Int = f(x, x) } // error - { def f(x: Int, y: Int): Int = f(1, 1) } // error - { def f(x: Int, y: Int): Int = { val a = 3; f(a, 1) } } // error - { def f(x: Int): Int = f(1) } // error - -} diff --git a/tests/neg/i8681.scala b/tests/neg/i8681.scala index 4d91509eb0d3..f7e7066fd2e0 100644 --- a/tests/neg/i8681.scala +++ b/tests/neg/i8681.scala @@ -13,4 +13,5 @@ val b = (A(1): A | B) match { case A(_) => "OK" case B(_) => "OK" case C(_) => "NOT OK" // error -} \ No newline at end of file +} +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i8711.check b/tests/neg/i8711.check index 5dbeeb22460c..10764e936b5a 100644 --- a/tests/neg/i8711.check +++ b/tests/neg/i8711.check @@ -1,12 +1,21 @@ --- [E030] Match case Unreachable Error: tests/neg/i8711.scala:9:9 ------------------------------------------------------ +-- [E030] Match case Unreachable Warning: tests/neg/i8711.scala:9:9 ---------------------------------------------------- 9 | case x: B => x // error: this case is unreachable since class A is not a subclass of class B | ^^^^ | Unreachable case --- [E030] Match case Unreachable Error: tests/neg/i8711.scala:14:9 ----------------------------------------------------- +-- [E030] Match case Unreachable Warning: tests/neg/i8711.scala:14:9 --------------------------------------------------- 14 | case x: C => x // error | ^^^^ | Unreachable case --- [E030] Match case Unreachable Error: tests/neg/i8711.scala:19:9 ----------------------------------------------------- -19 | case x: (B | C) => x // error +-- [E030] Match case Unreachable Warning: tests/neg/i8711.scala:19:9 --------------------------------------------------- +19 | case x: (B | C) => x // warn | ^^^^^^^^^^ | Unreachable case +-- Error: tests/neg/i8711.scala:9:9 ------------------------------------------------------------------------------------ +9 | case x: B => x // error: this case is unreachable since class A is not a subclass of class B + | ^ + | this case is unreachable since type A and class B are unrelated +-- Error: tests/neg/i8711.scala:14:9 ----------------------------------------------------------------------------------- +14 | case x: C => x // error + | ^ + | this case is unreachable since type A | B and class C are unrelated +No warnings can be incurred under -Werror. diff --git a/tests/neg/i8711.scala b/tests/neg/i8711.scala index 2647e20fe03b..0ae32393a327 100644 --- a/tests/neg/i8711.scala +++ b/tests/neg/i8711.scala @@ -16,7 +16,9 @@ object Test { } def baz(x: A) = x match { - case x: (B | C) => x // error + case x: (B | C) => x // warn case _ => } } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i8781b.scala b/tests/neg/i8781b.scala deleted file mode 100644 index 7c9b074e1be7..000000000000 --- a/tests/neg/i8781b.scala +++ /dev/null @@ -1,7 +0,0 @@ -//> using options -Xfatal-warnings - -object Test: - - println((3: Boolean | Int).isInstanceOf[Boolean]) - - println(3.isInstanceOf[Boolean]) // error diff --git a/tests/neg/i9166.scala b/tests/neg/i9166.scala deleted file mode 100644 index b9644bf56f71..000000000000 --- a/tests/neg/i9166.scala +++ /dev/null @@ -1,7 +0,0 @@ -//> using options -Xfatal-warnings -Wimplausible-patterns -object UnitTest extends App { - def foo(m: Unit) = m match { - case runtime.BoxedUnit.UNIT => println("ok") // error - } - foo(()) -} diff --git a/tests/neg/i9266.scala b/tests/neg/i9266.scala deleted file mode 100644 index e6f8db7417c7..000000000000 --- a/tests/neg/i9266.scala +++ /dev/null @@ -1,5 +0,0 @@ -//> using options -Xfatal-warnings - -import language.`future-migration` - -def test = { implicit x: Int => x + x } // error diff --git a/tests/neg/i9408b.check b/tests/neg/i9408b.check index 5f8a854a9282..4d86f5a0ef0b 100644 --- a/tests/neg/i9408b.check +++ b/tests/neg/i9408b.check @@ -1,5 +1,6 @@ --- Error: tests/neg/i9408b/Test_2.scala:8:20 --------------------------------------------------------------------------- -8 | val length: Int = "abc" // error +-- Migration Warning: tests/neg/i9408b/Test_2.scala:8:20 --------------------------------------------------------------- +8 | val length: Int = "abc" // warn | ^^^^^ |The conversion (test.conversions.Conv.implicitLength : String => Int) will not be applied implicitly here in Scala 3 because only implicit methods and instances of Conversion class will continue to work as implicit views. +No warnings can be incurred under -Werror. diff --git a/tests/neg/i9408b/Test_2.scala b/tests/neg/i9408b/Test_2.scala index 6b3cbbafcb0e..11cad10f1e9f 100644 --- a/tests/neg/i9408b/Test_2.scala +++ b/tests/neg/i9408b/Test_2.scala @@ -5,5 +5,7 @@ import scala.language.implicitConversions object Test { import test.conversions.Conv.* - val length: Int = "abc" // error + val length: Int = "abc" // warn } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i9751.scala b/tests/neg/i9751.scala deleted file mode 100644 index 618d237e0cd4..000000000000 --- a/tests/neg/i9751.scala +++ /dev/null @@ -1,11 +0,0 @@ -//> using options -Xfatal-warnings - -def f(): Unit = { - () // error - () -} - -inline def g(): Unit = { - () // error - () -} diff --git a/tests/neg/impl-conv/A.scala b/tests/neg/impl-conv/A.scala index 31eccf4fa4f7..9c47e67ca789 100644 --- a/tests/neg/impl-conv/A.scala +++ b/tests/neg/impl-conv/A.scala @@ -2,7 +2,7 @@ package implConv object A { - implicit def s2i(x: String): Int = Integer.parseInt(x) // error: feature + implicit def s2i(x: String): Int = Integer.parseInt(x) // warn: feature given i2s: Conversion[Int, String] = _.toString // ok implicit class Foo(x: String) { diff --git a/tests/neg/impl-conv/B.scala b/tests/neg/impl-conv/B.scala index 618868b8bbc0..b475c460f318 100644 --- a/tests/neg/impl-conv/B.scala +++ b/tests/neg/impl-conv/B.scala @@ -8,5 +8,6 @@ object B { "".foo val x: Int = "" // ok - val y: String = 1 // error: feature + val y: String = 1 // warn: feature } +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/implicit-conversions-old.scala b/tests/neg/implicit-conversions-old.scala deleted file mode 100644 index 0a7b75766bbf..000000000000 --- a/tests/neg/implicit-conversions-old.scala +++ /dev/null @@ -1,25 +0,0 @@ -//> using options -Xfatal-warnings -feature - -class A -class B - -object A { - - implicit def a2b(x: A): B = ??? // error under -Xfatal-warnings -feature - - implicit def b2a(x: B): A = ??? // error under -Xfatal-warnings -feature -} - -class C - -object D { - implicit def a2c(x: A): C = ??? // error under -Xfatal-warnings -feature -} - -object Test { - import D.* - - val x1: A = new B - val x2: B = new A // ok, since it's an old-style comversion - val x3: C = new A // ok, since it's an old-style comversion -} \ No newline at end of file diff --git a/tests/neg/indentLeft.scala b/tests/neg/indentLeft.scala index c4a260583de2..7e1cf8041bc7 100644 --- a/tests/neg/indentLeft.scala +++ b/tests/neg/indentLeft.scala @@ -1,10 +1,11 @@ //> using options -Xfatal-warnings +// nopos-error: No warnings can be incurred under -Werror. object Test { if (true) { println("hi") - println("!") // error: too far to the left + println("!") // warn: too far to the left } // error: too far to the left \ No newline at end of file diff --git a/tests/neg/indentRight.scala b/tests/neg/indentRight.scala index 8eb9deb23389..6c43651d67e6 100644 --- a/tests/neg/indentRight.scala +++ b/tests/neg/indentRight.scala @@ -1,19 +1,19 @@ //> using options -no-indent -Xfatal-warnings trait A - case class B() extends A // error: Line is indented too far to the right - case object C extends A // error: Line is indented too far to the right + case class B() extends A // warn: Line is indented too far to the right + case object C extends A // warn: Line is indented too far to the right object Test { if (true) println("ho") - println("hu") // error: Line is indented too far to the right + println("hu") // warn: Line is indented too far to the right if (true) { println("ho") } - println("hu") // error: Line is indented too far to the right + println("hu") // warn: Line is indented too far to the right while (true) () @@ -24,8 +24,8 @@ object Test { } trait A - case class B() extends A // error: Line is indented too far to the right - case object C extends A // error: Line is indented too far to the right + case class B() extends A // warn: Line is indented too far to the right + case object C extends A // warn: Line is indented too far to the right if (true) // OK println("hi") @@ -33,4 +33,4 @@ object Test { println("!") // error: expected a toplevel definition } - +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/infix.check b/tests/neg/infix.check new file mode 100644 index 000000000000..7c7c87005291 --- /dev/null +++ b/tests/neg/infix.check @@ -0,0 +1,30 @@ +-- Error: tests/neg/infix.scala:26:4 ----------------------------------------------------------------------------------- +26 | c mop 2 // error: should not be used as infix operator + | ^^^ + | Alphanumeric method mop is not declared infix; it should not be used as infix operator. + | Instead, use method syntax .mop(...) or backticked identifier `mop`. + | The latter can be rewritten automatically under -rewrite -source future-migration. +-- Error: tests/neg/infix.scala:27:4 ----------------------------------------------------------------------------------- +27 | c meth 2 // error: should not be used as infix operator + | ^^^^ + | Alphanumeric method meth is not declared infix; it should not be used as infix operator. + | Instead, use method syntax .meth(...) or backticked identifier `meth`. + | The latter can be rewritten automatically under -rewrite -source future-migration. +-- Error: tests/neg/infix.scala:45:14 ---------------------------------------------------------------------------------- +45 | val x1: Int Map String = ??? // error + | ^^^ + | Alphanumeric type Map is not declared infix; it should not be used as infix operator. + | Instead, use prefix syntax Map[...] or backticked identifier `Map`. + | The latter can be rewritten automatically under -rewrite -source future-migration. +-- Error: tests/neg/infix.scala:47:14 ---------------------------------------------------------------------------------- +47 | val x3: Int AndC String = ??? // error + | ^^^^ + | Alphanumeric type AndC is not declared infix; it should not be used as infix operator. + | Instead, use prefix syntax AndC[...] or backticked identifier `AndC`. + | The latter can be rewritten automatically under -rewrite -source future-migration. +-- Error: tests/neg/infix.scala:61:8 ----------------------------------------------------------------------------------- +61 | val _ Pair _ = p // error + | ^^^^ + | Alphanumeric extractor Pair is not declared infix; it should not be used as infix operator. + | Instead, use prefix syntax Pair(...) or backticked identifier `Pair`. + | The latter can be rewritten automatically under -rewrite -source future-migration. diff --git a/tests/neg/infix.scala b/tests/neg/infix.scala index aefdd5c40d47..dda638c829f9 100644 --- a/tests/neg/infix.scala +++ b/tests/neg/infix.scala @@ -1,4 +1,4 @@ -//> using options -source future -deprecation -Xfatal-warnings +//> using options -source future -deprecation // Compile with -strict -Xfatal-warnings -deprecation class C: @@ -67,4 +67,4 @@ def test() = { val _ Q _ = q // OK -} +} \ No newline at end of file diff --git a/tests/neg/main-functions-nameclash.scala b/tests/neg/main-functions-nameclash.scala deleted file mode 100644 index 1f9352e1592d..000000000000 --- a/tests/neg/main-functions-nameclash.scala +++ /dev/null @@ -1,5 +0,0 @@ -//> using options -Xfatal-warnings - -object foo { - @main def foo(x: Int) = () // error: class foo and object foo produce classes that overwrite one another -} diff --git a/tests/neg/manifest-summoning-b.scala b/tests/neg/manifest-summoning-b.scala deleted file mode 100644 index 6d1b8baff007..000000000000 --- a/tests/neg/manifest-summoning-b.scala +++ /dev/null @@ -1,4 +0,0 @@ -//> using options -Xfatal-warnings -deprecation - -val foo = manifest[List[? <: Int]] // error -val bar = optManifest[Array[? <: String]] // error diff --git a/tests/neg/matchable.scala b/tests/neg/matchable.scala deleted file mode 100644 index aaf8234f6d1e..000000000000 --- a/tests/neg/matchable.scala +++ /dev/null @@ -1,29 +0,0 @@ -//> using options -Xfatal-warnings -source future - -def foo[T](x: T): Matchable = - println(x.getClass()) // ok - println(x.isInstanceOf[Int]) // ok - x match - case x: Int => // error: should not be scrutinized - println("int") - x - case x: String => // error: should not be scrutinized - println("string") - x - List(x) match - case (x: Int) :: Nil => // error: should not be scrutinized - println("int") - x - case List(x: String) => // error: should not be scrutinized - println("string") - x - case List(y :: Nil) => // error: should not be scrutinized - y :: Nil - case _ => - x // error: should not be scrutinized - -@main def Test = - val x: Matchable = foo(1) - val y: Matchable = foo("hello") - assert(x != y) - diff --git a/tests/neg/missing-targetName.scala b/tests/neg/missing-targetName.scala index b5403ac7cb19..8c799c4a19dd 100644 --- a/tests/neg/missing-targetName.scala +++ b/tests/neg/missing-targetName.scala @@ -5,7 +5,8 @@ import scala.annotation.targetName class & { // error @targetName("op") def *(x: Int): Int = ??? // OK - def / (x: Int): Int // error - val frozen_& : Int = ??? // error - object some_??? // error + def / (x: Int): Int // warn + val frozen_& : Int = ??? // warn + object some_??? // warn } +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/old-syntax.scala b/tests/neg/old-syntax.scala deleted file mode 100644 index 124781d13db2..000000000000 --- a/tests/neg/old-syntax.scala +++ /dev/null @@ -1,5 +0,0 @@ -//> using options -Xfatal-warnings -deprecation - -val f = (x: Int) ⇒ x + 1 // error - -val list = for (n ← List(42)) yield n + 1 // error diff --git a/tests/neg/ovlazy.scala b/tests/neg/ovlazy.scala deleted file mode 100644 index 69078fbd2745..000000000000 --- a/tests/neg/ovlazy.scala +++ /dev/null @@ -1,8 +0,0 @@ -//> using options -source 3.0-migration -Xfatal-warnings - -class A { - val x: Int = 1 -} -class B extends A { - override lazy val x: Int = 2 // error -} diff --git a/tests/neg/private-this-3.4.scala b/tests/neg/private-this-3.4.scala deleted file mode 100644 index b198e954e41b..000000000000 --- a/tests/neg/private-this-3.4.scala +++ /dev/null @@ -1,7 +0,0 @@ -//> using options -Werror - -import scala.language.`3.4` - -class Foo: - private[this] def foo: Int = ??? // error: migration warning - protected[this] def bar: Int = ??? // error: migration warning diff --git a/tests/neg/private-this-future-migration.scala b/tests/neg/private-this-future-migration.scala deleted file mode 100644 index 7e3da2be72e2..000000000000 --- a/tests/neg/private-this-future-migration.scala +++ /dev/null @@ -1,7 +0,0 @@ -//> using options -Werror - -import scala.language.`future-migration` - -class Foo: - private[this] def foo: Int = ??? // error: migration warning - protected[this] def bar: Int = ??? // error: migration warning diff --git a/tests/neg/pureStatement.scala b/tests/neg/pureStatement.scala index 4d2ea1d49b08..72d39ce2ecf6 100644 --- a/tests/neg/pureStatement.scala +++ b/tests/neg/pureStatement.scala @@ -3,16 +3,16 @@ class IOCapability object Test { - "" // error: pure expression does nothing in statement position + "" // warn: pure expression does nothing in statement position locally { - "" // error: pure expression does nothing in statement position + "" // warn: pure expression does nothing in statement position println("") - 42 // error: pure expression does nothing in statement position + 42 // warn: pure expression does nothing in statement position - ((x: Int) => println("hi")) // error: pure expression does nothing in statement position + ((x: Int) => println("hi")) // warn: pure expression does nothing in statement position () } @@ -24,7 +24,7 @@ object Test { implicit val cap: IOCapability = new IOCapability - 2 // error: pure expression does nothing in statement position + 2 // warn: pure expression does nothing in statement position doSideEffects(1) // error: pure expression does nothing in statement position @@ -32,3 +32,4 @@ object Test { broken.foo // no extra error, and no pure expression warning broken.foo() // same } +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/quote-simple-hole.scala b/tests/neg/quote-simple-hole.scala deleted file mode 100644 index 64e2bcad4862..000000000000 --- a/tests/neg/quote-simple-hole.scala +++ /dev/null @@ -1,17 +0,0 @@ -//> using options -Xfatal-warnings - -import scala.quoted.Quotes - -def test(using Quotes) = { - val x = '{0} - val y = '{ // error: Canceled splice directly inside a quote. '{ ${ XYZ } } is equivalent to XYZ. - $x - } - val z = '{ - val a = ${ // error: Canceled quote directly inside a splice. ${ '{ XYZ } } is equivalent to XYZ. - '{ - $y - } - } - } -} diff --git a/tests/neg/refinements-this.scala b/tests/neg/refinements-this.scala deleted file mode 100644 index f8d41bd85360..000000000000 --- a/tests/neg/refinements-this.scala +++ /dev/null @@ -1,5 +0,0 @@ -//> using options -Xfatal-warnings - -class Outer: - type X = { type O = Outer.this.type } // ok - type Y = { type O = this.type } // error diff --git a/tests/neg/refutable-pattern-binding-messages.check b/tests/neg/refutable-pattern-binding-messages.check index 5a9d85fd4447..4a8f895264a3 100644 --- a/tests/neg/refutable-pattern-binding-messages.check +++ b/tests/neg/refutable-pattern-binding-messages.check @@ -22,24 +22,24 @@ | If the narrowing is intentional, this can be communicated by adding the `case` keyword before the full pattern, | which will result in a filtering for expression (using `withFilter`). | This patch can be rewritten automatically under -rewrite -source 3.2-migration. --- Error: tests/neg/refutable-pattern-binding-messages.scala:5:14 ------------------------------------------------------ -5 | val Positive(p) = 5 // error: refutable extractor +-- Warning: tests/neg/refutable-pattern-binding-messages.scala:5:14 ---------------------------------------------------- +5 | val Positive(p) = 5 // warn: refutable extractor | ^^^^^^^^^^^^^^^ | pattern binding uses refutable extractor `Test.Positive` | | If this usage is intentional, this can be communicated by adding `: @unchecked` after the expression, | which may result in a MatchError at runtime. | This patch can be rewritten automatically under -rewrite -source 3.2-migration. --- Error: tests/neg/refutable-pattern-binding-messages.scala:10:20 ----------------------------------------------------- -10 | val i :: is = List(1, 2, 3) // error: pattern type more specialized +-- Warning: tests/neg/refutable-pattern-binding-messages.scala:10:20 --------------------------------------------------- +10 | val i :: is = List(1, 2, 3) // warn: pattern type more specialized | ^^^^^^^^^^^^^ | pattern's type ::[Int] is more specialized than the right hand side expression's type List[Int] | | If the narrowing is intentional, this can be communicated by adding `: @unchecked` after the expression, | which may result in a MatchError at runtime. | This patch can be rewritten automatically under -rewrite -source 3.2-migration. --- Error: tests/neg/refutable-pattern-binding-messages.scala:16:10 ----------------------------------------------------- -16 | val 1 = 2 // error: pattern type does not match +-- Warning: tests/neg/refutable-pattern-binding-messages.scala:16:10 --------------------------------------------------- +16 | val 1 = 2 // warn: pattern type does not match | ^ | pattern's type (1 : Int) does not match the right hand side expression's type (2 : Int) | diff --git a/tests/neg/refutable-pattern-binding-messages.scala b/tests/neg/refutable-pattern-binding-messages.scala index c6ae043652c2..e71371785d15 100644 --- a/tests/neg/refutable-pattern-binding-messages.scala +++ b/tests/neg/refutable-pattern-binding-messages.scala @@ -1,17 +1,17 @@ -//> using options -Werror + object Test { // refutable extractor object Positive { def unapply(i: Int): Option[Int] = Some(i).filter(_ > 0) } - val Positive(p) = 5 // error: refutable extractor + val Positive(p) = 5 // warn: refutable extractor for Positive(i) <- List(1, 2, 3) do () // error: refutable extractor // more specialized val xs: List[AnyRef] = ??? - val i :: is = List(1, 2, 3) // error: pattern type more specialized + val i :: is = List(1, 2, 3) // warn: pattern type more specialized for ((x: String) <- xs) do () // error: pattern type more specialized // does not match val ys: List[Option[?]] = ??? for none @ None <- ys do () // error: pattern type does not match - val 1 = 2 // error: pattern type does not match + val 1 = 2 // warn: pattern type does not match } diff --git a/tests/neg/rewrite-messages.scala b/tests/neg/rewrite-messages.scala deleted file mode 100644 index 7509682c4baa..000000000000 --- a/tests/neg/rewrite-messages.scala +++ /dev/null @@ -1,8 +0,0 @@ -//> using options -source:future-migration -deprecation -Werror - -import scala.util._ // error - -object Test { - extension (x: Int) def foo(y: Int) = x + y - 2 foo 4 // error -} diff --git a/tests/neg/strict-pattern-bindings-3.2.scala b/tests/neg/strict-pattern-bindings-3.2.scala deleted file mode 100644 index d7db6cd165e4..000000000000 --- a/tests/neg/strict-pattern-bindings-3.2.scala +++ /dev/null @@ -1,37 +0,0 @@ -//> using options -Xfatal-warnings -// These tests should fail under -Xfatal-warnings with source version source version 3.2 or later -import language.`3.2` - -object Test: - // from filtering-fors.scala - val xs: List[AnyRef] = ??? - - for ((x: String) <- xs) do () // error - for (y@ (x: String) <- xs) do () // error - for ((x, y) <- xs) do () // error - - for ((x: String) <- xs if x.isEmpty) do () // error - for ((x: String) <- xs; y = x) do () // error - for ((x: String) <- xs; (y, z) <- xs) do () // error // error - for (case (x: String) <- xs; (y, z) <- xs) do () // error - for ((x: String) <- xs; case (y, z) <- xs) do () // error - - val pairs: List[AnyRef] = List((1, 2), "hello", (3, 4)) - for ((x, y) <- pairs) yield (y, x) // error - - // from unchecked-patterns.scala - val y :: ys = List(1, 2, 3) // error - val (1, c) = (1, 2) // error - val 1 *: cs = 1 *: Tuple() // error - - val (_: Int | _: AnyRef) = ??? : AnyRef // error - - val 1 = 2 // error - - object Positive { def unapply(i: Int): Option[Int] = Some(i).filter(_ > 0) } - object Always1 { def unapply(i: Int): Some[Int] = Some(i) } - object Pair { def unapply(t: (Int, Int)): t.type = t } - object Triple { def unapply(t: (Int, Int, Int)): (Int, Int, Int) = t } - - val Positive(p) = 5 // error - val Some(s1) = Option(1) // error diff --git a/tests/neg/structural-2.scala b/tests/neg/structural-2.scala index 3613d6073e34..85fac55c08a5 100644 --- a/tests/neg/structural-2.scala +++ b/tests/neg/structural-2.scala @@ -69,7 +69,8 @@ object Test { package p6 { class Refinements { - val y: { val x: T; type T } // error: deprecated warning: illegal forward reference in refinement; now illegal + val y: { val x: T; type T } // warn: deprecated warning: illegal forward reference in refinement; now illegal } } +// nopos-error: No warnings can be incurred under -Werror. diff --git a/tests/neg/symbolic-packages.scala b/tests/neg/symbolic-packages.scala deleted file mode 100644 index 12719d027b4c..000000000000 --- a/tests/neg/symbolic-packages.scala +++ /dev/null @@ -1,13 +0,0 @@ -//> using options -Xfatal-warnings - -package `with spaces` { // error - class Foo -} - -package +.* { // error // error - class Bar -} - -package object `mixed_*` { // error - class Baz -} diff --git a/tests/neg/unchecked-patterns.scala b/tests/neg/unchecked-patterns.scala index db304a2f1875..7e6c4de76a50 100644 --- a/tests/neg/unchecked-patterns.scala +++ b/tests/neg/unchecked-patterns.scala @@ -5,23 +5,24 @@ object Test { val (y1: Some[Int]) = Some(1): Option[Int] @unchecked // OK val y2: Some[Int] @unchecked = Some(1): Option[Int] // error - val x :: xs = List(1, 2, 3) // error - val (1, c) = (1, 2) // error - val 1 *: cs = 1 *: Tuple() // error + val x :: xs = List(1, 2, 3) // warn + val (1, c) = (1, 2) // warn + val 1 *: cs = 1 *: Tuple() // warn - val (_: Int | _: AnyRef) = ??? : AnyRef // error + val (_: Int | _: AnyRef) = ??? : AnyRef // warn - val 1 = 2 // error + val 1 = 2 // warn object Positive { def unapply(i: Int): Option[Int] = Some(i).filter(_ > 0) } object Always1 { def unapply(i: Int): Some[Int] = Some(i) } object Pair { def unapply(t: (Int, Int)): t.type = t } object Triple { def unapply(t: (Int, Int, Int)): (Int, Int, Int) = t } - val Positive(p) = 5 // error - val Some(s1) = Option(1) // error + val Positive(p) = 5 // warn + val Some(s1) = Option(1) // warn val Some(s2) = Some(1) // OK val Always1(p1) = 5 // OK val Pair(t1, t2) = (5, 5) // OK val Triple(u1, u2, u3) = (5, 5, 5) // OK -} \ No newline at end of file +} +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/warn-value-discard.check b/tests/neg/warn-value-discard.check deleted file mode 100644 index ba43c743709f..000000000000 --- a/tests/neg/warn-value-discard.check +++ /dev/null @@ -1,20 +0,0 @@ --- [E175] Potential Issue Error: tests/neg/warn-value-discard.scala:27:36 ---------------------------------------------- -27 | mutable.Set.empty[String].remove("") // error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | discarded non-Unit value of type Boolean --- [E175] Potential Issue Error: tests/neg/warn-value-discard.scala:39:41 ---------------------------------------------- -39 | mutable.Set.empty[String].subtractOne("") // error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | discarded non-Unit value of type scala.collection.mutable.Set[String] --- [E175] Potential Issue Error: tests/neg/warn-value-discard.scala:59:4 ----------------------------------------------- -59 | mutable.Set.empty[String] += "" // error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | discarded non-Unit value of type scala.collection.mutable.Set[String] --- [E175] Potential Issue Error: tests/neg/warn-value-discard.scala:15:35 ---------------------------------------------- -15 | firstThing().map(_ => secondThing()) // error - | ^^^^^^^^^^^^^ - | discarded non-Unit value of type Either[Failed, Unit] --- [E175] Potential Issue Error: tests/neg/warn-value-discard.scala:18:35 ---------------------------------------------- -18 | firstThing().map(_ => secondThing()) // error - | ^^^^^^^^^^^^^ - | discarded non-Unit value of type Either[Failed, Unit] diff --git a/tests/neg/with-type-operator-future-migration.scala b/tests/neg/with-type-operator-future-migration.scala deleted file mode 100644 index 3ed2e3a8f067..000000000000 --- a/tests/neg/with-type-operator-future-migration.scala +++ /dev/null @@ -1,5 +0,0 @@ -//> using options -Werror - -import scala.language.`future-migration` - -def foo: Int with String = ??? // error diff --git a/tests/patmat/i14407.dupe.check b/tests/patmat/i14407.dupe.check index b0605bcd95e5..e6f742314d98 100644 --- a/tests/patmat/i14407.dupe.check +++ b/tests/patmat/i14407.dupe.check @@ -1 +1,2 @@ 6: Match case Unreachable +0: No Kind diff --git a/tests/patmat/i18118.check b/tests/patmat/i18118.check index 8861eb273fb9..f7ad777f5e8c 100644 --- a/tests/patmat/i18118.check +++ b/tests/patmat/i18118.check @@ -2,3 +2,4 @@ 21: Pattern Match 32: Pattern Match 41: Pattern Match +0: No Kind diff --git a/tests/warn/14034b.scala b/tests/warn/14034b.scala new file mode 100644 index 000000000000..fdef353f7aca --- /dev/null +++ b/tests/warn/14034b.scala @@ -0,0 +1,15 @@ +//> using options -deprecation + +@deprecated trait Exp +@deprecated val exp = 1 + +def test1 = exp // warn +def test2(a: Exp) = () // warn + +type Foo0 = Exp // warn +type Foo = Option[Exp] // warn +type Bar = Option[exp.type] // warn +type Baz = Exp | Int // warn +type Quux = [X] =>> X match + case Exp => Int // warn +type Quuz[A <: Exp] = Int // warn \ No newline at end of file diff --git a/tests/neg/15981.check b/tests/warn/15981.check similarity index 68% rename from tests/neg/15981.check rename to tests/warn/15981.check index 10745839c566..6cc57d86385f 100644 --- a/tests/neg/15981.check +++ b/tests/warn/15981.check @@ -1,5 +1,5 @@ --- [E092] Pattern Match Error: tests/neg/15981.scala:4:45 -------------------------------------------------------------- -4 | override def equals(any: Any): Boolean = any.isInstanceOf[PosInt] // error +-- [E092] Pattern Match Unchecked Warning: tests/warn/15981.scala:4:45 ------------------------------------------------- +4 | override def equals(any: Any): Boolean = any.isInstanceOf[PosInt] // warn | ^^^ | the type test for PosInt cannot be checked at runtime because it's a local class | diff --git a/tests/neg/15981.scala b/tests/warn/15981.scala similarity index 76% rename from tests/neg/15981.scala rename to tests/warn/15981.scala index 5aba3555c010..a52da28c8462 100644 --- a/tests/neg/15981.scala +++ b/tests/warn/15981.scala @@ -1,6 +1,6 @@ -//> using options -Werror + val _ = locally{ sealed abstract class PosInt(val value: Int) { - override def equals(any: Any): Boolean = any.isInstanceOf[PosInt] // error + override def equals(any: Any): Boolean = any.isInstanceOf[PosInt] // warn } } diff --git a/tests/neg/17284.check b/tests/warn/17284.check similarity index 86% rename from tests/neg/17284.check rename to tests/warn/17284.check index fa248c598311..47df2d21e3a7 100644 --- a/tests/neg/17284.check +++ b/tests/warn/17284.check @@ -1,5 +1,5 @@ --- [E187] Potential Issue Error: tests/neg/17284.scala:4:6 ------------------------------------------------------------- -4 | 451.synchronized {} // error +-- [E187] Potential Issue Warning: tests/warn/17284.scala:4:6 ---------------------------------------------------------- +4 | 451.synchronized {} // warn | ^^^^^^^^^^^^^^^^ | Suspicious synchronized call on boxed class |--------------------------------------------------------------------------------------------------------------------- @@ -8,8 +8,8 @@ | You called the synchronized method on a boxed primitive. This might not be what | you intended. --------------------------------------------------------------------------------------------------------------------- --- [E187] Potential Issue Error: tests/neg/17284.scala:8:4 ------------------------------------------------------------- -8 | x.synchronized {} // error +-- [E187] Potential Issue Warning: tests/warn/17284.scala:8:4 ---------------------------------------------------------- +8 | x.synchronized {} // warn | ^^^^^^^^^^^^^^ | Suspicious synchronized call on boxed class |--------------------------------------------------------------------------------------------------------------------- @@ -18,8 +18,8 @@ | You called the synchronized method on a boxed primitive. This might not be what | you intended. --------------------------------------------------------------------------------------------------------------------- --- [E187] Potential Issue Error: tests/neg/17284.scala:11:7 ------------------------------------------------------------ -11 | true.synchronized {} // error +-- [E187] Potential Issue Warning: tests/warn/17284.scala:11:7 --------------------------------------------------------- +11 | true.synchronized {} // warn | ^^^^^^^^^^^^^^^^^ | Suspicious synchronized call on boxed class |-------------------------------------------------------------------------------------------------------------------- diff --git a/tests/warn/17284.scala b/tests/warn/17284.scala new file mode 100644 index 000000000000..c30e8cb478ec --- /dev/null +++ b/tests/warn/17284.scala @@ -0,0 +1,14 @@ +//> using options -explain + +def test = + 451.synchronized {} // warn + +def test2 = + val x: Integer = 451 + x.synchronized {} // warn + +def test3 = + true.synchronized {} // warn + +def test4 = + true.hashCode() // success \ No newline at end of file diff --git a/tests/neg-deep-subtype/1828.scala b/tests/warn/1828.scala similarity index 69% rename from tests/neg-deep-subtype/1828.scala rename to tests/warn/1828.scala index ae228a83e898..2231967a53e0 100644 --- a/tests/neg-deep-subtype/1828.scala +++ b/tests/warn/1828.scala @@ -1,8 +1,8 @@ -//> using options -Xfatal-warnings + class Test { def remove[S](a: S | Int, f: Int => S):S = a match { - case a: S => a // error + case a: S => a // warn case a: Int => f(a) } diff --git a/tests/warn/18493.check b/tests/warn/18493.check new file mode 100644 index 000000000000..64f2e2aac735 --- /dev/null +++ b/tests/warn/18493.check @@ -0,0 +1,8 @@ +-- [E030] Match case Unreachable Warning: tests/warn/18493.scala:6:9 --------------------------------------------------- +6 | case "abc" => // warn + | ^^^^^ + | Unreachable case +-- [E030] Match case Unreachable Warning: tests/warn/18493.scala:12:9 -------------------------------------------------- +12 | case "abc" => // warn + | ^^^^^ + | Unreachable case diff --git a/tests/neg/18493.scala b/tests/warn/18493.scala similarity index 68% rename from tests/neg/18493.scala rename to tests/warn/18493.scala index 8dfb3bf923cc..d3ca292a346e 100644 --- a/tests/neg/18493.scala +++ b/tests/warn/18493.scala @@ -1,14 +1,14 @@ -//> using options -Werror + object PartialFunctionNoWarning { // nice warning "abc" match { case "abc" => - case "abc" => // error + case "abc" => // warn } // no warnings val pf: PartialFunction[String, Unit] = { case "abc" => - case "abc" => // error + case "abc" => // warn } } \ No newline at end of file diff --git a/tests/warn/3324b.scala b/tests/warn/3324b.scala new file mode 100644 index 000000000000..9a2011d18012 --- /dev/null +++ b/tests/warn/3324b.scala @@ -0,0 +1,11 @@ + + +class C[T] { + val x: Any = ??? + if (x.isInstanceOf[List[String]]) // warn: unchecked + if (x.isInstanceOf[T]) // warn: unchecked + x match { + case x: List[String] => // warn: unchecked + case x: T => // warn: unchecked + } +} \ No newline at end of file diff --git a/tests/warn/3324f.scala b/tests/warn/3324f.scala new file mode 100644 index 000000000000..86af918b0d5a --- /dev/null +++ b/tests/warn/3324f.scala @@ -0,0 +1,11 @@ + + +trait C[T] +class D[T] + +class Test { + def foo[T](x: C[T]) = x match { + case _: D[T] => // warn + case _: C[Int] => // warn + } +} \ No newline at end of file diff --git a/tests/neg-deep-subtype/3324g.scala b/tests/warn/3324g.scala similarity index 73% rename from tests/neg-deep-subtype/3324g.scala rename to tests/warn/3324g.scala index a5b842e4e450..23ff4b3d23f9 100644 --- a/tests/neg-deep-subtype/3324g.scala +++ b/tests/warn/3324g.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings + class Test { trait A[+T] @@ -6,7 +6,7 @@ class Test { class C[T] extends B[Any] with A[T] def foo[T](c: C[T]): Unit = c match { - case _: B[T] => // error + case _: B[T] => // warn } def bar[T](b: B[T]): Unit = b match { @@ -14,8 +14,8 @@ class Test { } def quux[T](a: A[T]): Unit = a match { - case _: B[T] => // error!! + case _: B[T] => // warn!! } quux(new C[Int]) -} +} \ No newline at end of file diff --git a/tests/neg/IsInstanceOfClassTag2.scala b/tests/warn/IsInstanceOfClassTag2.scala similarity index 80% rename from tests/neg/IsInstanceOfClassTag2.scala rename to tests/warn/IsInstanceOfClassTag2.scala index 9d32ee401092..5ca8a8c91765 100644 --- a/tests/neg/IsInstanceOfClassTag2.scala +++ b/tests/warn/IsInstanceOfClassTag2.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings + import scala.reflect.TypeTest @@ -11,7 +11,7 @@ object IsInstanceOfClassTag { } def main(args: Array[String]): Unit = { - safeCast[List[String]](List[Int](1)) match { // error + safeCast[List[String]](List[Int](1)) match { // warn case None => case Some(xs) => } @@ -22,3 +22,4 @@ object IsInstanceOfClassTag { } } } + diff --git a/tests/neg-deep-subtype/JavaSeqLiteral.scala b/tests/warn/JavaSeqLiteral.scala similarity index 82% rename from tests/neg-deep-subtype/JavaSeqLiteral.scala rename to tests/warn/JavaSeqLiteral.scala index 6003731ae657..9652a9fa502c 100644 --- a/tests/neg-deep-subtype/JavaSeqLiteral.scala +++ b/tests/warn/JavaSeqLiteral.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings + object Test1 { trait Tree[-T] @@ -10,7 +10,7 @@ object Test1 { class DummyTree extends JavaSeqLiteral[Any] def foo1(tree: Tree[Type]) = - tree.isInstanceOf[JavaSeqLiteral[Type]] // error + tree.isInstanceOf[JavaSeqLiteral[Type]] // warn foo1(new DummyTree) } @@ -28,4 +28,4 @@ object Test2 { tree.isInstanceOf[JavaSeqLiteral[Type]] foo1(new DummyTree) -} \ No newline at end of file +} diff --git a/tests/warn/avoid-warn-deprecation.scala b/tests/warn/avoid-warn-deprecation.scala new file mode 100644 index 000000000000..364added5e8a --- /dev/null +++ b/tests/warn/avoid-warn-deprecation.scala @@ -0,0 +1,11 @@ +//> using options -feature + +object A { + @deprecated("use bar instead of this one", "0.2.3") + def foo: Int = 3 +} + +object B { + A.foo +} +// nopos-warn there was 1 deprecation warning; re-run with -deprecation for details \ No newline at end of file diff --git a/tests/neg-deep-subtype/conditionalWarnings.scala b/tests/warn/conditionalWarnings.scala similarity index 75% rename from tests/neg-deep-subtype/conditionalWarnings.scala rename to tests/warn/conditionalWarnings.scala index c4757cbb7546..5ab63c263abf 100644 --- a/tests/neg-deep-subtype/conditionalWarnings.scala +++ b/tests/warn/conditionalWarnings.scala @@ -1,15 +1,15 @@ -//> using options -deprecation -Xfatal-warnings +//> using options -deprecation object Test { @deprecated def foo = ??? given Conversion[String, Int] = _.length - foo // error + foo // warn val x: Int = "abc" // OK, since -feature warnings are not enabled. // The program compiles with final line // there was 1 feature warning; re-run with -feature for details - // nopos-error -} + // nopos-warn +} \ No newline at end of file diff --git a/tests/neg/convertible.scala b/tests/warn/convertible.scala similarity index 60% rename from tests/neg/convertible.scala rename to tests/warn/convertible.scala index e72de452f41d..c98006ecdc9b 100644 --- a/tests/neg/convertible.scala +++ b/tests/warn/convertible.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings -feature +//> using options -feature import language.experimental.into @@ -11,9 +11,9 @@ object Test: def f(x: Text, y: => Text, zs: Text*) = println(s"${x.str} ${y.str} ${zs.map(_.str).mkString(" ")}") - f("abc", "def") // error // error - f("abc", "def", "xyz", "uvw") // error // error // error // error - f("abc", "def", "xyz", Text("uvw")) // error // error // error + f("abc", "def") // warn // warn + f("abc", "def", "xyz", "uvw") // warn // warn // warn // warn + f("abc", "def", "xyz", Text("uvw")) // warn // warn // warn def g(x: into Text) = println(x.str) @@ -27,5 +27,4 @@ object Test: def h(x: into Text) = val y = h1(x) - y("abc") // error, inference through type variable does not propagate - + y("abc") // warn, inference through type variable does not propagate \ No newline at end of file diff --git a/tests/neg/deprecated-override.scala b/tests/warn/deprecated-override.scala similarity index 52% rename from tests/neg/deprecated-override.scala rename to tests/warn/deprecated-override.scala index b532416c7126..2d0b0ceb4aea 100644 --- a/tests/neg/deprecated-override.scala +++ b/tests/warn/deprecated-override.scala @@ -1,4 +1,4 @@ -//> using options -source future -deprecation -Xfatal-warnings +//> using options -source future -deprecation trait A: def f: Int @@ -7,10 +7,9 @@ class B extends A: @deprecatedOverriding def f = 1 class C extends B: - override def f = 2 // error + override def f = 2 // warn trait D extends A: override def f = 3 -object E extends B, D // error - +object E extends B, D // warn \ No newline at end of file diff --git a/tests/neg/feature-shadowing.scala b/tests/warn/feature-shadowing.scala similarity index 77% rename from tests/neg/feature-shadowing.scala rename to tests/warn/feature-shadowing.scala index 16286d5eea87..301f24b241f7 100644 --- a/tests/neg/feature-shadowing.scala +++ b/tests/warn/feature-shadowing.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings -feature +//> using options -feature import language.implicitConversions given Conversion[Int, String] = _.toString @@ -8,7 +8,7 @@ object a: object b: import language.implicitConversions as _ - val s: String = 2 // error + val s: String = 2 // warn object c: import language.implicitConversions diff --git a/tests/neg/gadt-contradictory-pattern.scala b/tests/warn/gadt-contradictory-pattern.scala similarity index 54% rename from tests/neg/gadt-contradictory-pattern.scala rename to tests/warn/gadt-contradictory-pattern.scala index 6fbd06120a48..5d85b23653db 100644 --- a/tests/neg/gadt-contradictory-pattern.scala +++ b/tests/warn/gadt-contradictory-pattern.scala @@ -1,14 +1,14 @@ -//> using options -Xfatal-warnings -Wimplausible-patterns +//> using options -Wimplausible-patterns object Test { sealed abstract class Foo[T] case object Bar1 extends Foo[Int] case object Bar2 extends Foo[String] case object Bar3 extends Foo[AnyRef] - def fail4[T <: AnyRef](xx: (Foo[T], Foo[T])) = xx match { - case (Bar1, Bar1) => () // error // error + def fail4[T <: AnyRef](xx: (Foo[T], Foo[T])) = xx match { // warn match may not be exhaustive + case (Bar1, Bar1) => () // warn // warn case (Bar2, Bar3) => () case (Bar3, _) => () } -} +} \ No newline at end of file diff --git a/tests/neg-deep-subtype/gadt.scala b/tests/warn/gadt.scala similarity index 68% rename from tests/neg-deep-subtype/gadt.scala rename to tests/warn/gadt.scala index 661c04fef373..9d7b81220284 100644 --- a/tests/neg-deep-subtype/gadt.scala +++ b/tests/warn/gadt.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings + class Test { trait A[+T] @@ -8,8 +8,8 @@ class Test { class D extends C def quux(a: A[C]): Unit = a match { - case _: B[C] => // error!! + case _: B[C] => // warn } quux(new B[D]) -} \ No newline at end of file +} diff --git a/tests/neg-deep-subtype/html.scala b/tests/warn/html.scala similarity index 87% rename from tests/neg-deep-subtype/html.scala rename to tests/warn/html.scala index f17cfb661505..98189c1bf2cb 100644 --- a/tests/neg-deep-subtype/html.scala +++ b/tests/warn/html.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings + object HTML: type AttrArg = AppliedAttr | Seq[AppliedAttr] @@ -12,7 +12,7 @@ object HTML: attrs.filter(_ != Nil).foreach{ case s: Seq[AppliedAttr] => s.foreach(sb.append(" ").append) - case s: Seq[Int] => // error + case s: Seq[Int] => // warn case e: AppliedAttr => sb.append(" ").append(e) } diff --git a/tests/warn/i10247.scala b/tests/warn/i10247.scala new file mode 100644 index 000000000000..aa344362cac2 --- /dev/null +++ b/tests/warn/i10247.scala @@ -0,0 +1,28 @@ +//> using options -deprecation + +def usered = Color.Red // warn: value Red is deprecated + +object DeprecatedContainer { + @deprecated("no foo", "0.1") val foo = 23 +} + +enum Day { + + @deprecated("no more Mondays!", "0.1") case Monday + +} + +enum Color { + + @deprecated("no Red", "0.1") case Red + + @deprecated("no Generic", "0.1") case Generic(rgb: Int) + + def useFoo1 = DeprecatedContainer.foo // warn // check that only enum cases are avoided + def useMonday = Day.Monday // warn // check that enum cases are declared in this enum + +} + +object Color { + def useFoo2 = DeprecatedContainer.foo // warn // check that only enum cases are avoided +} \ No newline at end of file diff --git a/tests/warn/i10930.scala b/tests/warn/i10930.scala new file mode 100644 index 000000000000..5d88235d0951 --- /dev/null +++ b/tests/warn/i10930.scala @@ -0,0 +1,15 @@ + + +import language.future +@main def Test = + type LeafElem[X] = X match + case String => Char + case Array[t] => LeafElem[t] + case Iterable[t] => LeafElem[t] + case AnyVal => X + + def leafElem[X](x: X): LeafElem[X] = x match + case x: String => x.charAt(0) // warn + case x: Array[t] => leafElem(x(1)) // warn + case x: Iterable[t] => leafElem(x.head) // warn + case x: AnyVal => x // warn \ No newline at end of file diff --git a/tests/warn/i10994.scala b/tests/warn/i10994.scala new file mode 100644 index 000000000000..74fe3bba3778 --- /dev/null +++ b/tests/warn/i10994.scala @@ -0,0 +1,5 @@ + + +def foo = true match + case (b: Boolean): Boolean => () // warn + diff --git a/tests/warn/i11022.check b/tests/warn/i11022.check new file mode 100644 index 000000000000..4257bb64652c --- /dev/null +++ b/tests/warn/i11022.check @@ -0,0 +1,20 @@ +-- Deprecation Warning: tests/warn/i11022.scala:10:7 ------------------------------------------------------------------- +10 |val a: CaseClass = CaseClass(42) // warn: deprecated type // warn: deprecated apply method + | ^^^^^^^^^ + | class CaseClass is deprecated: no CaseClass +-- Deprecation Warning: tests/warn/i11022.scala:10:19 ------------------------------------------------------------------ +10 |val a: CaseClass = CaseClass(42) // warn: deprecated type // warn: deprecated apply method + | ^^^^^^^^^ + | class CaseClass is deprecated: no CaseClass +-- Deprecation Warning: tests/warn/i11022.scala:11:7 ------------------------------------------------------------------- +11 |val b: CaseClass = new CaseClass(42) // warn: deprecated type // warn: deprecated class + | ^^^^^^^^^ + | class CaseClass is deprecated: no CaseClass +-- Deprecation Warning: tests/warn/i11022.scala:11:23 ------------------------------------------------------------------ +11 |val b: CaseClass = new CaseClass(42) // warn: deprecated type // warn: deprecated class + | ^^^^^^^^^ + | class CaseClass is deprecated: no CaseClass +-- Deprecation Warning: tests/warn/i11022.scala:12:14 ------------------------------------------------------------------ +12 |val c: Unit = CaseClass(42).magic() // warn: deprecated apply method + | ^^^^^^^^^ + | class CaseClass is deprecated: no CaseClass diff --git a/tests/warn/i11022.scala b/tests/warn/i11022.scala new file mode 100644 index 000000000000..8e2de9d8f519 --- /dev/null +++ b/tests/warn/i11022.scala @@ -0,0 +1,13 @@ +//> using options -deprecation + +@deprecated("no CaseClass") +case class CaseClass(rgb: Int): + def magic(): Unit = () + +object CaseClass: + def notDeprecated(): Unit = () + +val a: CaseClass = CaseClass(42) // warn: deprecated type // warn: deprecated apply method +val b: CaseClass = new CaseClass(42) // warn: deprecated type // warn: deprecated class +val c: Unit = CaseClass(42).magic() // warn: deprecated apply method +val d: Unit = CaseClass.notDeprecated() // compiles \ No newline at end of file diff --git a/tests/neg/i11097.scala b/tests/warn/i11097.scala similarity index 89% rename from tests/neg/i11097.scala rename to tests/warn/i11097.scala index 149fe89249c8..51c02a627a15 100644 --- a/tests/neg/i11097.scala +++ b/tests/warn/i11097.scala @@ -1,12 +1,12 @@ -//> using options -Xfatal-warnings + @main def test: Unit = { class C { type T1; type T2 } def pmatch(s: C): s.T2 = s match { - case p: (C { type T1 = Int; type T2 >: T1 } & s.type) => // error + case p: (C { type T1 = Int; type T2 >: T1 } & s.type) => // warn (3: p.T1): p.T2 - case p: (C { type T1 = String; type T2 >: T1 } & s.type) => // error + case p: (C { type T1 = String; type T2 >: T1 } & s.type) => // warn ("this branch should be matched": p.T1): p.T2 } diff --git a/tests/warn/i11333.check b/tests/warn/i11333.check new file mode 100644 index 000000000000..df22502cc649 --- /dev/null +++ b/tests/warn/i11333.check @@ -0,0 +1,30 @@ +-- [E167] Lossy Conversion Warning: tests/warn/i11333.scala:4:19 ------------------------------------------------------- +4 | val f1: Float = 123456789 // warn + | ^^^^^^^^^ + | Widening conversion from Int to Float loses precision. + | Write `.toFloat` instead. +-- [E167] Lossy Conversion Warning: tests/warn/i11333.scala:5:19 ------------------------------------------------------- +5 | val d1: Double = 1234567890123456789L // warn + | ^^^^^^^^^^^^^^^^^^^^ + | Widening conversion from Long to Double loses precision. + | Write `.toDouble` instead. +-- [E167] Lossy Conversion Warning: tests/warn/i11333.scala:6:19 ------------------------------------------------------- +6 | val f2: Float = 123456789L // warn + | ^^^^^^^^^^ + | Widening conversion from Long to Float loses precision. + | Write `.toFloat` instead. +-- [E167] Lossy Conversion Warning: tests/warn/i11333.scala:12:21 ------------------------------------------------------ +12 | val f1_b: Float = i1 // warn + | ^^ + | Widening conversion from Int to Float loses precision. + | Write `.toFloat` instead. +-- [E167] Lossy Conversion Warning: tests/warn/i11333.scala:13:21 ------------------------------------------------------ +13 | val d1_b: Double = l1 // warn + | ^^ + | Widening conversion from Long to Double loses precision. + | Write `.toDouble` instead. +-- [E167] Lossy Conversion Warning: tests/warn/i11333.scala:14:21 ------------------------------------------------------ +14 | val f2_b: Float = l2 // warn + | ^^ + | Widening conversion from Long to Float loses precision. + | Write `.toFloat` instead. diff --git a/tests/warn/i11333.scala b/tests/warn/i11333.scala new file mode 100644 index 000000000000..210916b30aaf --- /dev/null +++ b/tests/warn/i11333.scala @@ -0,0 +1,14 @@ + + +class C: + val f1: Float = 123456789 // warn + val d1: Double = 1234567890123456789L // warn + val f2: Float = 123456789L // warn + + inline val i1 = 123456789 + inline val l1 = 1234567890123456789L + inline val l2 = 123456789L + + val f1_b: Float = i1 // warn + val d1_b: Double = l1 // warn + val f2_b: Float = l2 // warn \ No newline at end of file diff --git a/tests/neg/i11344.scala b/tests/warn/i11344.scala similarity index 73% rename from tests/neg/i11344.scala rename to tests/warn/i11344.scala index 0602fe14a995..f8af81369162 100644 --- a/tests/neg/i11344.scala +++ b/tests/warn/i11344.scala @@ -1,8 +1,9 @@ -//> using options -Xfatal-warnings -deprecation +//> using options -deprecation trait Pet(val name: String, rest: Int): def f(suffix: String) = s"$name$suffix$rest" -class Birdie(override val name: String) extends Pet("huh", 1) // error +class Birdie(override val name: String) extends Pet("huh", 1) // warn + diff --git a/tests/warn/i11963a.scala b/tests/warn/i11963a.scala new file mode 100644 index 000000000000..b6743d92a4ac --- /dev/null +++ b/tests/warn/i11963a.scala @@ -0,0 +1,4 @@ + + +open trait Foo // warn + diff --git a/tests/warn/i11963b.scala b/tests/warn/i11963b.scala new file mode 100644 index 000000000000..5868e6979214 --- /dev/null +++ b/tests/warn/i11963b.scala @@ -0,0 +1,4 @@ + + +open abstract class Foo // warn + diff --git a/tests/warn/i11963c.scala b/tests/warn/i11963c.scala new file mode 100644 index 000000000000..245b436ee1e9 --- /dev/null +++ b/tests/warn/i11963c.scala @@ -0,0 +1,8 @@ + + +object Test { + def foo: Any = { + open class Bar // warn + new Bar + } +} diff --git a/tests/neg/i12253.check b/tests/warn/i12253.check similarity index 69% rename from tests/neg/i12253.check rename to tests/warn/i12253.check index 75a698249dee..e33a6214a438 100644 --- a/tests/neg/i12253.check +++ b/tests/warn/i12253.check @@ -1,11 +1,11 @@ --- [E092] Pattern Match Error: tests/neg/i12253.scala:13:10 ------------------------------------------------------------ -13 | case extractors.InlinedLambda(_, Select(_, name)) => Expr(name) // error // error +-- [E092] Pattern Match Unchecked Warning: tests/warn/i12253.scala:13:10 ----------------------------------------------- +13 | case extractors.InlinedLambda(_, Select(_, name)) => Expr(name) // warn // warn | ^ |the type test for extractors.q2.reflect.Term cannot be checked at runtime because it refers to an abstract type member or type parameter | | longer explanation available when compiling with `-explain` --- [E092] Pattern Match Error: tests/neg/i12253.scala:13:38 ------------------------------------------------------------ -13 | case extractors.InlinedLambda(_, Select(_, name)) => Expr(name) // error // error +-- [E092] Pattern Match Unchecked Warning: tests/warn/i12253.scala:13:38 ----------------------------------------------- +13 | case extractors.InlinedLambda(_, Select(_, name)) => Expr(name) // warn // warn | ^ |the type test for q1.reflect.Select cannot be checked at runtime because it refers to an abstract type member or type parameter | diff --git a/tests/neg/i12253.scala b/tests/warn/i12253.scala similarity index 93% rename from tests/neg/i12253.scala rename to tests/warn/i12253.scala index 540ff8ef6d5b..d632de7c43f4 100644 --- a/tests/neg/i12253.scala +++ b/tests/warn/i12253.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings + import scala.quoted.{given, *} import deriving.*, compiletime.* @@ -10,7 +10,7 @@ object MacroUtils: import quotes.reflect.* val extractors = new Extractors code.asTerm match - case extractors.InlinedLambda(_, Select(_, name)) => Expr(name) // error // error + case extractors.InlinedLambda(_, Select(_, name)) => Expr(name) // warn // warn case t => report.throwError(s"Illegal argument to extractor: ${code.show}, in tasty: $t") class Extractors(using val q2: Quotes): @@ -27,4 +27,5 @@ object MacroUtils: end Extractors end MacroUtils -// nopos-error + +// nopos-warn deprecation \ No newline at end of file diff --git a/tests/warn/i12597.scala b/tests/warn/i12597.scala new file mode 100644 index 000000000000..57546a69b173 --- /dev/null +++ b/tests/warn/i12597.scala @@ -0,0 +1,8 @@ +//> using options -deprecation + +@main def Test = + val a: IArray[Int] = IArray(2) + val b: IArray[Any] = a + val c = b.toArray // warn: deprecated + c(0) = "" + diff --git a/tests/neg/i13011.scala b/tests/warn/i13011.scala similarity index 60% rename from tests/neg/i13011.scala rename to tests/warn/i13011.scala index c0541aeb7f8e..0675ec936d0c 100644 --- a/tests/neg/i13011.scala +++ b/tests/warn/i13011.scala @@ -1,23 +1,23 @@ -//> using options -Xfatal-warnings + class i13011 { - lazy implicit val simple1: String = simple1 // error + lazy implicit val simple1: String = simple1 // warn def f: Unit = { - lazy val simple2: String = simple2 // error + lazy val simple2: String = simple2 // warn } - lazy val simple3: String = if true then this.simple3 else "a" // error + lazy val simple3: String = if true then this.simple3 else "a" // warn def firstDigitIsEven(n: Int): Boolean = if n % 10 == n then n % 2 == 0 else firstDigitIsEven(n / 10) lazy val simple4: String = if firstDigitIsEven(22) then this.simple4 else "a" // ok - lazy val simple5: String = identity(this.simple5) // error + lazy val simple5: String = identity(this.simple5) // warn - lazy val simple6: String = { // error + lazy val simple6: String = { // warn this.simple6 "aa" } lazy val simple7: Function0[Any] = () => this.simple7 // Ok -} +} \ No newline at end of file diff --git a/tests/neg/i13440.check b/tests/warn/i13440.check similarity index 62% rename from tests/neg/i13440.check rename to tests/warn/i13440.check index c820ee67833d..a27e5635fed3 100644 --- a/tests/neg/i13440.check +++ b/tests/warn/i13440.check @@ -1,12 +1,12 @@ --- Error: tests/neg/i13440.scala:5:4 ----------------------------------------------------------------------------------- -5 |def given = 42 // error +-- Migration Warning: tests/warn/i13440.scala:5:4 ---------------------------------------------------------------------- +5 |def given = 42 // warn | ^ | given is now a keyword, write `given` instead of given to keep it as an identifier --- Error: tests/neg/i13440.scala:7:13 ---------------------------------------------------------------------------------- -7 |case class C(enum: List[Int] = Nil) { // error +-- Migration Warning: tests/warn/i13440.scala:7:13 --------------------------------------------------------------------- +7 |case class C(enum: List[Int] = Nil) { // warn | ^ | enum is now a keyword, write `enum` instead of enum to keep it as an identifier --- Error: tests/neg/i13440.scala:8:11 ---------------------------------------------------------------------------------- -8 | val s = s"$enum" // error +-- Migration Warning: tests/warn/i13440.scala:8:11 --------------------------------------------------------------------- +8 | val s = s"$enum" // warn | ^ | enum is now a keyword, write `enum` instead of enum to keep it as an identifier diff --git a/tests/warn/i13440.scala b/tests/warn/i13440.scala new file mode 100644 index 000000000000..4f1337391d61 --- /dev/null +++ b/tests/warn/i13440.scala @@ -0,0 +1,9 @@ + + +import language.`3.0-migration` + +def given = 42 // warn + +case class C(enum: List[Int] = Nil) { // warn + val s = s"$enum" // warn +} \ No newline at end of file diff --git a/tests/neg/i13542.scala b/tests/warn/i13542.scala similarity index 75% rename from tests/neg/i13542.scala rename to tests/warn/i13542.scala index c0feb88b556d..f573aafadc7a 100644 --- a/tests/neg/i13542.scala +++ b/tests/warn/i13542.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings + import scala.language.implicitConversions @@ -16,12 +16,12 @@ def lazyIdentity[T](x: => T): T = x def repIdentity[T](x: T*): T = x(0) val x1 = - implicit def barToFoo(bar: Bar): Foo = bar.toFoo // error: infinite loop in function body + implicit def barToFoo(bar: Bar): Foo = bar.toFoo // warn: infinite loop in function body val foo: Foo = Bar(1) val x2 = implicit def barToFoo2(bar: Bar): Foo = - identity(bar.toFoo) // error + identity(bar.toFoo) // warn val foo: Foo = Bar(1) val x3 = @@ -31,12 +31,12 @@ val x3 = val x4 = implicit def barToFoo4(bar: Bar): Foo = - repIdentity(bar.toFoo) // error + repIdentity(bar.toFoo) // warn val foo: Foo = Bar(1) val x5 = implicit def barToFoo4(bar: Bar): Foo = - val y = bar.toFoo // error + val y = bar.toFoo // warn y val foo: Foo = Bar(1) @@ -44,9 +44,4 @@ val x6 = implicit def barToFoo4(bar: Bar): Foo = lazy val y = bar.toFoo if false then y else ??? - val foo: Foo = Bar(1) - - - - - + val foo: Foo = Bar(1) \ No newline at end of file diff --git a/tests/warn/i14705.scala b/tests/warn/i14705.scala new file mode 100644 index 000000000000..a6c56ed8b927 --- /dev/null +++ b/tests/warn/i14705.scala @@ -0,0 +1,6 @@ + + +val n = Nil +val b = n.head.isInstanceOf[String] // warn + + diff --git a/tests/neg/i14721.scala b/tests/warn/i14721.scala similarity index 72% rename from tests/neg/i14721.scala rename to tests/warn/i14721.scala index 46786f04558b..9739bab5801b 100644 --- a/tests/neg/i14721.scala +++ b/tests/warn/i14721.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings + class C: def op: Unit = println("op") @@ -6,4 +6,5 @@ class C: def test: Unit = try op catch case _: NullPointerException => - handler // error + handler // warn + diff --git a/tests/neg/i15474.scala b/tests/warn/i15474.scala similarity index 66% rename from tests/neg/i15474.scala rename to tests/warn/i15474.scala index 8edf97a1e55a..20c203fe6e27 100644 --- a/tests/neg/i15474.scala +++ b/tests/warn/i15474.scala @@ -1,10 +1,10 @@ -//> using options -Xfatal-warnings + import scala.language.implicitConversions object Test1: given c: Conversion[ String, Int ] with - def apply(from: String): Int = from.toInt // error + def apply(from: String): Int = from.toInt // warn object Test2: given c: Conversion[ String, Int ] = _.toInt // loop not detected, could be used as a fallback to avoid the warning. @@ -13,6 +13,6 @@ object Prices { opaque type Price = BigDecimal object Price{ - given Ordering[Price] = summon[Ordering[BigDecimal]] // error + given Ordering[Price] = summon[Ordering[BigDecimal]] // warn } } \ No newline at end of file diff --git a/tests/neg/i15479.scala b/tests/warn/i15479.scala similarity index 68% rename from tests/neg/i15479.scala rename to tests/warn/i15479.scala index d4f306a12368..b69296ae23e4 100644 --- a/tests/neg/i15479.scala +++ b/tests/warn/i15479.scala @@ -1,4 +1,4 @@ -//> using options -source future -deprecation -Xfatal-warnings +//> using options -source future -deprecation package deptest { @deprecated("Not used any more", since="7") @@ -8,11 +8,11 @@ package deptest { } package depuser { - import deptest.DeprecatedThing.* // error + import deptest.DeprecatedThing.* // warn object DepUser { def main(args: Array[String]): Unit = println { oldValue } } -} \ No newline at end of file +} diff --git a/tests/neg/i15503a.scala b/tests/warn/i15503a.scala similarity index 85% rename from tests/neg/i15503a.scala rename to tests/warn/i15503a.scala index b5f17a1e2f52..df8691c21a13 100644 --- a/tests/neg/i15503a.scala +++ b/tests/warn/i15503a.scala @@ -1,13 +1,13 @@ -//> using options -Xfatal-warnings -Wunused:imports +//> using options -Wunused:imports object FooUnused: - import collection.mutable.Set // error - import collection.mutable.{Map => MutMap} // error - import collection.mutable._ // error + import collection.mutable.Set // warn + import collection.mutable.{Map => MutMap} // warn + import collection.mutable._ // warn object FooWildcardUnused: - import collection.mutable._ // error + import collection.mutable._ // warn object Foo: import collection.mutable.Set // OK @@ -22,7 +22,7 @@ object FooWildcard: val bar = Set() // OK object FooNestedUnused: - import collection.mutable.Set // error + import collection.mutable.Set // warn object Nested: def hello = 1 @@ -32,11 +32,11 @@ object FooNested: def hello = Set() object FooGivenUnused: - import SomeGivenImports.given // error + import SomeGivenImports.given // warn object FooGiven: import SomeGivenImports.given // OK - import SomeGivenImports._ // error + import SomeGivenImports._ // warn val foo = summon[Int] @@ -52,7 +52,7 @@ object FooTypeName: import collection.mutable.Map // OK import collection.mutable.Seq // OK import collection.mutable.ArrayBuilder // OK - import collection.mutable.ListBuffer // error + import collection.mutable.ListBuffer // warn def checkImplicit[A](using Set[A]) = () def checkParamType[B](a: Map[B,B]): Seq[B] = ??? @@ -64,12 +64,12 @@ object FooTypeName: object InlineChecks: object InlineFoo: import collection.mutable.Set // ok - import collection.mutable.Map // error + import collection.mutable.Map // warn inline def getSet = Set(1) object InlinedBar: import collection.mutable.Set // ok - import collection.mutable.Map // error + import collection.mutable.Map // warn val a = InlineFoo.getSet object MacroChecks: @@ -80,7 +80,7 @@ object MacroChecks: object InnerMostCheck: - import collection.mutable.* // error + import collection.mutable.* // warn def check = import collection.mutable.* //OK val a = Set(1) @@ -88,7 +88,7 @@ object InnerMostCheck: object IgnoreExclusion: import collection.mutable.{Set => _} // OK import collection.mutable.{Map => _} // OK - import collection.mutable.{ListBuffer} // error + import collection.mutable.{ListBuffer} // warn def check = val a = Set(1) val b = Map(1 -> 2) @@ -106,7 +106,7 @@ package testsamepackageimport: } package p { - import p._ // error + import p._ // warn package q { class U { def f = new C @@ -120,7 +120,7 @@ package testpackageimport: val x: Int = 0 package b: - import a._ // error + import a._ // warn /* END : Check on packages*/ @@ -149,7 +149,7 @@ object GivenImportOrderAtoB: object A { implicit val x: X = new X } object B { implicit val y: Y = new Y } class C { - import A._ // error + import A._ // warn import B._ // OK def t = implicitly[X] } @@ -161,7 +161,7 @@ object GivenImportOrderBtoA: object B { implicit val y: Y = new Y } class C { import B._ // OK - import A._ // error + import A._ // warn def t = implicitly[X] } /* END : tests on given import order */ @@ -174,19 +174,19 @@ object Scala2ImplicitsGiven: import A.given // OK val b = summon[Int] object C: - import A.given // error + import A.given // warn val b = 1 object D: import A._ // OK val b = summon[Int] object E: - import A._ // error + import A._ // warn val b = 1 object F: import A.x // OK val b = summon[Int] object G: - import A.x // error + import A.x // warn val b = 1 // ------------------------------------- @@ -226,7 +226,7 @@ package testOnOverloadedMethodsImports: package b: object D extends a.C package c: - import b.D.foo // error + import b.D.foo // warn package d: import b.D.foo // OK def bar = foo((??? : a.A)) @@ -242,13 +242,13 @@ package testOnOverloadedMethodsImports: package foo.testing.rename.imports: import collection.mutable.{Set => MutSet1} // OK import collection.mutable.{Set => MutSet2} // OK - import collection.mutable.{Set => MutSet3} // error + import collection.mutable.{Set => MutSet3} // warn type A[X] = MutSet1[X] val a = MutSet2(1) //------------------------------------- package foo.testing.imports.precedence: - import scala.collection.immutable.{BitSet => _, _} // error + import scala.collection.immutable.{BitSet => _, _} // warn import scala.collection.immutable.BitSet // OK def t = BitSet.empty diff --git a/tests/neg/i15503b.scala b/tests/warn/i15503b.scala similarity index 71% rename from tests/neg/i15503b.scala rename to tests/warn/i15503b.scala index 4dc10e12606d..7ab86026ff00 100644 --- a/tests/neg/i15503b.scala +++ b/tests/warn/i15503b.scala @@ -1,17 +1,17 @@ -//> using options -Xfatal-warnings -Wunused:locals +//> using options -Wunused:locals val a = 1 // OK var cs = 3 // OK val b = // OK - var e3 = 2 // error - val e1 = 1 // error - def e2 = 2 // error + var e3 = 2 // warn + val e1 = 1 // warn + def e2 = 2 // warn 1 val c = // OK - var e1 = 1 // error not set + var e1 = 1 // warn not set def e2 = e1 // OK val e3 = e2 // OK e3 @@ -26,14 +26,14 @@ val g = // OK def d = 1 // OK def e = // OK - val e1 = 1 // error - def e2 = 2 // error - var e3 = 4 // error + val e1 = 1 // warn + def e2 = 2 // warn + var e3 = 4 // warn 1 def f = // OK val f1 = 1 // OK - var f2 = f1 // error not set + var f2 = f1 // warn not set def f3 = f2 // OK f3 @@ -50,13 +50,13 @@ class Foo { var cs = 3 // OK val b = // OK - var e3 = 2 // error - val e1 = 1 // error - def e2 = 2 // error + var e3 = 2 // warn + val e1 = 1 // warn + def e2 = 2 // warn 1 val c = // OK - var e1 = 1 // error not set + var e1 = 1 // warn not set def e2 = e1 // OK val e3 = e2 // OK e3 @@ -71,14 +71,14 @@ class Foo { def d = 1 // OK def e = // OK - val e1 = 1 // error - def e2 = 2 // error - var e3 = 4 // error + val e1 = 1 // warn + def e2 = 2 // warn + var e3 = 4 // warn 1 def f = // OK val f1 = 1 // OK - var f2 = f1 // error not set + var f2 = f1 // warn not set def f3 = f2 // OK f3 @@ -99,18 +99,18 @@ package foo.scala2.tests: trait Locals { def f0 = { - var x = 1 // error + var x = 1 // warn var y = 2 // OK y = 3 y + y } def f1 = { val a = new Outer // OK - val b = new Outer // error + val b = new Outer // warn new a.Inner } def f2 = { - var x = 100 // error not set + var x = 100 // warn not set x } } @@ -118,14 +118,14 @@ package foo.scala2.tests: object Types { def l1() = { object HiObject { def f = this } // OK - class Hi { // error + class Hi { // warn def f1: Hi = new Hi def f2(x: Hi) = x } - class DingDongDoobie // error + class DingDongDoobie // warn class Bippy // OK type Something = Bippy // OK - type OtherThing = String // error + type OtherThing = String // warn (new Bippy): Something } } @@ -141,4 +141,4 @@ package test.foo.twisted.i16682: } isInt - def f = myPackage("42") + def f = myPackage("42") \ No newline at end of file diff --git a/tests/neg/i15503c.scala b/tests/warn/i15503c.scala similarity index 69% rename from tests/neg/i15503c.scala rename to tests/warn/i15503c.scala index 040dae43a2c9..e70df10f3140 100644 --- a/tests/neg/i15503c.scala +++ b/tests/warn/i15503c.scala @@ -1,29 +1,30 @@ -//> using options -Xfatal-warnings -Wunused:privates -source:3.3 +//> using options -Wunused:privates -source:3.3 + trait C class A: self: C => // OK class B: private[A] val a = 1 // OK private[B] val b = 1 // OK - private[this] val c = 1 // error - private val d = 1 // error + private[this] val c = 1 // warn + private val d = 1 // warn private[A] val e = 1 // OK private[this] val f = e // OK private val g = f // OK private[A] var h = 1 // OK - private[this] var i = h // error not set - private var j = i // error not set + private[this] var i = h // warn not set + private var j = i // warn not set private[this] var k = 1 // OK private var l = 2 // OK - private val m = // error + private val m = // warn k = l l = k l - private def fac(x: Int): Int = // error + private def fac(x: Int): Int = // warn if x == 0 then 1 else x * fac(x - 1) val x = 1 // OK @@ -34,10 +35,10 @@ class A: package foo.test.contructors: case class A private (x:Int) // OK class B private (val x: Int) // OK - class C private (private val x: Int) // error + class C private (private val x: Int) // warn class D private (private val x: Int): // OK def y = x - class E private (private var x: Int): // error not set + class E private (private var x: Int): // warn not set def y = x class F private (private var x: Int): // OK def y = @@ -54,4 +55,4 @@ package test.foo.i16682: case _ => println("NaN") } - def f = myPackage.isInt("42") + def f = myPackage.isInt("42") \ No newline at end of file diff --git a/tests/neg/i15503d.scala b/tests/warn/i15503d.scala similarity index 60% rename from tests/neg/i15503d.scala rename to tests/warn/i15503d.scala index c43dc07c638e..9a0ba9b2f8dc 100644 --- a/tests/neg/i15503d.scala +++ b/tests/warn/i15503d.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings -Wunused:unsafe-warn-patvars +//> using options -Wunused:unsafe-warn-patvars // todo : change to :patvars sealed trait Calc @@ -8,15 +8,15 @@ case class S(pred: Const) extends Const case object Z extends Const val a = Sum(S(S(Z)),Z) match { - case Sum(a,Z) => Z // error + case Sum(a,Z) => Z // warn // case Sum(a @ _,Z) => Z // todo : this should pass in the future - case Sum(a@S(_),Z) => Z // error - case Sum(a@S(_),Z) => a // OK - case Sum(a@S(b@S(_)), Z) => a // error - case Sum(a@S(b@S(_)), Z) => a // error - case Sum(a@S(b@(S(_))), Z) => Sum(a,b) // OK + case Sum(a@S(_),Z) => Z // warn + case Sum(a@S(_),Z) => a // warn unreachable + case Sum(a@S(b@S(_)), Z) => a // warn + case Sum(a@S(b@S(_)), Z) => a // warn + case Sum(a@S(b@(S(_))), Z) => Sum(a,b) // warn unreachable case Sum(_,_) => Z // OK - case _ => Z // OK + case _ => Z // warn unreachable } // todo : This should pass in the future @@ -27,4 +27,4 @@ val a = Sum(S(S(Z)),Z) match { // todo : This should *NOT* pass in the future // val c = for { // case Some(x) <- Option(Option(1)) -// } println(s"hello world") +// } println(s"hello world") \ No newline at end of file diff --git a/tests/neg/i15503e.scala b/tests/warn/i15503e.scala similarity index 81% rename from tests/neg/i15503e.scala rename to tests/warn/i15503e.scala index f3214e7b24e6..46d73a4945cd 100644 --- a/tests/neg/i15503e.scala +++ b/tests/warn/i15503e.scala @@ -1,14 +1,14 @@ -//> using options -Xfatal-warnings -Wunused:explicits +//> using options -Wunused:explicits object Foo { /* This goes around the "trivial method" detection */ val default_val = 1 private def f1(a: Int) = a // OK - private def f2(a: Int) = default_val // error + private def f2(a: Int) = default_val // warn private def f3(a: Int)(using Int) = a // OK - private def f4(a: Int)(using Int) = default_val // error - private def f6(a: Int)(using Int) = summon[Int] // error + private def f4(a: Int)(using Int) = default_val // warn + private def f6(a: Int)(using Int) = summon[Int] // warn private def f7(a: Int)(using Int) = summon[Int] + a // OK } @@ -49,9 +49,9 @@ package foo.test.trivial: private def f6(x: Int) = X // OK private def f7(x: Int) = Y // OK private def f8(x: Int): List[C] = Nil // OK - private def f9(x: Int): List[Int] = List(1,2,3,4) // error + private def f9(x: Int): List[Int] = List(1,2,3,4) // warn private def foo:Int = 32 // OK - private def f77(x: Int) = foo // error + private def f77(x: Int) = foo // warn } object Y @@ -67,5 +67,4 @@ package foo.test.i16865: def fn(a: Int, b: Int): Int = b + 3 // OK object Ex2 extends Bar: - override def fn(a: Int, b: Int): Int = b + 3 // OK - + override def fn(a: Int, b: Int): Int = b + 3 // OK \ No newline at end of file diff --git a/tests/neg/i15503f.scala b/tests/warn/i15503f.scala similarity index 77% rename from tests/neg/i15503f.scala rename to tests/warn/i15503f.scala index 08520d149b95..ccf0b7e74065 100644 --- a/tests/neg/i15503f.scala +++ b/tests/warn/i15503f.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings -Wunused:implicits +//> using options -Wunused:implicits /* This goes around the "trivial method" detection */ val default_int = 1 @@ -10,5 +10,5 @@ object Xd { private def f4(a: Int)(using Int) = default_int // OK private def f6(a: Int)(using Int) = summon[Int] // OK private def f7(a: Int)(using Int) = summon[Int] + a // OK - private def f8(a: Int)(using foo: Int) = a // error + private def f8(a: Int)(using foo: Int) = a // warn } diff --git a/tests/neg/i15503g.scala b/tests/warn/i15503g.scala similarity index 68% rename from tests/neg/i15503g.scala rename to tests/warn/i15503g.scala index 4da98a8d43f2..fbd9f3c1352c 100644 --- a/tests/neg/i15503g.scala +++ b/tests/warn/i15503g.scala @@ -1,14 +1,14 @@ -//> using options -Xfatal-warnings -Wunused:params +//> using options -Wunused:params /* This goes around the "trivial method" detection */ object Foo { val default_int = 1 private def f1(a: Int) = a // OK - private def f2(a: Int) = default_int // error + private def f2(a: Int) = default_int // warn private def f3(a: Int)(using Int) = a // OK - private def f4(a: Int)(using Int) = default_int // error - private def f6(a: Int)(using Int) = summon[Int] // error + private def f4(a: Int)(using Int) = default_int // warn + private def f6(a: Int)(using Int) = summon[Int] // warn private def f7(a: Int)(using Int) = summon[Int] + a // OK /* --- Trivial method check --- */ private def g1(x: Int) = 1 // OK @@ -20,4 +20,4 @@ package foo.test.i17101: extension[A] (x: Test[A]) { // OK def value: A = x def causesIssue: Unit = println("oh no") - } + } \ No newline at end of file diff --git a/tests/warn/i15503h.scala b/tests/warn/i15503h.scala new file mode 100644 index 000000000000..854693981488 --- /dev/null +++ b/tests/warn/i15503h.scala @@ -0,0 +1,20 @@ +//> using options -Wunused:linted + +import collection.mutable.Set // warn + +class A { + private val a = 1 // warn + val b = 2 // OK + + private def c = 2 // warn + def d(using x:Int): Int = b // ok + def e(x: Int) = 1 // OK + def f = + val x = 1 // warn + def f = 2 // warn + 3 + + def g(x: Int): Int = x match + case x:1 => 0 // OK + case _ => 1 +} \ No newline at end of file diff --git a/tests/neg/i15503i.scala b/tests/warn/i15503i.scala similarity index 88% rename from tests/neg/i15503i.scala rename to tests/warn/i15503i.scala index d415c95a701a..329b81327288 100644 --- a/tests/neg/i15503i.scala +++ b/tests/warn/i15503i.scala @@ -1,11 +1,11 @@ -//> using options -Xfatal-warnings -Wunused:all +//> using options -Wunused:all -import collection.mutable.{Map => MutMap} // error -import collection.mutable.Set // error +import collection.mutable.{Map => MutMap} // warn +import collection.mutable.Set // warn class A { import collection.mutable.{Map => MutMap} // OK - private val a = 1 // error + private val a = 1 // warn val b = 2 // OK /* This goes around the trivial method detection */ @@ -13,7 +13,7 @@ class A { val someMap = MutMap() - private def c1 = 2 // error + private def c1 = 2 // warn private def c2 = 2 // OK def c3 = c2 @@ -23,8 +23,8 @@ class A { def e1(x: Int) = default_int // ok def e2(x: Int) = x // OK def f = - val x = 1 // error - def f = 2 // error + val x = 1 // warn + def f = 2 // warn val y = 3 // OK def g = 4 // OK y + g @@ -49,7 +49,7 @@ package foo.test.scala.annotation: def a3(@unused a: Int) = default_int //OK def b1 = - def f = 1 // error + def f = 1 // warn 1 def b2 = @@ -61,7 +61,7 @@ package foo.test.scala.annotation: 1 object Foo: - private def a = 1 // error + private def a = 1 // warn private def b = 2 // OK @unused private def c = 3 // OK @@ -81,8 +81,8 @@ package foo.test.i16678: def run = println(foo(number => number.toString, value = 5)) // OK - println(foo(number => "", value = 5)) // error - println(foo(func = number => "", value = 5)) // error + println(foo(number => "", value = 5)) // warn + println(foo(func = number => "", value = 5)) // warn println(foo(func = number => number.toString, value = 5)) // OK println(foo(func = _.toString, value = 5)) // OK @@ -93,7 +93,7 @@ package foo.test.possibleclasses: )( s: Int, val t: Int, // OK - private val z: Int // error + private val z: Int // warn ) case class AllCaseUsed( @@ -108,12 +108,12 @@ package foo.test.possibleclasses: } class AllClass( - k: Int, // error - private val y: Int // error + k: Int, // warn + private val y: Int // warn )( - s: Int, // error + s: Int, // warn val t: Int, // OK - private val z: Int // error + private val z: Int // warn ) class AllUsed( @@ -134,7 +134,7 @@ package foo.test.possibleclasses.withvar: )( s: Int, var t: Int, // OK - private var z: Int // error + private var z: Int // warn ) case class AllCaseUsed( @@ -143,27 +143,27 @@ package foo.test.possibleclasses.withvar: )( s: Int, // OK var t: Int, // OK global scope can be set somewhere else - private var z: Int // error not set + private var z: Int // warn not set ) { def a = k + y + s + t + z } class AllClass( - k: Int, // error - private var y: Int // error + k: Int, // warn + private var y: Int // warn )( - s: Int, // error + s: Int, // warn var t: Int, // OK - private var z: Int // error + private var z: Int // warn ) class AllUsed( k: Int, // OK - private var y: Int // error not set + private var y: Int // warn not set )( s: Int, // OK var t: Int, // OK global scope can be set somewhere else - private var z: Int // error not set + private var z: Int // warn not set ) { def a = k + y + s + t + z } @@ -312,4 +312,4 @@ package foo.test.i17117: val test = t1.test } - } + } \ No newline at end of file diff --git a/tests/neg/i15503j.scala b/tests/warn/i15503j.scala similarity index 90% rename from tests/neg/i15503j.scala rename to tests/warn/i15503j.scala index 66140934abc1..f5e15bb79f79 100644 --- a/tests/neg/i15503j.scala +++ b/tests/warn/i15503j.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings -Wunused:strict-no-implicit-warn +//> using options -Wunused:strict-no-implicit-warn package foo.unused.strict.test: package a: @@ -12,8 +12,8 @@ package foo.unused.strict.test: import a.* // OK import a.x // OK import a.y // OK - import a.z // error - import a.f // error + import a.z // warn + import a.f // warn package c: import a.given // OK import a.x // OK diff --git a/tests/neg/i15662.scala b/tests/warn/i15662.scala similarity index 68% rename from tests/neg/i15662.scala rename to tests/warn/i15662.scala index c84ed6e5e341..0cf0e57ed0c3 100644 --- a/tests/neg/i15662.scala +++ b/tests/warn/i15662.scala @@ -1,10 +1,10 @@ -//> using options -Xfatal-warnings + case class Composite[T](v: T) def m(composite: Composite[?]): Unit = composite match { - case Composite[Int](v) => println(v) // error: cannot be checked at runtime + case Composite[Int](v) => println(v) // warn: cannot be checked at runtime } def m2(composite: Composite[?]): Unit = diff --git a/tests/neg/i15893.scala b/tests/warn/i15893.scala similarity index 83% rename from tests/neg/i15893.scala rename to tests/warn/i15893.scala index a62ddc3ae653..8e40964b2eca 100644 --- a/tests/neg/i15893.scala +++ b/tests/warn/i15893.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings + sealed trait NatT case class Zero() extends NatT @@ -25,19 +25,19 @@ transparent inline def transparentInlineMod2(inline n: NatT): NatT = inline n m case Succ(Succ(predPredN)) => transparentInlineMod2(predPredN) def dependentlyTypedMod2[N <: NatT](n: N): Mod2[N] = n match - case Zero(): Zero => Zero() // error - case Succ(Zero()): Succ[Zero] => Succ(Zero()) // error - case Succ(Succ(predPredN)): Succ[Succ[?]] => dependentlyTypedMod2(predPredN) // error + case Zero(): Zero => Zero() // warn + case Succ(Zero()): Succ[Zero] => Succ(Zero()) // warn + case Succ(Succ(predPredN)): Succ[Succ[?]] => dependentlyTypedMod2(predPredN) // warn inline def inlineDependentlyTypedMod2[N <: NatT](inline n: N): Mod2[N] = inline n match - case Zero(): Zero => Zero() // error - case Succ(Zero()): Succ[Zero] => Succ(Zero()) // error - case Succ(Succ(predPredN)): Succ[Succ[?]] => inlineDependentlyTypedMod2(predPredN) // error + case Zero(): Zero => Zero() // warn + case Succ(Zero()): Succ[Zero] => Succ(Zero()) // warn + case Succ(Succ(predPredN)): Succ[Succ[?]] => inlineDependentlyTypedMod2(predPredN) // warn transparent inline def transparentInlineDependentlyTypedMod2[N <: NatT](inline n: N): Mod2[N] = inline n match - case Zero(): Zero => Zero() // error - case Succ(Zero()): Succ[Zero] => Succ(Zero()) // error - case Succ(Succ(predPredN)): Succ[Succ[?]] => transparentInlineDependentlyTypedMod2(predPredN) // error + case Zero(): Zero => Zero() // warn + case Succ(Zero()): Succ[Zero] => Succ(Zero()) // warn + case Succ(Succ(predPredN)): Succ[Succ[?]] => transparentInlineDependentlyTypedMod2(predPredN) // warn def foo(n: NatT): NatT = mod2(n) match case Succ(Zero()) => Zero() @@ -60,4 +60,4 @@ inline def transparentInlineFoo(inline n: NatT): NatT = inline transparentInline println(transparentInlineFoo(Succ(Succ(Succ(Zero()))))) // prints Zero(), as expected println(dependentlyTypedMod2(Succ(Succ(Succ(Zero()))))) // runtime error; unexpected println(inlineDependentlyTypedMod2(Succ(Succ(Succ(Zero()))))) // prints Succ(Zero()), as expected - println(transparentInlineDependentlyTypedMod2(Succ(Succ(Succ(Zero()))))) // prints Succ(Zero()), as expected + println(transparentInlineDependentlyTypedMod2(Succ(Succ(Succ(Zero()))))) // prints Succ(Zero()), as expected \ No newline at end of file diff --git a/tests/neg/i16639a.scala b/tests/warn/i16639a.scala similarity index 67% rename from tests/neg/i16639a.scala rename to tests/warn/i16639a.scala index 5b348d594f5b..9fe4efe57d7b 100644 --- a/tests/neg/i16639a.scala +++ b/tests/warn/i16639a.scala @@ -1,35 +1,35 @@ -//> using options -Xfatal-warnings -Wunused:all -source:3.3 -// +//> using options -Wunused:all -source:3.3 + class Bippy(a: Int, b: Int) { - private def this(c: Int) = this(c, c) // warn /Dotty:NoWarn - private def boop(x: Int) = x+a+b // error - private def bippy(x: Int): Int = bippy(x) // error TODO: could warn - final private val MILLIS1 = 2000 // error no warn, /Dotty:Warn - final private val MILLIS2: Int = 1000 // error + private def this(c: Int) = this(c, c) + private def boop(x: Int) = x+a+b // warn + private def bippy(x: Int): Int = bippy(x) // warn TODO: could warn + final private val MILLIS1 = 2000 // warn no warn, /Dotty:Warn + final private val MILLIS2: Int = 1000 // warn final private val HI_COMPANION: Int = 500 // no warn, accessed from companion def hi() = Bippy.HI_INSTANCE } object Bippy { def hi(x: Bippy) = x.HI_COMPANION private val HI_INSTANCE: Int = 500 // no warn, accessed from instance - private val HEY_INSTANCE: Int = 1000 // error warn - private lazy val BOOL: Boolean = true // error warn + private val HEY_INSTANCE: Int = 1000 // warn warn + private lazy val BOOL: Boolean = true // warn warn } class A(val msg: String) class B1(msg: String) extends A(msg) class B2(msg0: String) extends A(msg0) -class B3(msg0: String) extends A("msg") // error /Dotty: unused explicit parameter +class B3(msg0: String) extends A("msg") // warn /Dotty: unused explicit parameter trait Bing trait Accessors { - private var v1: Int = 0 // error warn - private var v2: Int = 0 // error warn, never set + private var v1: Int = 0 // warn warn + private var v2: Int = 0 // warn warn, never set private var v3: Int = 0 private var v4: Int = 0 // no warn - private[this] var v5 = 0 // error warn, never set + private[this] var v5 = 0 // warn warn, never set private[this] var v6 = 0 private[this] var v7 = 0 // no warn @@ -43,12 +43,12 @@ trait Accessors { } class StableAccessors { - private var s1: Int = 0 // error warn - private var s2: Int = 0 // error warn, never set - private var s3: Int = 0 // warn, never got /Dotty: no warn even if not usued + private var s1: Int = 0 // warn warn + private var s2: Int = 0 // warn warn, never set + private var s3: Int = 0 private var s4: Int = 0 // no warn - private[this] var s5 = 0 // error warn, never set + private[this] var s5 = 0 // warn warn, never set private[this] var s6 = 0 // no warn, limitation /Dotty: Why limitation ? private[this] var s7 = 0 // no warn @@ -62,7 +62,6 @@ class StableAccessors { } trait DefaultArgs { - // warn about default getters for x2 and x3 private def bippy(x1: Int, x2: Int = 10, x3: Int = 15): Int = x1 + x2 + x3 // no more warn warn since #17061 def boppy() = bippy(5, 100, 200) @@ -75,27 +74,27 @@ class Outer { trait Locals { def f0 = { - var x = 1 // error warn + var x = 1 // warn warn var y = 2 y = 3 y + y } def f1 = { val a = new Outer // no warn - val b = new Outer // error warn + val b = new Outer // warn warn new a.Inner } def f2 = { - var x = 100 // error warn about it being a var, var not set + var x = 100 // warn warn about it being a var, var not set x } } object Types { private object Dongo { def f = this } // no more warn since #17061 - private class Bar1 // error warn + private class Bar1 // warn warn private class Bar2 // no warn - private type Alias1 = String // error warn + private type Alias1 = String // warn warn private type Alias2 = String // no warn def bippo = (new Bar2).toString @@ -103,14 +102,14 @@ object Types { def l1() = { object HiObject { def f = this } // no more warn since #17061 - class Hi { // error warn + class Hi { // warn warn def f1: Hi = new Hi def f2(x: Hi) = x } - class DingDongDoobie // error warn + class DingDongDoobie // warn warn class Bippy // no warn type Something = Bippy // no warn - type OtherThing = String // error warn + type OtherThing = String // warn warn (new Bippy): Something } } @@ -126,7 +125,7 @@ trait Underwarn { class OtherNames { private def x_=(i: Int): Unit = () // no more warn since #17061 - private def x: Int = 42 // error Dotty triggers unused private member : To investigate + private def x: Int = 42 // warn Dotty triggers unused private member : To investigate private def y_=(i: Int): Unit = () // // no more warn since #17061 private def y: Int = 42 @@ -152,7 +151,7 @@ trait Forever { } trait Ignorance { - private val readResolve = 42 // error ignore /dotty triggers unused private member/ why should we ignore ? + private val readResolve = 42 // warn ignore /dotty triggers unused private member/ why should we ignore ? } trait CaseyKasem { @@ -190,7 +189,7 @@ class `no warn in patmat anonfun isDefinedAt` { class `nonprivate alias is enclosing` { class C type C2 = C - private class D extends C2 // error warn + private class D extends C2 // warn warn } object `classof something` { @@ -200,8 +199,7 @@ object `classof something` { trait `short comings` { def f: Int = { - val x = 42 // error /Dotty only triggers in dotty + val x = 42 // warn /Dotty only triggers in dotty 17 } -} - +} \ No newline at end of file diff --git a/tests/neg/i16649-refutable.check b/tests/warn/i16649-refutable.check similarity index 78% rename from tests/neg/i16649-refutable.check rename to tests/warn/i16649-refutable.check index a1325d7cfa91..a6cacfc691ee 100644 --- a/tests/neg/i16649-refutable.check +++ b/tests/warn/i16649-refutable.check @@ -1,5 +1,5 @@ --- Error: tests/neg/i16649-refutable.scala:6:6 ------------------------------------------------------------------------- -6 | val '{ ($y: Int) + ($z: Int) } = x // error +-- Warning: tests/warn/i16649-refutable.scala:6:6 ---------------------------------------------------------------------- +6 | val '{ ($y: Int) + ($z: Int) } = x // warn | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | pattern binding uses refutable extractor `'{...}` | diff --git a/tests/neg/i16649-refutable.scala b/tests/warn/i16649-refutable.scala similarity index 59% rename from tests/neg/i16649-refutable.scala rename to tests/warn/i16649-refutable.scala index 8caac5b2576a..5ff18b5a3633 100644 --- a/tests/neg/i16649-refutable.scala +++ b/tests/warn/i16649-refutable.scala @@ -1,9 +1,10 @@ -//> using options -Xfatal-warnings + import quoted.* def foo(using Quotes)(x: Expr[Int]) = - val '{ ($y: Int) + ($z: Int) } = x // error + val '{ ($y: Int) + ($z: Int) } = x // warn val '{ $a: Int } = x val '{ $b: Any } = x val '{ $c } = x + diff --git a/tests/neg/i16728.check b/tests/warn/i16728.check similarity index 55% rename from tests/neg/i16728.check rename to tests/warn/i16728.check index 93cc215696c2..117b2bd0c4d4 100644 --- a/tests/neg/i16728.check +++ b/tests/warn/i16728.check @@ -1,5 +1,5 @@ --- [E092] Pattern Match Error: tests/neg/i16728.scala:18:11 ------------------------------------------------------------ -18 | case tx : C[Int]#X => // error +-- [E092] Pattern Match Unchecked Warning: tests/warn/i16728.scala:18:11 ----------------------------------------------- +18 | case tx : C[Int]#X => // warn | ^ | the type test for C[Int] cannot be checked at runtime because its type arguments can't be determined from A | diff --git a/tests/neg/i16728.scala b/tests/warn/i16728.scala similarity index 87% rename from tests/neg/i16728.scala rename to tests/warn/i16728.scala index b76bb03fa14a..4d28b07c51a3 100644 --- a/tests/neg/i16728.scala +++ b/tests/warn/i16728.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings + class A[T] { class X { @@ -15,7 +15,7 @@ object Test { val b0x : A[?]#X = new b0.X def test = b0x match { - case tx : C[Int]#X => // error + case tx : C[Int]#X => // warn val c : C[Int] = tx.outer c case _ => @@ -31,4 +31,4 @@ object Test { } } -} \ No newline at end of file +} diff --git a/tests/neg/i16930.scala b/tests/warn/i16930.scala similarity index 70% rename from tests/neg/i16930.scala rename to tests/warn/i16930.scala index c7af60161424..bf30fccbf601 100644 --- a/tests/neg/i16930.scala +++ b/tests/warn/i16930.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings -Wunused:imports +//> using options -Wunused:imports trait Outer: trait Used @@ -6,7 +6,7 @@ trait Outer: object Test { val outer: Outer = ??? - import outer.{Used, Unused} // error + import outer.{Used, Unused} // warn def foo(x: Any): Used = x.asInstanceOf[Used] } @@ -17,6 +17,6 @@ trait Outer1: object Test1 { val outer1: Outer1 = ??? - import outer1.{Unused1, UnusedToo1} // error // error + import outer1.{Unused1, UnusedToo1} // warn // warn def foo() = outer1.unusedToo1 // in this case UnusedToo1 is not used explicitly, only inferred -} +} \ No newline at end of file diff --git a/tests/neg/i17266.check b/tests/warn/i17266.check similarity index 83% rename from tests/neg/i17266.check rename to tests/warn/i17266.check index 1a84d1bf5e89..716cd531dd0a 100644 --- a/tests/neg/i17266.check +++ b/tests/warn/i17266.check @@ -1,5 +1,5 @@ --- [E181] Potential Issue Error: tests/neg/i17266.scala:4:2 ------------------------------------------------------------ -4 | synchronized { // error +-- [E181] Potential Issue Warning: tests/warn/i17266.scala:4:2 --------------------------------------------------------- +4 | synchronized { // warn | ^^^^^^^^^^^^ | Suspicious top-level unqualified call to synchronized |--------------------------------------------------------------------------------------------------------------------- @@ -9,8 +9,8 @@ | resolved to calls on Predef or on imported methods. This might not be what | you intended. --------------------------------------------------------------------------------------------------------------------- --- [E181] Potential Issue Error: tests/neg/i17266.scala:17:2 ----------------------------------------------------------- -17 | synchronized { // error +-- [E181] Potential Issue Warning: tests/warn/i17266.scala:17:2 -------------------------------------------------------- +17 | synchronized { // warn | ^^^^^^^^^^^^ | Suspicious top-level unqualified call to synchronized |-------------------------------------------------------------------------------------------------------------------- @@ -20,8 +20,8 @@ | resolved to calls on Predef or on imported methods. This might not be what | you intended. -------------------------------------------------------------------------------------------------------------------- --- [E187] Potential Issue Error: tests/neg/i17266.scala:22:4 ----------------------------------------------------------- -22 | 1.synchronized { // error +-- [E187] Potential Issue Warning: tests/warn/i17266.scala:22:4 -------------------------------------------------------- +22 | 1.synchronized { // warn | ^^^^^^^^^^^^^^ | Suspicious synchronized call on boxed class |-------------------------------------------------------------------------------------------------------------------- @@ -30,8 +30,8 @@ | You called the synchronized method on a boxed primitive. This might not be what | you intended. -------------------------------------------------------------------------------------------------------------------- --- [E181] Potential Issue Error: tests/neg/i17266.scala:108:2 ---------------------------------------------------------- -108 | wait() // error +-- [E181] Potential Issue Warning: tests/warn/i17266.scala:108:2 ------------------------------------------------------- +108 | wait() // warn | ^^^^ | Suspicious top-level unqualified call to wait |------------------------------------------------------------------------------------------------------------------- @@ -41,8 +41,8 @@ | resolved to calls on Predef or on imported methods. This might not be what | you intended. ------------------------------------------------------------------------------------------------------------------- --- [E181] Potential Issue Error: tests/neg/i17266.scala:115:2 ---------------------------------------------------------- -115 | wait() // error +-- [E181] Potential Issue Warning: tests/warn/i17266.scala:115:2 ------------------------------------------------------- +115 | wait() // warn | ^^^^ | Suspicious top-level unqualified call to wait |------------------------------------------------------------------------------------------------------------------- @@ -52,8 +52,8 @@ | resolved to calls on Predef or on imported methods. This might not be what | you intended. ------------------------------------------------------------------------------------------------------------------- --- [E181] Potential Issue Error: tests/neg/i17266.scala:121:2 ---------------------------------------------------------- -121 | wait(10) // error +-- [E181] Potential Issue Warning: tests/warn/i17266.scala:121:2 ------------------------------------------------------- +121 | wait(10) // warn | ^^^^ | Suspicious top-level unqualified call to wait |------------------------------------------------------------------------------------------------------------------- @@ -63,8 +63,8 @@ | resolved to calls on Predef or on imported methods. This might not be what | you intended. ------------------------------------------------------------------------------------------------------------------- --- [E181] Potential Issue Error: tests/neg/i17266.scala:128:2 ---------------------------------------------------------- -128 | wait(10) // error +-- [E181] Potential Issue Warning: tests/warn/i17266.scala:128:2 ------------------------------------------------------- +128 | wait(10) // warn | ^^^^ | Suspicious top-level unqualified call to wait |------------------------------------------------------------------------------------------------------------------- @@ -74,8 +74,8 @@ | resolved to calls on Predef or on imported methods. This might not be what | you intended. ------------------------------------------------------------------------------------------------------------------- --- [E181] Potential Issue Error: tests/neg/i17266.scala:134:2 ---------------------------------------------------------- -134 | hashCode() // error +-- [E181] Potential Issue Warning: tests/warn/i17266.scala:134:2 ------------------------------------------------------- +134 | hashCode() // warn | ^^^^^^^^ | Suspicious top-level unqualified call to hashCode |------------------------------------------------------------------------------------------------------------------- @@ -85,8 +85,8 @@ | resolved to calls on Predef or on imported methods. This might not be what | you intended. ------------------------------------------------------------------------------------------------------------------- --- [E181] Potential Issue Error: tests/neg/i17266.scala:141:2 ---------------------------------------------------------- -141 | hashCode() // error +-- [E181] Potential Issue Warning: tests/warn/i17266.scala:141:2 ------------------------------------------------------- +141 | hashCode() // warn | ^^^^^^^^ | Suspicious top-level unqualified call to hashCode |------------------------------------------------------------------------------------------------------------------- diff --git a/tests/neg/i17266.scala b/tests/warn/i17266.scala similarity index 86% rename from tests/neg/i17266.scala rename to tests/warn/i17266.scala index 439abafc44a1..7e0c9f1b653b 100644 --- a/tests/neg/i17266.scala +++ b/tests/warn/i17266.scala @@ -1,7 +1,7 @@ -//> using options -Werror -explain +//> using options -explain def test1 = - synchronized { // error + synchronized { // warn println("hello") } @@ -14,12 +14,12 @@ object MyLib def test3 = import MyLib.* - synchronized { // error + synchronized { // warn println("hello") } def test4 = - 1.synchronized { // error + 1.synchronized { // warn println("hello") } @@ -105,40 +105,40 @@ trait Test15: } def test16 = - wait() // error + wait() // warn def test17 = this.wait() // not an error (should be?) def test18 = import MyLib.* - wait() // error + wait() // warn def test19 = 1.wait() // not an error (should be?) def test20 = - wait(10) // error + wait(10) // warn def test21 = this.wait(10) // not an error (should be?) def test22 = import MyLib.* - wait(10) // error + wait(10) // warn def test23 = 1.wait(10) // not an error (should be?) def test24 = - hashCode() // error + hashCode() // warn def test25 = this.hashCode() // not an error (should be?) def test26 = import MyLib.* - hashCode() // error + hashCode() // warn def test27 = - 1.hashCode()// not an error (should be? probably not) + 1.hashCode()// not an error (should be? probably not) \ No newline at end of file diff --git a/tests/neg/i17314b.scala b/tests/warn/i17314b.scala similarity index 63% rename from tests/neg/i17314b.scala rename to tests/warn/i17314b.scala index 9e89fecde935..e1500028ca93 100644 --- a/tests/neg/i17314b.scala +++ b/tests/warn/i17314b.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings -Wunused:all +//> using options -Wunused:all package foo: class Foo[T] @@ -6,9 +6,10 @@ package foo: package bar: - import foo.{given foo.Foo[Int]} // error + import foo.{given foo.Foo[Int]} // warn import foo.Foo given Foo[Int] = ??? val repro: Foo[Int] = summon[Foo[Int]] + diff --git a/tests/neg/i17612a.check b/tests/warn/i17612a.check similarity index 62% rename from tests/neg/i17612a.check rename to tests/warn/i17612a.check index 04a5b07b6e33..67b489f17a91 100644 --- a/tests/neg/i17612a.check +++ b/tests/warn/i17612a.check @@ -1,32 +1,32 @@ --- Error: tests/neg/i17612a.scala:18:15 -------------------------------------------------------------------------------- -18 | class Derived(x : Int, y: Int, z2: Int) extends Base(x, y + 1, z2): // error // error / for x, y translated to private[this] x field & shadowing var Base.x, Base.y +-- Warning: tests/warn/i17612a.scala:18:15 ----------------------------------------------------------------------------- +18 | class Derived(x : Int, y: Int, z2: Int) extends Base(x, y + 1, z2): // warn // warn / for x, y translated to private[this] x field & shadowing var Base.x, Base.y | ^ | value x in class Derived shadows field x inherited from class Base --- Error: tests/neg/i17612a.scala:18:24 -------------------------------------------------------------------------------- -18 | class Derived(x : Int, y: Int, z2: Int) extends Base(x, y + 1, z2): // error // error / for x, y translated to private[this] x field & shadowing var Base.x, Base.y +-- Warning: tests/warn/i17612a.scala:18:24 ----------------------------------------------------------------------------- +18 | class Derived(x : Int, y: Int, z2: Int) extends Base(x, y + 1, z2): // warn // warn / for x, y translated to private[this] x field & shadowing var Base.x, Base.y | ^ | value y in class Derived shadows field y inherited from class Base --- Error: tests/neg/i17612a.scala:20:2 --------------------------------------------------------------------------------- -20 | private val shadowed2 = 2 + 2 // error (In Scala 2 we cannot do that got the warning) +-- Warning: tests/warn/i17612a.scala:20:2 ------------------------------------------------------------------------------ +20 | private val shadowed2 = 2 + 2 // warn (In Scala 2 we cannot do that got the warning) | ^ | value shadowed2 in class Derived shadows field shadowed2 inherited from class Base --- Error: tests/neg/i17612a.scala:21:2 --------------------------------------------------------------------------------- -21 | private[this] val shadowed3 = 3 + 3 // error +-- Warning: tests/warn/i17612a.scala:21:2 ------------------------------------------------------------------------------ +21 | private[this] val shadowed3 = 3 + 3 // warn | ^ | value shadowed3 in class Derived shadows field shadowed3 inherited from class Base --- Error: tests/neg/i17612a.scala:23:2 --------------------------------------------------------------------------------- -23 | private val shadowed5 = 5 + 5 // error +-- Warning: tests/warn/i17612a.scala:23:2 ------------------------------------------------------------------------------ +23 | private val shadowed5 = 5 + 5 // warn | ^ | value shadowed5 in class Derived shadows field shadowed5 inherited from class Base --- Error: tests/neg/i17612a.scala:34:20 -------------------------------------------------------------------------------- -34 | class UnderDerived(x: Int, y: Int, z: Int) extends Derived(x, y, z) // error // error // error +-- Warning: tests/warn/i17612a.scala:34:20 ----------------------------------------------------------------------------- +34 | class UnderDerived(x: Int, y: Int, z: Int) extends Derived(x, y, z) // warn // warn // warn | ^ | value x in class UnderDerived shadows field x inherited from class Base --- Error: tests/neg/i17612a.scala:34:28 -------------------------------------------------------------------------------- -34 | class UnderDerived(x: Int, y: Int, z: Int) extends Derived(x, y, z) // error // error // error +-- Warning: tests/warn/i17612a.scala:34:28 ----------------------------------------------------------------------------- +34 | class UnderDerived(x: Int, y: Int, z: Int) extends Derived(x, y, z) // warn // warn // warn | ^ | value y in class UnderDerived shadows field y inherited from class Base --- Error: tests/neg/i17612a.scala:34:36 -------------------------------------------------------------------------------- -34 | class UnderDerived(x: Int, y: Int, z: Int) extends Derived(x, y, z) // error // error // error +-- Warning: tests/warn/i17612a.scala:34:36 ----------------------------------------------------------------------------- +34 | class UnderDerived(x: Int, y: Int, z: Int) extends Derived(x, y, z) // warn // warn // warn | ^ | value z in class UnderDerived shadows field z inherited from class Base diff --git a/tests/neg/i17612a.scala b/tests/warn/i17612a.scala similarity index 76% rename from tests/neg/i17612a.scala rename to tests/warn/i17612a.scala index 099b528965e1..7473d8fd9ec9 100644 --- a/tests/neg/i17612a.scala +++ b/tests/warn/i17612a.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings -Xlint:private-shadow -source:3.3 +//> using options -Xlint:private-shadow -source:3.3 object i17612a: class Base(var x: Int, val y: Int, var z: Int): @@ -15,12 +15,12 @@ object i17612a: def increment(): Unit = x = x + 1 - class Derived(x : Int, y: Int, z2: Int) extends Base(x, y + 1, z2): // error // error / for x, y translated to private[this] x field & shadowing var Base.x, Base.y + class Derived(x : Int, y: Int, z2: Int) extends Base(x, y + 1, z2): // warn // warn / for x, y translated to private[this] x field & shadowing var Base.x, Base.y private def hello() = 4 - private val shadowed2 = 2 + 2 // error (In Scala 2 we cannot do that got the warning) - private[this] val shadowed3 = 3 + 3 // error + private val shadowed2 = 2 + 2 // warn (In Scala 2 we cannot do that got the warning) + private[this] val shadowed3 = 3 + 3 // warn //private[Derived] val fatalOverride = 0 // value fatalOverride of type Int has weaker access privileges; it should be public - private val shadowed5 = 5 + 5 // error + private val shadowed5 = 5 + 5 // warn private val notShadowed2 = -4 //protected var shadowed6 = 6 + 6 // variable shadowed6 of type Int has weaker access privileges; it should be public @@ -31,7 +31,7 @@ object i17612a: override def toString = s"x : ${x.toString}, y : ${y.toString}" - class UnderDerived(x: Int, y: Int, z: Int) extends Derived(x, y, z) // error // error // error + class UnderDerived(x: Int, y: Int, z: Int) extends Derived(x, y, z) // warn // warn // warn def main(args: Array[String]) = val derived = new Derived(1, 1, 1) diff --git a/tests/neg/i17613a.check b/tests/warn/i17613a.check similarity index 57% rename from tests/neg/i17613a.check rename to tests/warn/i17613a.check index 4721b786c82d..6e40d102b1a4 100644 --- a/tests/neg/i17613a.check +++ b/tests/warn/i17613a.check @@ -1,28 +1,28 @@ --- Error: tests/neg/i17613a.scala:8:13 --------------------------------------------------------------------------------- -8 | def foobar[D](in: D) = in.toString // error method parameter shadows some other type +-- Warning: tests/warn/i17613a.scala:8:13 ------------------------------------------------------------------------------ +8 | def foobar[D](in: D) = in.toString // warn method parameter shadows some other type | ^ | Type parameter D for method foobar shadows the type defined by trait D in class B --- Error: tests/neg/i17613a.scala:9:13 --------------------------------------------------------------------------------- -9 | type MySeq[D] = Seq[D] // error type member's parameter shadows some other type +-- Warning: tests/warn/i17613a.scala:9:13 ------------------------------------------------------------------------------ +9 | type MySeq[D] = Seq[D] // warn type member's parameter shadows some other type | ^ | Type parameter D for type MySeq shadows the type defined by trait D in class B --- Error: tests/neg/i17613a.scala:11:12 -------------------------------------------------------------------------------- -11 | class Foo[T](t: T): // error class parameter shadows some other type +-- Warning: tests/warn/i17613a.scala:11:12 ----------------------------------------------------------------------------- +11 | class Foo[T](t: T): // warn class parameter shadows some other type | ^ | Type parameter T for class Foo shadows the type defined by type T in class B --- Error: tests/neg/i17613a.scala:12:11 -------------------------------------------------------------------------------- -12 | def bar[T](w: T) = w.toString // error a type parameter shadows another type parameter +-- Warning: tests/warn/i17613a.scala:12:11 ----------------------------------------------------------------------------- +12 | def bar[T](w: T) = w.toString // warn a type parameter shadows another type parameter | ^ | Type parameter T for method bar shadows the type defined by type T in class Foo --- Error: tests/neg/i17613a.scala:15:12 -------------------------------------------------------------------------------- -15 | class C[M[List[_]]] // error +-- Warning: tests/warn/i17613a.scala:15:12 ----------------------------------------------------------------------------- +15 | class C[M[List[_]]] // warn | ^^^^^^^ | Type parameter List for class C shadows the type defined by type List in package scala --- Error: tests/neg/i17613a.scala:16:11 -------------------------------------------------------------------------------- -16 | type E[M[List[_]]] = Int // error +-- Warning: tests/warn/i17613a.scala:16:11 ----------------------------------------------------------------------------- +16 | type E[M[List[_]]] = Int // warn | ^^^^^^^ | Type parameter List for type E shadows the type defined by type List in package scala --- Error: tests/neg/i17613a.scala:17:14 -------------------------------------------------------------------------------- -17 | def foo[N[M[List[_]]]] = ??? // error +-- Warning: tests/warn/i17613a.scala:17:14 ----------------------------------------------------------------------------- +17 | def foo[N[M[List[_]]]] = ??? // warn | ^^^^^^^ | Type parameter List for method foo shadows the type defined by type List in package scala diff --git a/tests/warn/i17613a.scala b/tests/warn/i17613a.scala new file mode 100644 index 000000000000..6ee55a5cf973 --- /dev/null +++ b/tests/warn/i17613a.scala @@ -0,0 +1,23 @@ +//> using options -Xlint:type-parameter-shadow + +object i17613a: + class B: + type T = Int + trait D + + def foobar[D](in: D) = in.toString // warn method parameter shadows some other type + type MySeq[D] = Seq[D] // warn type member's parameter shadows some other type + + class Foo[T](t: T): // warn class parameter shadows some other type + def bar[T](w: T) = w.toString // warn a type parameter shadows another type parameter + + // even deeply nested... + class C[M[List[_]]] // warn + type E[M[List[_]]] = Int // warn + def foo[N[M[List[_]]]] = ??? // warn + + // ...but not between type parameters in the same list + class F[A, M[N[A]]] + type G[A, M[L[A]]] = Int + def bar[A, N[M[L[A]]]] = ??? + def main(args: Array[String]) = println("Test for type parameter shadow") \ No newline at end of file diff --git a/tests/neg/i18722.check b/tests/warn/i18722.check similarity index 89% rename from tests/neg/i18722.check rename to tests/warn/i18722.check index 539e23787752..4fae07e15204 100644 --- a/tests/neg/i18722.check +++ b/tests/warn/i18722.check @@ -1,5 +1,5 @@ --- [E190] Potential Issue Error: tests/neg/i18722.scala:3:15 ----------------------------------------------------------- -3 |def f1: Unit = null // error +-- [E190] Potential Issue Warning: tests/warn/i18722.scala:3:15 -------------------------------------------------------- +3 |def f1: Unit = null // warn | ^^^^ | Discarded non-Unit value of type Null. You may want to use `()`. |--------------------------------------------------------------------------------------------------------------------- @@ -9,8 +9,8 @@ | Here the `null` expression is a pure statement that can be discarded. | Therefore the expression is effectively equivalent to `()`. --------------------------------------------------------------------------------------------------------------------- --- [E190] Potential Issue Error: tests/neg/i18722.scala:4:15 ----------------------------------------------------------- -4 |def f2: Unit = 1 // error +-- [E190] Potential Issue Warning: tests/warn/i18722.scala:4:15 -------------------------------------------------------- +4 |def f2: Unit = 1 // warn | ^ | Discarded non-Unit value of type Int. You may want to use `()`. |--------------------------------------------------------------------------------------------------------------------- @@ -20,8 +20,8 @@ | Here the `1` expression is a pure statement that can be discarded. | Therefore the expression is effectively equivalent to `()`. --------------------------------------------------------------------------------------------------------------------- --- [E190] Potential Issue Error: tests/neg/i18722.scala:5:15 ----------------------------------------------------------- -5 |def f3: Unit = "a" // error +-- [E190] Potential Issue Warning: tests/warn/i18722.scala:5:15 -------------------------------------------------------- +5 |def f3: Unit = "a" // warn | ^^^ | Discarded non-Unit value of type String. You may want to use `()`. |--------------------------------------------------------------------------------------------------------------------- @@ -31,8 +31,8 @@ | Here the `"a"` expression is a pure statement that can be discarded. | Therefore the expression is effectively equivalent to `()`. --------------------------------------------------------------------------------------------------------------------- --- [E190] Potential Issue Error: tests/neg/i18722.scala:7:15 ----------------------------------------------------------- -7 |def f4: Unit = i // error +-- [E190] Potential Issue Warning: tests/warn/i18722.scala:7:15 -------------------------------------------------------- +7 |def f4: Unit = i // warn | ^ | Discarded non-Unit value of type Int. You may want to use `()`. |--------------------------------------------------------------------------------------------------------------------- diff --git a/tests/warn/i18722.scala b/tests/warn/i18722.scala new file mode 100644 index 000000000000..246640a349b4 --- /dev/null +++ b/tests/warn/i18722.scala @@ -0,0 +1,9 @@ +//> using options -explain + +def f1: Unit = null // warn +def f2: Unit = 1 // warn +def f3: Unit = "a" // warn +val i: Int = 1 +def f4: Unit = i // warn +val u: Unit = () +def f5: Unit = u \ No newline at end of file diff --git a/tests/neg/i18862-3.4.check b/tests/warn/i18862-3.4.check similarity index 70% rename from tests/neg/i18862-3.4.check rename to tests/warn/i18862-3.4.check index b56454feeeaa..8dd5058d305e 100644 --- a/tests/neg/i18862-3.4.check +++ b/tests/warn/i18862-3.4.check @@ -1,5 +1,5 @@ --- Error: tests/neg/i18862-3.4.scala:6:38 ------------------------------------------------------------------------------ -6 |def test(xs: List[Int]): Unit = f(xs: _*) // error: migration warning +-- Warning: tests/warn/i18862-3.4.scala:4:38 --------------------------------------------------------------------------- +4 |def test(xs: List[Int]): Unit = f(xs: _*) // warn: migration warning | ^ | The syntax `x: _*` is no longer supported for vararg splices; use `x*` instead | This construct can be rewritten automatically under -rewrite -source 3.4-migration. diff --git a/tests/warn/i18862-3.4.scala b/tests/warn/i18862-3.4.scala new file mode 100644 index 000000000000..6d9cf8c71f7b --- /dev/null +++ b/tests/warn/i18862-3.4.scala @@ -0,0 +1,4 @@ +import scala.language.`3.4` + +def f(x: Int*): Unit = () +def test(xs: List[Int]): Unit = f(xs: _*) // warn: migration warning diff --git a/tests/warn/i18862-future-migration.scala b/tests/warn/i18862-future-migration.scala new file mode 100644 index 000000000000..02225b67435a --- /dev/null +++ b/tests/warn/i18862-future-migration.scala @@ -0,0 +1,4 @@ +import scala.language.`future-migration` + +def f(x: Int*): Unit = () +def test(xs: List[Int]): Unit = f(xs: _*) // warn: migration warning diff --git a/tests/warn/i18867-3.4.scala b/tests/warn/i18867-3.4.scala new file mode 100644 index 000000000000..e2630c0cb95c --- /dev/null +++ b/tests/warn/i18867-3.4.scala @@ -0,0 +1,5 @@ +import language.`3.4` + +def foo(x: Int) = x + +def test = foo _ // warn diff --git a/tests/neg/i18867.check b/tests/warn/i18867.check similarity index 76% rename from tests/neg/i18867.check rename to tests/warn/i18867.check index 014e9e7bd92e..226496d8e74b 100644 --- a/tests/neg/i18867.check +++ b/tests/warn/i18867.check @@ -1,5 +1,5 @@ --- Error: tests/neg/i18867.scala:5:15 ---------------------------------------------------------------------------------- -5 |def test = foo _ // error +-- Warning: tests/warn/i18867.scala:3:15 ------------------------------------------------------------------------------- +3 |def test = foo _ // warn | ^^^^^ | The syntax ` _` is no longer supported; | you can simply leave out the trailing ` _` diff --git a/tests/warn/i18867.scala b/tests/warn/i18867.scala new file mode 100644 index 000000000000..a16d67b89919 --- /dev/null +++ b/tests/warn/i18867.scala @@ -0,0 +1,3 @@ +def foo(x: Int) = x + +def test = foo _ // warn diff --git a/tests/warn/i2333.scala b/tests/warn/i2333.scala new file mode 100644 index 000000000000..1ac5eb314325 --- /dev/null +++ b/tests/warn/i2333.scala @@ -0,0 +1,11 @@ +//> using options -deprecation + +@deprecated("bla", "2.11.0") class Foo { + println("") + def this(x: Int) = this() +} + +object Test { + new Foo // warn: deprecated + new Foo(1) // warn: deprecated +} \ No newline at end of file diff --git a/tests/warn/i2673.scala b/tests/warn/i2673.scala new file mode 100644 index 000000000000..a04e3b370d56 --- /dev/null +++ b/tests/warn/i2673.scala @@ -0,0 +1,6 @@ + + +package Foos + +class Foo // warn +class foo diff --git a/tests/warn/i2673b.scala b/tests/warn/i2673b.scala new file mode 100644 index 000000000000..0d11317cd9e6 --- /dev/null +++ b/tests/warn/i2673b.scala @@ -0,0 +1,7 @@ + + +package Foos + +class Bar // warn +object bar + diff --git a/tests/warn/i2673c.scala b/tests/warn/i2673c.scala new file mode 100644 index 000000000000..682e4adfa2c9 --- /dev/null +++ b/tests/warn/i2673c.scala @@ -0,0 +1,9 @@ + + +package Foos + +object Outer { + case class X() // warn + object x +} + diff --git a/tests/warn/i3324.scala b/tests/warn/i3324.scala new file mode 100644 index 000000000000..ab0c24da39a5 --- /dev/null +++ b/tests/warn/i3324.scala @@ -0,0 +1,6 @@ + + +class Foo { + def foo(x: Any): Boolean = + x.isInstanceOf[List[String]] // warn +} diff --git a/tests/neg/i3561.scala b/tests/warn/i3561.scala similarity index 51% rename from tests/neg/i3561.scala rename to tests/warn/i3561.scala index 862e65f3c2f7..a64a599eafec 100644 --- a/tests/neg/i3561.scala +++ b/tests/warn/i3561.scala @@ -1,18 +1,18 @@ -//> using options -Xfatal-warnings + class Test { val Constant = 'Q' // OK if final - def tokenMe(ch: Char) = (ch: @annotation.switch) match { // error: could not emit switch + def tokenMe(ch: Char) = (ch: @annotation.switch) match { // warn: could not emit switch case ' ' => 1 case 'A' => 2 case '5' | Constant => 3 case '4' => 4 } - def test2(x: Any) = (x: @annotation.switch) match { // error: could not emit switch + def test2(x: Any) = (x: @annotation.switch) match { // warn: could not emit switch case ' ' => 1 case 'A' => 2 case '5' | Constant => 3 case '4' => 4 } -} +} \ No newline at end of file diff --git a/tests/neg/i4008.check b/tests/warn/i4008.check similarity index 80% rename from tests/neg/i4008.check rename to tests/warn/i4008.check index c1f27866d1c1..b72e7a8c20c5 100644 --- a/tests/neg/i4008.check +++ b/tests/warn/i4008.check @@ -1,40 +1,40 @@ --- [E158] Reference Error: tests/neg/i4008.scala:7:56 ------------------------------------------------------------------ -7 |@annotation.implicitNotFound("An implicit ShouldWarn1[${B}] is not in scope") // error +-- [E158] Reference Warning: tests/warn/i4008.scala:7:56 --------------------------------------------------------------- +7 |@annotation.implicitNotFound("An implicit ShouldWarn1[${B}] is not in scope") // warn | ^ | Invalid reference to a type variable `B` found in the annotation argument. | The variable does not occur as a parameter in the scope of type `ShouldWarn1`. --- [E158] Reference Error: tests/neg/i4008.scala:11:56 ----------------------------------------------------------------- -11 |@annotation.implicitNotFound("An implicit ShouldWarn2[${A}] is not in scope") // error +-- [E158] Reference Warning: tests/warn/i4008.scala:11:56 -------------------------------------------------------------- +11 |@annotation.implicitNotFound("An implicit ShouldWarn2[${A}] is not in scope") // warn | ^ | Invalid reference to a type variable `A` found in the annotation argument. | The variable does not occur as a parameter in the scope of type `ShouldWarn2`. --- [E158] Reference Error: tests/neg/i4008.scala:15:56 ----------------------------------------------------------------- -15 |@annotation.implicitNotFound("An implicit ShouldWarn3[${A},${B}] is not in scope") // error +-- [E158] Reference Warning: tests/warn/i4008.scala:15:56 -------------------------------------------------------------- +15 |@annotation.implicitNotFound("An implicit ShouldWarn3[${A},${B}] is not in scope") // warn | ^ | Invalid reference to a type variable `A` found in the annotation argument. | The variable does not occur as a parameter in the scope of type `ShouldWarn3`. --- [E158] Reference Error: tests/neg/i4008.scala:19:56 ----------------------------------------------------------------- -19 |@annotation.implicitNotFound("An implicit ShouldWarn4[${A},${B}] is not in scope") // error // error +-- [E158] Reference Warning: tests/warn/i4008.scala:19:56 -------------------------------------------------------------- +19 |@annotation.implicitNotFound("An implicit ShouldWarn4[${A},${B}] is not in scope") // warn // warn | ^ | Invalid reference to a type variable `A` found in the annotation argument. | The variable does not occur as a parameter in the scope of type `ShouldWarn4`. --- [E158] Reference Error: tests/neg/i4008.scala:19:61 ----------------------------------------------------------------- -19 |@annotation.implicitNotFound("An implicit ShouldWarn4[${A},${B}] is not in scope") // error // error +-- [E158] Reference Warning: tests/warn/i4008.scala:19:61 -------------------------------------------------------------- +19 |@annotation.implicitNotFound("An implicit ShouldWarn4[${A},${B}] is not in scope") // warn // warn | ^ | Invalid reference to a type variable `B` found in the annotation argument. | The variable does not occur as a parameter in the scope of type `ShouldWarn4`. --- [E158] Reference Error: tests/neg/i4008.scala:23:61 ----------------------------------------------------------------- -23 |@annotation.implicitNotFound("An implicit ShouldWarn5[${C},${Abc}] is not in scope") // error +-- [E158] Reference Warning: tests/warn/i4008.scala:23:61 -------------------------------------------------------------- +23 |@annotation.implicitNotFound("An implicit ShouldWarn5[${C},${Abc}] is not in scope") // warn | ^ | Invalid reference to a type variable `Abc` found in the annotation argument. | The variable does not occur as a parameter in the scope of type `ShouldWarn5`. --- [E158] Reference Error: tests/neg/i4008.scala:46:54 ----------------------------------------------------------------- -46 |class C[A](using @annotation.implicitNotFound("No C[${B}] found") c: Class[A]) // error +-- [E158] Reference Warning: tests/warn/i4008.scala:46:54 -------------------------------------------------------------- +46 |class C[A](using @annotation.implicitNotFound("No C[${B}] found") c: Class[A]) // warn | ^ | Invalid reference to a type variable `B` found in the annotation argument. | The variable does not occur as a parameter in the scope of the constructor of `C`. --- [E158] Reference Error: tests/neg/i4008.scala:48:62 ----------------------------------------------------------------- -48 |def someMethod1[A](using @annotation.implicitNotFound("No C[${B}] found") sc: C[A]) = 0 // error +-- [E158] Reference Warning: tests/warn/i4008.scala:48:62 -------------------------------------------------------------- +48 |def someMethod1[A](using @annotation.implicitNotFound("No C[${B}] found") sc: C[A]) = 0 // warn | ^ | Invalid reference to a type variable `B` found in the annotation argument. | The variable does not occur as a parameter in the scope of method `someMethod1`. diff --git a/tests/neg/i4008.scala b/tests/warn/i4008.scala similarity index 86% rename from tests/neg/i4008.scala rename to tests/warn/i4008.scala index 5b851c987e37..489a067bf6fd 100644 --- a/tests/neg/i4008.scala +++ b/tests/warn/i4008.scala @@ -1,26 +1,26 @@ -//> using options -Xfatal-warnings + // ===== Template annotations ===== // class, 1TP, invalid ref -@annotation.implicitNotFound("An implicit ShouldWarn1[${B}] is not in scope") // error +@annotation.implicitNotFound("An implicit ShouldWarn1[${B}] is not in scope") // warn class ShouldWarn1[A] // trait, 1TP, invalid ref -@annotation.implicitNotFound("An implicit ShouldWarn2[${A}] is not in scope") // error +@annotation.implicitNotFound("An implicit ShouldWarn2[${A}] is not in scope") // warn trait ShouldWarn2[B] // trait, 2TP, 1 invalid ref -@annotation.implicitNotFound("An implicit ShouldWarn3[${A},${B}] is not in scope") // error +@annotation.implicitNotFound("An implicit ShouldWarn3[${A},${B}] is not in scope") // warn trait ShouldWarn3[B, C] // class, 2TP, 2 invalid refs -@annotation.implicitNotFound("An implicit ShouldWarn4[${A},${B}] is not in scope") // error // error +@annotation.implicitNotFound("An implicit ShouldWarn4[${A},${B}] is not in scope") // warn // warn class ShouldWarn4[C, D] // class, 2TP, 1 invalid multi-char refs -@annotation.implicitNotFound("An implicit ShouldWarn5[${C},${Abc}] is not in scope") // error +@annotation.implicitNotFound("An implicit ShouldWarn5[${C},${Abc}] is not in scope") // warn class ShouldWarn5[C, D] // trait, 1TP, valid ref @@ -43,8 +43,8 @@ class ShouldntWarn4[Hello, World] @annotation.implicitNotFound("Hopefully you don't see this!") -class C[A](using @annotation.implicitNotFound("No C[${B}] found") c: Class[A]) // error +class C[A](using @annotation.implicitNotFound("No C[${B}] found") c: Class[A]) // warn -def someMethod1[A](using @annotation.implicitNotFound("No C[${B}] found") sc: C[A]) = 0 // error +def someMethod1[A](using @annotation.implicitNotFound("No C[${B}] found") sc: C[A]) = 0 // warn def someMethod2[A](using @annotation.implicitNotFound("No C[${A}] found") sc: C[A]) = "" \ No newline at end of file diff --git a/tests/neg-deep-subtype/i4297.scala b/tests/warn/i4297.scala similarity index 64% rename from tests/neg-deep-subtype/i4297.scala rename to tests/warn/i4297.scala index 88e66c59d1b4..a34c3a5de584 100644 --- a/tests/neg-deep-subtype/i4297.scala +++ b/tests/warn/i4297.scala @@ -1,13 +1,14 @@ -//> using options -Xfatal-warnings + class Test { def test[X <: Option[Int]](x: X) = x.isInstanceOf[Some[Int]] def test1[Y <: Int, X <: Option[Y]](x: X) = x.isInstanceOf[Some[Int]] def test2(x: Any) = x.isInstanceOf[Function1[Nothing, ?]] - def test3a(x: Any) = x.isInstanceOf[Function1[Any, ?]] // error - def test3b(x: Any) = x.isInstanceOf[Function1[Int, ?]] // error - def test4[Y <: Int, X <: Function1[Y, Unit]](x: X) = x.isInstanceOf[Function1[Int, ?]] // error - def test5[Y <: Int, X <: Function1[Y, Unit]](x: X) = x.isInstanceOf[Function1[Int, Unit]] // error - def test6[Y <: Int, X <: Function1[Y, Unit]](x: X) = x.isInstanceOf[Function1[Int, Any]] // error + def test3a(x: Any) = x.isInstanceOf[Function1[Any, ?]] // warn + def test3b(x: Any) = x.isInstanceOf[Function1[Int, ?]] // warn + def test4[Y <: Int, X <: Function1[Y, Unit]](x: X) = x.isInstanceOf[Function1[Int, ?]] // warn + def test5[Y <: Int, X <: Function1[Y, Unit]](x: X) = x.isInstanceOf[Function1[Int, Unit]] // warn + def test6[Y <: Int, X <: Function1[Y, Unit]](x: X) = x.isInstanceOf[Function1[Int, Any]] // warn def test7[Y <: Int, X <: Function1[Y, Unit]](x: X) = x.isInstanceOf[Function1[?, Unit]] } + diff --git a/tests/neg/i4364.scala b/tests/warn/i4364.scala similarity index 61% rename from tests/neg/i4364.scala rename to tests/warn/i4364.scala index 85dca443f6d4..5cfc2ed5076d 100644 --- a/tests/neg/i4364.scala +++ b/tests/warn/i4364.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings + object Test { def foo(c: java.util.function.Consumer[Integer]) = c.accept(0) @@ -6,6 +6,6 @@ object Test { def main(args: Array[String]) = { foo(f) // Ok: Consumer is @FunctionalInterface - new java.io.ObjectOutputStream(f) // error: OutputStream is not @FunctionalInterface + new java.io.ObjectOutputStream(f) // warn: OutputStream is not @FunctionalInterface } } diff --git a/tests/warn/i4812.check b/tests/warn/i4812.check new file mode 100644 index 000000000000..a09e91b4c797 --- /dev/null +++ b/tests/warn/i4812.check @@ -0,0 +1,42 @@ +-- [E092] Pattern Match Unchecked Warning: tests/warn/i4812.scala:8:11 ------------------------------------------------- +8 | case prev: A => // warn: the type test for A cannot be checked at runtime + | ^ + | the type test for A cannot be checked at runtime because it's a local class + | + | longer explanation available when compiling with `-explain` +-- [E092] Pattern Match Unchecked Warning: tests/warn/i4812.scala:18:11 ------------------------------------------------ +18 | case prev: A => // warn: the type test for A cannot be checked at runtime + | ^ + | the type test for A cannot be checked at runtime because it's a local class + | + | longer explanation available when compiling with `-explain` +-- [E092] Pattern Match Unchecked Warning: tests/warn/i4812.scala:28:11 ------------------------------------------------ +28 | case prev: A => // warn: the type test for A cannot be checked at runtime + | ^ + | the type test for A cannot be checked at runtime because it's a local class + | + | longer explanation available when compiling with `-explain` +-- [E092] Pattern Match Unchecked Warning: tests/warn/i4812.scala:38:11 ------------------------------------------------ +38 | case prev: A => // warn: the type test for A cannot be checked at runtime + | ^ + | the type test for A cannot be checked at runtime because it's a local class + | + | longer explanation available when compiling with `-explain` +-- [E092] Pattern Match Unchecked Warning: tests/warn/i4812.scala:50:13 ------------------------------------------------ +50 | case prev: A => // warn: the type test for A cannot be checked at runtime + | ^ + | the type test for A cannot be checked at runtime because it's a local class + | + | longer explanation available when compiling with `-explain` +-- [E092] Pattern Match Unchecked Warning: tests/warn/i4812.scala:60:11 ------------------------------------------------ +60 | case prev: A => // warn: the type test for A cannot be checked at runtime + | ^ + | the type test for A cannot be checked at runtime because it's a local class + | + | longer explanation available when compiling with `-explain` +-- [E092] Pattern Match Unchecked Warning: tests/warn/i4812.scala:96:11 ------------------------------------------------ +96 | case x: B => // warn: the type test for B cannot be checked at runtime + | ^ + | the type test for B cannot be checked at runtime because it's a local class + | + | longer explanation available when compiling with `-explain` diff --git a/tests/neg/i4812.scala b/tests/warn/i4812.scala similarity index 79% rename from tests/neg/i4812.scala rename to tests/warn/i4812.scala index c6f6dafc656c..520294491acd 100644 --- a/tests/neg/i4812.scala +++ b/tests/warn/i4812.scala @@ -1,11 +1,11 @@ -//> using options -Werror + object Test: var prev: Any = scala.compiletime.uninitialized def test[T](x: T): T = class A(val elem: (T, Boolean)) prev match - case prev: A => // error: the type test for A cannot be checked at runtime + case prev: A => // warn: the type test for A cannot be checked at runtime prev.elem._1 case _ => prev = new A((x, true)) @@ -15,7 +15,7 @@ object Test: abstract class Parent(_elem: T) { def elem: T = _elem } class A extends Parent(x) prev match - case prev: A => // error: the type test for A cannot be checked at runtime + case prev: A => // warn: the type test for A cannot be checked at runtime prev.elem case _ => prev = new A @@ -25,7 +25,7 @@ object Test: class Holder(val elem: T) class A(val holder: Holder) prev match - case prev: A => // error: the type test for A cannot be checked at runtime + case prev: A => // warn: the type test for A cannot be checked at runtime prev.holder.elem case _ => prev = new A(new Holder(x)) @@ -35,7 +35,7 @@ object Test: class Holder(val elem: (Int, (Unit, (T, Boolean)))) class A { var holder: Holder = null } prev match - case prev: A => // error: the type test for A cannot be checked at runtime + case prev: A => // warn: the type test for A cannot be checked at runtime prev.holder.elem._2._2._1 case _ => val a = new A @@ -47,7 +47,7 @@ object Test: def test5(x: U): U = class A(val elem: U) prev match - case prev: A => // error: the type test for A cannot be checked at runtime + case prev: A => // warn: the type test for A cannot be checked at runtime prev.elem case _ => prev = new A(x) @@ -57,7 +57,7 @@ object Test: class A { var b: B = null } class B { var a: A = null; var elem: T = scala.compiletime.uninitialized } prev match - case prev: A => // error: the type test for A cannot be checked at runtime + case prev: A => // warn: the type test for A cannot be checked at runtime prev.b.elem case _ => val a = new A @@ -93,7 +93,7 @@ object Test: val methodCallId = System.nanoTime() class B(val id: Long) extends A prevA match - case x: B => // error: the type test for B cannot be checked at runtime + case x: B => // warn: the type test for B cannot be checked at runtime x.ensuring(x.id == methodCallId, s"Method call id $methodCallId != ${x.id}") case _ => val x = new B(methodCallId) @@ -116,4 +116,4 @@ object Test: def main(args: Array[String]): Unit = test(1) - val x: String = test("") // was: ClassCastException: java.lang.Integer cannot be cast to java.lang.String + val x: String = test("") // was: ClassCastException: java.lang.Integer cannot be cast to java.lang.String \ No newline at end of file diff --git a/tests/warn/i4936b.scala b/tests/warn/i4936b.scala new file mode 100644 index 000000000000..057c90545dbd --- /dev/null +++ b/tests/warn/i4936b.scala @@ -0,0 +1,3 @@ + + +final object Foo // warn diff --git a/tests/neg/i4986b.check b/tests/warn/i4986b.check similarity index 80% rename from tests/neg/i4986b.check rename to tests/warn/i4986b.check index db30dcba8003..f20b467a295d 100644 --- a/tests/neg/i4986b.check +++ b/tests/warn/i4986b.check @@ -1,40 +1,40 @@ --- [E158] Reference Error: tests/neg/i4986b.scala:5:65 ----------------------------------------------------------------- -5 |@implicitNotFound(msg = "Cannot construct a collection of type ${Too} with elements of type ${Elem} based on a collection of type ${From}.") // error // error +-- [E158] Reference Warning: tests/warn/i4986b.scala:5:65 -------------------------------------------------------------- +5 |@implicitNotFound(msg = "Cannot construct a collection of type ${Too} with elements of type ${Elem} based on a collection of type ${From}.") // warn // warn | ^ | Invalid reference to a type variable `Too` found in the annotation argument. | The variable does not occur as a parameter in the scope of type `Meh`. --- [E158] Reference Error: tests/neg/i4986b.scala:5:94 ----------------------------------------------------------------- -5 |@implicitNotFound(msg = "Cannot construct a collection of type ${Too} with elements of type ${Elem} based on a collection of type ${From}.") // error // error +-- [E158] Reference Warning: tests/warn/i4986b.scala:5:94 -------------------------------------------------------------- +5 |@implicitNotFound(msg = "Cannot construct a collection of type ${Too} with elements of type ${Elem} based on a collection of type ${From}.") // warn // warn | ^ | Invalid reference to a type variable `Elem` found in the annotation argument. | The variable does not occur as a parameter in the scope of type `Meh`. --- [E158] Reference Error: tests/neg/i4986b.scala:8:71 ----------------------------------------------------------------- -8 |@implicitNotFound(msg = "Cannot construct a collection of type ${To} ${Elem}.") // error +-- [E158] Reference Warning: tests/warn/i4986b.scala:8:71 -------------------------------------------------------------- +8 |@implicitNotFound(msg = "Cannot construct a collection of type ${To} ${Elem}.") // warn | ^ | Invalid reference to a type variable `Elem` found in the annotation argument. | The variable does not occur as a parameter in the scope of type `Meh2`. --- [E158] Reference Error: tests/neg/i4986b.scala:11:46 ---------------------------------------------------------------- -11 |class C[T](implicit @implicitNotFound("No C[${t}] available") t: T) // error +-- [E158] Reference Warning: tests/warn/i4986b.scala:11:46 ------------------------------------------------------------- +11 |class C[T](implicit @implicitNotFound("No C[${t}] available") t: T) // warn | ^ | Invalid reference to a type variable `t` found in the annotation argument. | The variable does not occur as a parameter in the scope of the constructor of `C`. --- [E158] Reference Error: tests/neg/i4986b.scala:14:54 ---------------------------------------------------------------- -14 | def m[Aaa](implicit @implicitNotFound("I see no C[${Uuh}]") theC: C[Aaa]) = ??? // error +-- [E158] Reference Warning: tests/warn/i4986b.scala:14:54 ------------------------------------------------------------- +14 | def m[Aaa](implicit @implicitNotFound("I see no C[${Uuh}]") theC: C[Aaa]) = ??? // warn | ^ | Invalid reference to a type variable `Uuh` found in the annotation argument. | The variable does not occur as a parameter in the scope of method `m`. --- [E158] Reference Error: tests/neg/i4986b.scala:20:73 ---------------------------------------------------------------- -20 | def m[S](implicit @implicitNotFound("${X} ${Y} ${ Z } ${R} ${S} -- ${XX} ${ZZ} ${ Nix }") i: Int) = ??? // error // error // error +-- [E158] Reference Warning: tests/warn/i4986b.scala:20:73 ------------------------------------------------------------- +20 | def m[S](implicit @implicitNotFound("${X} ${Y} ${ Z } ${R} ${S} -- ${XX} ${ZZ} ${ Nix }") i: Int) = ??? // warn // warn // warn | ^ | Invalid reference to a type variable `XX` found in the annotation argument. | The variable does not occur as a parameter in the scope of method `m`. --- [E158] Reference Error: tests/neg/i4986b.scala:20:79 ---------------------------------------------------------------- -20 | def m[S](implicit @implicitNotFound("${X} ${Y} ${ Z } ${R} ${S} -- ${XX} ${ZZ} ${ Nix }") i: Int) = ??? // error // error // error +-- [E158] Reference Warning: tests/warn/i4986b.scala:20:79 ------------------------------------------------------------- +20 | def m[S](implicit @implicitNotFound("${X} ${Y} ${ Z } ${R} ${S} -- ${XX} ${ZZ} ${ Nix }") i: Int) = ??? // warn // warn // warn | ^ | Invalid reference to a type variable `ZZ` found in the annotation argument. | The variable does not occur as a parameter in the scope of method `m`. --- [E158] Reference Error: tests/neg/i4986b.scala:20:86 ---------------------------------------------------------------- -20 | def m[S](implicit @implicitNotFound("${X} ${Y} ${ Z } ${R} ${S} -- ${XX} ${ZZ} ${ Nix }") i: Int) = ??? // error // error // error +-- [E158] Reference Warning: tests/warn/i4986b.scala:20:86 ------------------------------------------------------------- +20 | def m[S](implicit @implicitNotFound("${X} ${Y} ${ Z } ${R} ${S} -- ${XX} ${ZZ} ${ Nix }") i: Int) = ??? // warn // warn // warn | ^ | Invalid reference to a type variable `Nix` found in the annotation argument. | The variable does not occur as a parameter in the scope of method `m`. diff --git a/tests/neg/i4986b.scala b/tests/warn/i4986b.scala similarity index 75% rename from tests/neg/i4986b.scala rename to tests/warn/i4986b.scala index c726e40fd4d8..6f2a0885090b 100644 --- a/tests/neg/i4986b.scala +++ b/tests/warn/i4986b.scala @@ -1,22 +1,22 @@ -//> using options -Xfatal-warnings + import scala.annotation.implicitNotFound -@implicitNotFound(msg = "Cannot construct a collection of type ${Too} with elements of type ${Elem} based on a collection of type ${From}.") // error // error +@implicitNotFound(msg = "Cannot construct a collection of type ${Too} with elements of type ${Elem} based on a collection of type ${From}.") // warn // warn trait Meh[-From, +To] -@implicitNotFound(msg = "Cannot construct a collection of type ${To} ${Elem}.") // error +@implicitNotFound(msg = "Cannot construct a collection of type ${To} ${Elem}.") // warn trait Meh2[-From, +To] -class C[T](implicit @implicitNotFound("No C[${t}] available") t: T) // error +class C[T](implicit @implicitNotFound("No C[${t}] available") t: T) // warn trait T { - def m[Aaa](implicit @implicitNotFound("I see no C[${Uuh}]") theC: C[Aaa]) = ??? // error + def m[Aaa](implicit @implicitNotFound("I see no C[${Uuh}]") theC: C[Aaa]) = ??? // warn def n[Aaa](implicit @implicitNotFound("I see no C[${Aaa}]") theC: C[Aaa]) = ??? } trait U[X, Y[_], Z[_, ZZ]] { class I[R] { - def m[S](implicit @implicitNotFound("${X} ${Y} ${ Z } ${R} ${S} -- ${XX} ${ZZ} ${ Nix }") i: Int) = ??? // error // error // error + def m[S](implicit @implicitNotFound("${X} ${Y} ${ Z } ${R} ${S} -- ${XX} ${ZZ} ${ Nix }") i: Int) = ??? // warn // warn // warn } -} +} \ No newline at end of file diff --git a/tests/warn/i5013.scala b/tests/warn/i5013.scala new file mode 100644 index 000000000000..9fbc32967b78 --- /dev/null +++ b/tests/warn/i5013.scala @@ -0,0 +1,11 @@ + + +class Foo { + + def foo1: Unit = 2 // warn: A pure expression does nothing in statement position + + def foo2: Unit = { + 3 // warn: A pure expression does nothing in statement position + 4 // warn: A pure expression does nothing in statement position + } +} \ No newline at end of file diff --git a/tests/neg/i5013b.scala b/tests/warn/i5013b.scala similarity index 62% rename from tests/neg/i5013b.scala rename to tests/warn/i5013b.scala index 7ccaf47c12f3..09ce319e0a88 100644 --- a/tests/neg/i5013b.scala +++ b/tests/warn/i5013b.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings + class Foo { @@ -11,8 +11,9 @@ class Foo { val c: Unit = () - def foo1: Unit = a // error: A pure expression does nothing in statement position + def foo1: Unit = a // warn: A pure expression does nothing in statement position def foo2: Unit = b def foo3: Unit = c // Not addapted to { c; () } and hence c is not a statement } + diff --git a/tests/neg/i5077.scala b/tests/warn/i5077.scala similarity index 89% rename from tests/neg/i5077.scala rename to tests/warn/i5077.scala index d705ffe52dd9..404b2cf5a639 100644 --- a/tests/neg/i5077.scala +++ b/tests/warn/i5077.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings -Wimplausible-patterns +//> using options -Wimplausible-patterns trait Is[A] case object IsInt extends Is[Int] case object IsString extends Is[String] @@ -12,7 +12,7 @@ def Test = { // Case 1: error c_string match { - case C(IsInt, _) => println(s"An Int") // error + case C(IsInt, _) => println(s"An Int") // warn case C(IsString, s) => println(s"A String with length ${s.length}") case _ => println("No match") } diff --git a/tests/neg/i6190b.check b/tests/warn/i6190b.check similarity index 65% rename from tests/neg/i6190b.check rename to tests/warn/i6190b.check index 5d4dbd7c24cb..eecf7bbcf13e 100644 --- a/tests/neg/i6190b.check +++ b/tests/warn/i6190b.check @@ -1,4 +1,4 @@ --- Error: tests/neg/i6190b.scala:5:29 ---------------------------------------------------------------------------------- -5 |def foo = List("1", "2").map(Rule) // error +-- Warning: tests/warn/i6190b.scala:5:29 ------------------------------------------------------------------------------- +5 |def foo = List("1", "2").map(Rule) // warn | ^^^^ | The method `apply` is inserted. The auto insertion will be deprecated, please write `Rule.apply` explicitly. diff --git a/tests/warn/i6190b.scala b/tests/warn/i6190b.scala new file mode 100644 index 000000000000..a10006516c6f --- /dev/null +++ b/tests/warn/i6190b.scala @@ -0,0 +1,6 @@ + + +case class Rule(name: String) + +def foo = List("1", "2").map(Rule) // warn + diff --git a/tests/neg/i7314.scala b/tests/warn/i7314.scala similarity index 62% rename from tests/neg/i7314.scala rename to tests/warn/i7314.scala index b865f2ad881b..4d0d525542bf 100644 --- a/tests/neg/i7314.scala +++ b/tests/warn/i7314.scala @@ -1,11 +1,11 @@ -//> using options -Xfatal-warnings -source future +//> using options -source future @main def Test = // conversion out of the opaque type: val imm1 = IArray(1,2,3) // supposedly immutable println(imm1(0)) // 1 imm1 match { - case a: Array[Int] => // error: should not be scrutinized + case a: Array[Int] => // warn: should not be scrutinized a(0) = 0 } println(imm1(0)) // 0 diff --git a/tests/neg/i7821.scala b/tests/warn/i7821.scala similarity index 75% rename from tests/neg/i7821.scala rename to tests/warn/i7821.scala index 5275c06e487f..6ac46ef730bb 100644 --- a/tests/neg/i7821.scala +++ b/tests/warn/i7821.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings + object XObject { opaque type X = Int @@ -16,7 +16,7 @@ object MyXObject { def anX: MyX = XObject.anX given ops: Object with { - extension (x: MyX) def + (y: MyX): MyX = x + y // error: warring: Infinite recursive call + extension (x: MyX) def + (y: MyX): MyX = x + y // warn: warring: Infinite recursive call } } diff --git a/tests/warn/i7821b.scala b/tests/warn/i7821b.scala new file mode 100644 index 000000000000..db3de3f86e2f --- /dev/null +++ b/tests/warn/i7821b.scala @@ -0,0 +1,13 @@ + + +object Test { + + { def f(x: Int, y: Int): Int = f(x, y) } // warn + { def f(x: Int, y: Int): Int = { f(x, y) } } // warn + { def f(x: Int, y: Int): Int = f(y, x) } // warn + { def f(x: Int, y: Int): Int = f(x, x) } // warn + { def f(x: Int, y: Int): Int = f(1, 1) } // warn + { def f(x: Int, y: Int): Int = { val a = 3; f(a, 1) } } // warn + { def f(x: Int): Int = f(1) } // warn + +} \ No newline at end of file diff --git a/tests/neg/i8427.scala b/tests/warn/i8427.scala similarity index 63% rename from tests/neg/i8427.scala rename to tests/warn/i8427.scala index 3db449bed41c..61ea2eabb79a 100644 --- a/tests/neg/i8427.scala +++ b/tests/warn/i8427.scala @@ -1,6 +1,6 @@ -//> using options -Xfatal-warnings -@SerialVersionUID(1L) // error + +@SerialVersionUID(1L) // warn trait T object Test { diff --git a/tests/warn/i8781b.scala b/tests/warn/i8781b.scala new file mode 100644 index 000000000000..455cd49b927a --- /dev/null +++ b/tests/warn/i8781b.scala @@ -0,0 +1,8 @@ + + +object Test: + + println((3: Boolean | Int).isInstanceOf[Boolean]) + + println(3.isInstanceOf[Boolean]) // warn + diff --git a/tests/neg/i8922b.scala b/tests/warn/i8922b.scala similarity index 97% rename from tests/neg/i8922b.scala rename to tests/warn/i8922b.scala index 9e615a8d5b58..f167eea005c5 100644 --- a/tests/neg/i8922b.scala +++ b/tests/warn/i8922b.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings + case class Token(tokenType: TokenType, lexeme: StringV, line: IntV) @@ -33,7 +33,7 @@ object Interpreter { case Binary(left, op, right) => val l = eval(left) val r = eval(right) - (l, r, op.tokenType) match { // error + (l, r, op.tokenType) match { // warn case (l: DoubleV, r: DoubleV, PLUS) => ??? case (l: IntV, r: IntV, PLUS) => ??? case (l: DoubleV, r: IntV, PLUS) => ??? @@ -75,4 +75,4 @@ object Interpreter { } } -} \ No newline at end of file +} diff --git a/tests/warn/i9166.scala b/tests/warn/i9166.scala new file mode 100644 index 000000000000..34a42987f6aa --- /dev/null +++ b/tests/warn/i9166.scala @@ -0,0 +1,8 @@ +//> using options -Wimplausible-patterns +object UnitTest extends App { + def foo(m: Unit) = m match { + case runtime.BoxedUnit.UNIT => println("ok") // warn + } + foo(()) +} + diff --git a/tests/neg/i9241.scala b/tests/warn/i9241.scala similarity index 64% rename from tests/neg/i9241.scala rename to tests/warn/i9241.scala index e7c959fc9ee2..ed1db2df0c8e 100644 --- a/tests/neg/i9241.scala +++ b/tests/warn/i9241.scala @@ -1,10 +1,10 @@ -//> using options -Xfatal-warnings + class Foo { - def unary_~() : Foo = this // error - def unary_-(using Int)(): Foo = this // error - def unary_+()(implicit i: Int): Foo = this // error - def unary_![T](): Foo = this // error + def unary_~() : Foo = this // warn + def unary_-(using Int)(): Foo = this // warn + def unary_+()(implicit i: Int): Foo = this // warn + def unary_![T](): Foo = this // warn } class Bar { @@ -17,27 +17,27 @@ class Bar { final class Baz private (val x: Int) extends AnyVal { def unary_- : Baz = ??? def unary_+[T] : Baz = ??? - def unary_!() : Baz = ??? // error + def unary_!() : Baz = ??? // warn def unary_~(using Int) : Baz = ??? } extension (x: Int) def unary_- : Int = ??? def unary_+[T] : Int = ??? - def unary_!() : Int = ??? // error + def unary_!() : Int = ??? // warn def unary_~(using Int) : Int = ??? end extension extension [T](x: Short) def unary_- : Int = ??? def unary_+[U] : Int = ??? - def unary_!() : Int = ??? // error + def unary_!() : Int = ??? // warn def unary_~(using Int) : Int = ??? end extension extension (using Int)(x: Byte) def unary_- : Int = ??? def unary_+[U] : Int = ??? - def unary_!() : Int = ??? // error + def unary_!() : Int = ??? // warn def unary_~(using Int) : Int = ??? -end extension +end extension \ No newline at end of file diff --git a/tests/neg/i9266.check b/tests/warn/i9266.check similarity index 71% rename from tests/neg/i9266.check rename to tests/warn/i9266.check index bd80a017da02..90dfe43bd2b2 100644 --- a/tests/neg/i9266.check +++ b/tests/warn/i9266.check @@ -1,5 +1,5 @@ --- Error: tests/neg/i9266.scala:5:22 ----------------------------------------------------------------------------------- -5 |def test = { implicit x: Int => x + x } // error +-- Migration Warning: tests/warn/i9266.scala:5:22 ---------------------------------------------------------------------- +5 |def test = { implicit x: Int => x + x } // warn | ^ | This syntax is no longer supported; parameter needs to be enclosed in (...) | This construct can be rewritten automatically under -rewrite -source future-migration. diff --git a/tests/warn/i9266.scala b/tests/warn/i9266.scala new file mode 100644 index 000000000000..c621e9e20b99 --- /dev/null +++ b/tests/warn/i9266.scala @@ -0,0 +1,6 @@ + + +import language.`future-migration` + +def test = { implicit x: Int => x + x } // warn + diff --git a/tests/neg/i9408a.check b/tests/warn/i9408a.check similarity index 76% rename from tests/neg/i9408a.check rename to tests/warn/i9408a.check index d9deb9cddaf7..ed2e94090cae 100644 --- a/tests/neg/i9408a.check +++ b/tests/warn/i9408a.check @@ -1,24 +1,24 @@ --- Error: tests/neg/i9408a.scala:18:20 --------------------------------------------------------------------------------- -18 | val length: Int = "qwerty" // error +-- Migration Warning: tests/warn/i9408a.scala:18:20 -------------------------------------------------------------------- +18 | val length: Int = "qwerty" // warn | ^^^^^^^^ |The conversion (Test3.implicitLength : String => Int) will not be applied implicitly here in Scala 3 because only implicit methods and instances of Conversion class will continue to work as implicit views. --- Error: tests/neg/i9408a.scala:23:20 --------------------------------------------------------------------------------- -23 | val length: Int = "qwerty" // error +-- Migration Warning: tests/warn/i9408a.scala:23:20 -------------------------------------------------------------------- +23 | val length: Int = "qwerty" // warn | ^^^^^^^^ |The conversion (Test4.implicitLength : => String => Int) will not be applied implicitly here in Scala 3 because only implicit methods and instances of Conversion class will continue to work as implicit views. --- Error: tests/neg/i9408a.scala:28:20 --------------------------------------------------------------------------------- -28 | val length: Int = "qwerty" // error +-- Migration Warning: tests/warn/i9408a.scala:28:20 -------------------------------------------------------------------- +28 | val length: Int = "qwerty" // warn | ^^^^^^^^ |The conversion (Test5.implicitLength : [A]: String => Int) will not be applied implicitly here in Scala 3 because only implicit methods and instances of Conversion class will continue to work as implicit views. --- Error: tests/neg/i9408a.scala:33:20 --------------------------------------------------------------------------------- -33 | val length: Int = "qwerty" // error +-- Migration Warning: tests/warn/i9408a.scala:33:20 -------------------------------------------------------------------- +33 | val length: Int = "qwerty" // warn | ^^^^^^^^ |The conversion (Test6.implicitLength : Map[String, Int]) will not be applied implicitly here in Scala 3 because only implicit methods and instances of Conversion class will continue to work as implicit views. --- Error: tests/neg/i9408a.scala:37:60 --------------------------------------------------------------------------------- -37 | implicit def a2int[A](a: A)(implicit ev: A => Int): Int = a // error +-- Migration Warning: tests/warn/i9408a.scala:37:60 -------------------------------------------------------------------- +37 | implicit def a2int[A](a: A)(implicit ev: A => Int): Int = a // warn | ^ |The conversion (ev : A => Int) will not be applied implicitly here in Scala 3 because only implicit methods and instances of Conversion class will continue to work as implicit views. --- Error: tests/neg/i9408a.scala:61:2 ---------------------------------------------------------------------------------- -61 | 123.foo // error +-- Migration Warning: tests/warn/i9408a.scala:61:2 --------------------------------------------------------------------- +61 | 123.foo // warn | ^^^ |The conversion (Test11.a2foo : [A]: A => Test11.Foo) will not be applied implicitly here in Scala 3 because only implicit methods and instances of Conversion class will continue to work as implicit views. diff --git a/tests/neg/i9408a.scala b/tests/warn/i9408a.scala similarity index 88% rename from tests/neg/i9408a.scala rename to tests/warn/i9408a.scala index 594417ec3215..64b58ff59550 100644 --- a/tests/neg/i9408a.scala +++ b/tests/warn/i9408a.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings + import language.`3.0-migration` import scala.language.implicitConversions @@ -15,26 +15,26 @@ object Test2 { object Test3 { implicit val implicitLength: String => Int = _.length - val length: Int = "qwerty" // error + val length: Int = "qwerty" // warn } object Test4 { implicit def implicitLength: String => Int = _.length - val length: Int = "qwerty" // error + val length: Int = "qwerty" // warn } object Test5 { implicit def implicitLength[A]: String => Int = _.length - val length: Int = "qwerty" // error + val length: Int = "qwerty" // warn } object Test6 { implicit val implicitLength: Map[String, Int] = Map("qwerty" -> 6) - val length: Int = "qwerty" // error + val length: Int = "qwerty" // warn } object Test7 { - implicit def a2int[A](a: A)(implicit ev: A => Int): Int = a // error + implicit def a2int[A](a: A)(implicit ev: A => Int): Int = a // warn } object Test8 { @@ -58,7 +58,7 @@ object Test11 { def foo = "foo" } implicit def a2foo[A]: A => Foo = _ => new Foo {} - 123.foo // error + 123.foo // warn } object Test12 { @@ -85,4 +85,4 @@ object Test15 { implicit def implicitSeq[A]: Seq[A] = ??? def foo(implicit ev: Seq[Int]): Unit = ??? foo -} +} \ No newline at end of file diff --git a/tests/neg/i9740.check b/tests/warn/i9740.check similarity index 76% rename from tests/neg/i9740.check rename to tests/warn/i9740.check index 359603a2863a..7d41bab8ec50 100644 --- a/tests/neg/i9740.check +++ b/tests/warn/i9740.check @@ -1,11 +1,11 @@ --- [E186] Type Error: tests/neg/i9740.scala:10:9 ----------------------------------------------------------------------- -10 | case RecoveryCompleted => println("Recovery completed") // error +-- [E186] Type Warning: tests/warn/i9740.scala:10:9 -------------------------------------------------------------------- +10 | case RecoveryCompleted => println("Recovery completed") // warn | ^^^^^^^^^^^^^^^^^ | Implausible pattern: | RecoveryCompleted could match selector of type object TypedRecoveryCompleted | only if there is an `equals` method identifying elements of the two types. --- [E186] Type Error: tests/neg/i9740.scala:15:9 ----------------------------------------------------------------------- -15 | case RecoveryCompleted => // error +-- [E186] Type Warning: tests/warn/i9740.scala:15:9 -------------------------------------------------------------------- +15 | case RecoveryCompleted => // warn | ^^^^^^^^^^^^^^^^^ | Implausible pattern: | RecoveryCompleted could match selector of type TypedRecoveryCompleted diff --git a/tests/neg/i9740.scala b/tests/warn/i9740.scala similarity index 78% rename from tests/neg/i9740.scala rename to tests/warn/i9740.scala index 6222298df48b..fc330df4d6a9 100644 --- a/tests/neg/i9740.scala +++ b/tests/warn/i9740.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings -Wimplausible-patterns +//> using options -Wimplausible-patterns abstract class RecoveryCompleted object RecoveryCompleted extends RecoveryCompleted @@ -7,11 +7,11 @@ object TypedRecoveryCompleted extends TypedRecoveryCompleted class Test { TypedRecoveryCompleted match { - case RecoveryCompleted => println("Recovery completed") // error + case RecoveryCompleted => println("Recovery completed") // warn case TypedRecoveryCompleted => println("Typed recovery completed") } def foo(x: TypedRecoveryCompleted) = x match - case RecoveryCompleted => // error + case RecoveryCompleted => // warn case TypedRecoveryCompleted => -} +} \ No newline at end of file diff --git a/tests/neg/i9740b.scala b/tests/warn/i9740b.scala similarity index 75% rename from tests/neg/i9740b.scala rename to tests/warn/i9740b.scala index dcd9a1d6a474..632308e3322d 100644 --- a/tests/neg/i9740b.scala +++ b/tests/warn/i9740b.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings -Wimplausible-patterns +//> using options -Wimplausible-patterns enum Recovery: case RecoveryCompleted @@ -10,11 +10,11 @@ import TypedRecovery.* class Test { TypedRecoveryCompleted match { - case RecoveryCompleted => println("Recovery completed") // error + case RecoveryCompleted => println("Recovery completed") // warn case TypedRecoveryCompleted => println("Typed recovery completed") } def foo(x: TypedRecovery) = x match - case RecoveryCompleted => // error + case RecoveryCompleted => // warn case TypedRecoveryCompleted => -} +} \ No newline at end of file diff --git a/tests/neg/i9740c.scala b/tests/warn/i9740c.scala similarity index 80% rename from tests/neg/i9740c.scala rename to tests/warn/i9740c.scala index c6a3a1380f1d..8ddf87adf46b 100644 --- a/tests/neg/i9740c.scala +++ b/tests/warn/i9740c.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings -Wimplausible-patterns +//> using options -Wimplausible-patterns sealed trait Exp[T] case class IntExp(x: Int) extends Exp[Int] case class StrExp(x: String) extends Exp[String] @@ -12,6 +12,7 @@ class Foo { def bar[A <: Txn[A]](x: Exp[A]): Unit = x match case IntExp(x) => case StrExp(x) => - case UnitExp => // error + case UnitExp => // warn case Obj(o) => } + diff --git a/tests/neg/i9740d.scala b/tests/warn/i9740d.scala similarity index 67% rename from tests/neg/i9740d.scala rename to tests/warn/i9740d.scala index 6f3cc3be02e2..87c7dc264afa 100644 --- a/tests/neg/i9740d.scala +++ b/tests/warn/i9740d.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings -Wimplausible-patterns +//> using options -Wimplausible-patterns sealed trait Exp[T] case class IntExp(x: Int) extends Exp[Int] @@ -8,6 +8,6 @@ object UnitExp extends Exp[Unit] class Foo[U <: Int, T <: U] { def bar[A <: T](x: Exp[A]): Unit = x match case IntExp(x) => - case StrExp(x) => - case UnitExp => // error + case StrExp(x) => // warn + case UnitExp => // warn implausible pattern } diff --git a/tests/warn/i9751.scala b/tests/warn/i9751.scala new file mode 100644 index 000000000000..284070723474 --- /dev/null +++ b/tests/warn/i9751.scala @@ -0,0 +1,11 @@ + + +def f(): Unit = { + () // warn + () +} + +inline def g(): Unit = { + () // warn + () +} \ No newline at end of file diff --git a/tests/neg/i9776.scala b/tests/warn/i9776.scala similarity index 84% rename from tests/neg/i9776.scala rename to tests/warn/i9776.scala index b05488810416..93b7cce98fef 100644 --- a/tests/neg/i9776.scala +++ b/tests/warn/i9776.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings + import scala.annotation.switch @@ -12,7 +12,7 @@ object Fruit { case object Orange extends Fruit def isCitrus(fruit: Fruit): Boolean = - (fruit: @switch) match { // error Could not emit switch for @switch annotated match + (fruit: @switch) match { // warn Could not emit switch for @switch annotated match case Orange => true case Lemon => true case Lime => true @@ -37,7 +37,7 @@ object TaggedFruit { } def isCitrus(fruit: TaggedFruit): Boolean = - (fruit.tag: @switch) match { // error Could not emit switch for @switch annotated match + (fruit.tag: @switch) match { // warn Could not emit switch for @switch annotated match case Apple.tag => true case 2 => true case 3 => true @@ -58,4 +58,4 @@ object TaggedFruit { case 2 => true case Apple.tag => true } -} +} \ No newline at end of file diff --git a/tests/neg/i9880.scala b/tests/warn/i9880.scala similarity index 81% rename from tests/neg/i9880.scala rename to tests/warn/i9880.scala index f99fae25e5dc..68775e7646a5 100644 --- a/tests/neg/i9880.scala +++ b/tests/warn/i9880.scala @@ -1,9 +1,9 @@ -//> using options -Xfatal-warnings + opaque type Bytes = Array[Byte] object Bytes: extension (self: Bytes) - def size: Int = (self: Array[Byte]).size // error + def size: Int = (self: Array[Byte]).size // warn // @@ -20,7 +20,7 @@ object Module2: object Gen: extension [A](self: Gen[A]) def map[B](f: A => B): Gen[B] = - self.map(f) // error + self.map(f) // warn // @@ -29,4 +29,4 @@ class Sym(val owner: Sym) extension (sym: Sym) def isSomething: Boolean = false def isFoo: Boolean = sym.isSomething && sym.owner.isFoo // was: Infinite loop in function body - def isBar: Boolean = sym.isSomething || sym.owner.isBar // was: Infinite loop in function body + def isBar: Boolean = sym.isSomething || sym.owner.isBar // was: Infinite loop in function body \ No newline at end of file diff --git a/tests/warn/implicit-conversions-old.scala b/tests/warn/implicit-conversions-old.scala new file mode 100644 index 000000000000..24e1124015e3 --- /dev/null +++ b/tests/warn/implicit-conversions-old.scala @@ -0,0 +1,25 @@ +//> using options -feature + +class A +class B + +object A { + + implicit def a2b(x: A): B = ??? // warn under -Xfatal-warnings -feature + + implicit def b2a(x: B): A = ??? // warn under -Xfatal-warnings -feature +} + +class C + +object D { + implicit def a2c(x: A): C = ??? // warn under -Xfatal-warnings -feature +} + +object Test { + import D.* + + val x1: A = new B + val x2: B = new A // ok, since it's an old-style comversion + val x3: C = new A // ok, since it's an old-style comversion +} \ No newline at end of file diff --git a/tests/neg/implicit-conversions.scala b/tests/warn/implicit-conversions.scala similarity index 55% rename from tests/neg/implicit-conversions.scala rename to tests/warn/implicit-conversions.scala index ead8c5ac7646..946d0c96fd5a 100644 --- a/tests/neg/implicit-conversions.scala +++ b/tests/warn/implicit-conversions.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings -feature +//> using options -feature class A class B @@ -25,7 +25,7 @@ object D { object Test { import D.given - val x1: A = new B // error under -Xfatal-warnings -feature - val x2: B = new A // error under -Xfatal-warnings -feature - val x3: C = new A // error under -Xfatal-warnings -feature + val x1: A = new B // warn under -Xfatal-warnings -feature + val x2: B = new A // warn under -Xfatal-warnings -feature + val x3: C = new A // warn under -Xfatal-warnings -feature } \ No newline at end of file diff --git a/tests/neg/inline-givens.scala b/tests/warn/inline-givens.scala similarity index 57% rename from tests/neg/inline-givens.scala rename to tests/warn/inline-givens.scala index 3e388de2ce8b..5ab4fd65fdc9 100644 --- a/tests/neg/inline-givens.scala +++ b/tests/warn/inline-givens.scala @@ -1,16 +1,15 @@ -//> using options -Xfatal-warnings + class Item(x: String) inline given a: Conversion[String, Item] = - Item(_) // error + Item(_) // warn inline given b: Conversion[String, Item] = - (x => Item(x)) // error + (x => Item(x)) // warn inline given c: Conversion[String, Item] = - { x => Item(x) } // error + { x => Item(x) } // warn inline given d: Conversion[String, Item] with - def apply(x: String) = Item(x) // ok - + def apply(x: String) = Item(x) // ok \ No newline at end of file diff --git a/tests/warn/main-functions-nameclash.scala b/tests/warn/main-functions-nameclash.scala new file mode 100644 index 000000000000..bc0fe64379d4 --- /dev/null +++ b/tests/warn/main-functions-nameclash.scala @@ -0,0 +1,5 @@ + + +object foo { + @main def foo(x: Int) = () // warn: class foo and object foo produce classes that overwrite one another +} diff --git a/tests/neg/manifest-summoning-b.check b/tests/warn/manifest-summoning-b.check similarity index 73% rename from tests/neg/manifest-summoning-b.check rename to tests/warn/manifest-summoning-b.check index bb63eebb555f..590b27ddbd98 100644 --- a/tests/neg/manifest-summoning-b.check +++ b/tests/warn/manifest-summoning-b.check @@ -1,12 +1,12 @@ --- Error: tests/neg/manifest-summoning-b.scala:3:34 -------------------------------------------------------------------- -3 |val foo = manifest[List[? <: Int]] // error +-- Deprecation Warning: tests/warn/manifest-summoning-b.scala:3:34 ----------------------------------------------------- +3 |val foo = manifest[List[? <: Int]] // warn | ^ | Compiler synthesis of Manifest and OptManifest is deprecated, instead | replace with the type `scala.reflect.ClassTag[List[? <: Int]]`. | Alternatively, consider using the new metaprogramming features of Scala 3, | see https://docs.scala-lang.org/scala3/reference/metaprogramming.html --- Error: tests/neg/manifest-summoning-b.scala:4:41 -------------------------------------------------------------------- -4 |val bar = optManifest[Array[? <: String]] // error +-- Deprecation Warning: tests/warn/manifest-summoning-b.scala:4:41 ----------------------------------------------------- +4 |val bar = optManifest[Array[? <: String]] // warn | ^ | Compiler synthesis of Manifest and OptManifest is deprecated, instead | replace with the type `scala.reflect.ClassTag[Array[? <: String]]`. diff --git a/tests/warn/manifest-summoning-b.scala b/tests/warn/manifest-summoning-b.scala new file mode 100644 index 000000000000..18ddec1250b5 --- /dev/null +++ b/tests/warn/manifest-summoning-b.scala @@ -0,0 +1,4 @@ +//> using options -deprecation + +val foo = manifest[List[? <: Int]] // warn +val bar = optManifest[Array[? <: String]] // warn \ No newline at end of file diff --git a/tests/warn/matchable.scala b/tests/warn/matchable.scala new file mode 100644 index 000000000000..8adcdcf1c90a --- /dev/null +++ b/tests/warn/matchable.scala @@ -0,0 +1,28 @@ +//> using options -source future + +def foo[T](x: T): Matchable = + println(x.getClass()) // ok + println(x.isInstanceOf[Int]) // ok + x match + case x: Int => // warn: should not be scrutinized + println("int") + x + case x: String => // warn: should not be scrutinized + println("string") + x + List(x) match + case (x: Int) :: Nil => // warn: should not be scrutinized + println("int") + x + case List(x: String) => // warn: should not be scrutinized + println("string") + x + case List(y :: Nil) => // warn: should not be scrutinized + y :: Nil + case _ => + x // warn: should not be scrutinized + +@main def Test = + val x: Matchable = foo(1) + val y: Matchable = foo("hello") + assert(x != y) \ No newline at end of file diff --git a/tests/neg/newline-braces.scala b/tests/warn/newline-braces.scala similarity index 55% rename from tests/neg/newline-braces.scala rename to tests/warn/newline-braces.scala index afe7731f3095..9ec2961ee30d 100644 --- a/tests/neg/newline-braces.scala +++ b/tests/warn/newline-braces.scala @@ -1,8 +1,9 @@ -//> using options -source 3.0-migration -Xfatal-warnings +//> using options -source 3.0-migration def f: List[Int] = { List(1, 2, 3).map // no newline inserted here in Scala-2 compat mode - { x => // error (migration) + { x => // warn (migration) x + 1 } } + diff --git a/tests/neg/nonunit-statement.scala b/tests/warn/nonunit-statement.scala similarity index 80% rename from tests/neg/nonunit-statement.scala rename to tests/warn/nonunit-statement.scala index 94346031077c..f90deb647d6e 100644 --- a/tests/neg/nonunit-statement.scala +++ b/tests/warn/nonunit-statement.scala @@ -1,4 +1,5 @@ -//> using options -Xfatal-warnings -Wnonunit-statement -Wvalue-discard -source:3.3 +//> using options -Wnonunit-statement -Wvalue-discard -source:3.3 + import collection.ArrayOps import collection.mutable.{ArrayBuilder, LinkedHashSet, ListBuffer} import concurrent._ @@ -9,38 +10,38 @@ class C { def c = { def improved = Future(42) def stale = Future(27) - improved // error + improved // warn stale } } class D { def d = { class E - new E().toString // error + new E().toString // warn new E().toString * 2 } } class F { import ExecutionContext.Implicits._ - Future(42) // error + Future(42) // warn } // unused template expression uses synthetic method of class case class K(s: String) { - copy() // error + copy() // warn } // mutations returning this are ok class Mutate { val b = ListBuffer.empty[Int] b += 42 // nowarn, returns this.type val xs = List(42) - 27 +: xs // error + 27 +: xs // warn def f(x: Int): this.type = this def g(): Unit = f(42) // nowarn } // some uninteresting expressions may warn for other reasons class WhoCares { - null // error for purity + null // warn for purity ??? // nowarn for impurity } // explicit Unit ascription to opt out of warning, even for funky applies @@ -50,15 +51,15 @@ class Absolution { // Future(42): Unit // nowarn { F(42)(ctx) }: Unit where annot is on F(42) // f(42): Unit // nowarn } -// warn uni-branched unless user disables it with -Wnonunit-if:false + class Boxed[A](a: A) { def isEmpty = false def foreach[U](f: A => U): Unit = - if (!isEmpty) f(a) // error (if) + if (!isEmpty) f(a) // warn (if) def forall(f: A => Boolean): Unit = if (!isEmpty) { println(".") - f(a) // error (if) + f(a) // warn (if) } def take(p: A => Boolean): Option[A] = { while (isEmpty || !p(a)) () @@ -69,20 +70,20 @@ class Unibranch[A, B] { def runWith[U](action: B => U): A => Boolean = { x => val z = null.asInstanceOf[B] val fellback = false - if (!fellback) action(z) // error (if) + if (!fellback) action(z) // warn (if) !fellback } def f(i: Int): Int = { def g = 17 if (i < 42) { - g // error block statement + g // warn block statement println("uh oh") - g // error (if) + g // warn (if) } while (i < 42) { - g // error + g // warn println("uh oh") - g // error + g // warn } 42 } @@ -92,7 +93,7 @@ class Dibranch { def j: Int = ??? def f(b: Boolean): Int = { // if-expr might have an uninteresting LUB - if (b) { // error, at least one branch looks interesting + if (b) { // warn, at least one branch looks interesting println("true") i } @@ -112,7 +113,7 @@ class Next[A] { class Setting[A] { def set = LinkedHashSet.empty[A] def f(a: A): Unit = { - set += a // error because cannot know whether the `set` was supposed to be consumed or assigned + set += a // warn because cannot know whether the `set` was supposed to be consumed or assigned println(set) } } @@ -122,27 +123,27 @@ class Strung { def iterator = Iterator.empty[String] def addString(b: StringBuilder, start: String, sep: String, end: String): StringBuilder = { val jsb = b.underlying - if (start.length != 0) jsb.append(start) // error (value-discard) + if (start.length != 0) jsb.append(start) // warn (value-discard) val it = iterator if (it.hasNext) { jsb.append(it.next()) while (it.hasNext) { jsb.append(sep) // nowarn (java) - jsb.append(it.next()) // error (value-discard) + jsb.append(it.next()) // warn (value-discard) } } - if (end.length != 0) jsb.append(end) // error (value-discard) + if (end.length != 0) jsb.append(end) // warn (value-discard) b } def f(b: java.lang.StringBuilder, it: Iterator[String]): String = { while (it.hasNext) { b.append("\n") // nowarn (java) - b.append(it.next()) // error (value-discard) + b.append(it.next()) // warn (value-discard) } b.toString } def g(b: java.lang.StringBuilder, it: Iterator[String]): String = { - while (it.hasNext) it.next() // error + while (it.hasNext) it.next() // warn b.toString } } @@ -195,4 +196,4 @@ class Depends { f(d) () } -} +} \ No newline at end of file diff --git a/tests/warn/old-syntax.scala b/tests/warn/old-syntax.scala new file mode 100644 index 000000000000..d584e3692a0a --- /dev/null +++ b/tests/warn/old-syntax.scala @@ -0,0 +1,5 @@ +//> using options -deprecation + +val f = (x: Int) ⇒ x + 1 // warn + +val list = for (n ← List(42)) yield n + 1 // warn \ No newline at end of file diff --git a/tests/neg/opaque-match.scala b/tests/warn/opaque-match.scala similarity index 63% rename from tests/neg/opaque-match.scala rename to tests/warn/opaque-match.scala index 59d0836fb2a3..453d525bac2c 100644 --- a/tests/neg/opaque-match.scala +++ b/tests/warn/opaque-match.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings + case class C() @@ -12,17 +12,13 @@ def Test[T] = O.x match case _: C => ??? // ok C() match - case _: O.T => ??? // error + case _: O.T => ??? // warn C() match - case _: T => ??? // error + case _: T => ??? // warn (??? : Any) match - case _: List[O.T] => ??? // error + case _: List[O.T] => ??? // warn (??? : Any) match case _: List[O.T @unchecked] => ??? // OK (??? : Any) match - case _: List[T] => ??? // error - - - - + case _: List[T] => ??? // warn \ No newline at end of file diff --git a/tests/neg-deep-subtype/or-type-trees.scala b/tests/warn/or-type-trees.scala similarity index 79% rename from tests/neg-deep-subtype/or-type-trees.scala rename to tests/warn/or-type-trees.scala index d0338ffe6066..0e8569576796 100644 --- a/tests/neg-deep-subtype/or-type-trees.scala +++ b/tests/warn/or-type-trees.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings + object Test1 { trait Tree @@ -9,7 +9,7 @@ object Test1 { def foo2(myTree: Tree | (Context => Tree)) = myTree match - case treeFn: (Context => Tree) => // error + case treeFn: (Context => Tree) => // warn case _ => def foo3(myTree: Tree | (Context => Tree)) = @@ -25,12 +25,12 @@ object Test2 { trait Type def foo1(myTree: Tree[Type] | (Context => Tree[Type])) = - println(myTree.isInstanceOf[Tree[Type]]) // error + println(myTree.isInstanceOf[Tree[Type]]) // warn /* class DummyTree extends Tree[Nothing] with (Context => Tree[Type]) */ def foo2(myTree: Tree[Type] | (Context => Tree[Type])) = myTree match - case treeFn: (Context => Tree[Type]) => // error + case treeFn: (Context => Tree[Type]) => // warn case _ => def foo3(myTree: Tree[Type] | (Context => Tree[Type])) = diff --git a/tests/warn/ovlazy.scala b/tests/warn/ovlazy.scala new file mode 100644 index 000000000000..1dfa284a00c9 --- /dev/null +++ b/tests/warn/ovlazy.scala @@ -0,0 +1,9 @@ +//> using options -source 3.0-migration + +class A { + val x: Int = 1 +} +class B extends A { + override lazy val x: Int = 2 // warn +} + diff --git a/tests/neg/private-this-3.4.check b/tests/warn/private-this-3.4.check similarity index 74% rename from tests/neg/private-this-3.4.check rename to tests/warn/private-this-3.4.check index 29c2fe909ede..29cdcfac6477 100644 --- a/tests/neg/private-this-3.4.check +++ b/tests/warn/private-this-3.4.check @@ -1,11 +1,11 @@ --- Error: tests/neg/private-this-3.4.scala:6:16 ------------------------------------------------------------------------ -6 | private[this] def foo: Int = ??? // error: migration warning +-- Warning: tests/warn/private-this-3.4.scala:4:16 --------------------------------------------------------------------- +4 | private[this] def foo: Int = ??? // warn: migration warning | ^ | The [this] qualifier will be deprecated in the future; it should be dropped. | See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html | This construct can be rewritten automatically under -rewrite -source 3.4-migration. --- Error: tests/neg/private-this-3.4.scala:7:18 ------------------------------------------------------------------------ -7 | protected[this] def bar: Int = ??? // error: migration warning +-- Warning: tests/warn/private-this-3.4.scala:5:18 --------------------------------------------------------------------- +5 | protected[this] def bar: Int = ??? // warn: migration warning | ^ | The [this] qualifier will be deprecated in the future; it should be dropped. | See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html diff --git a/tests/warn/private-this-3.4.scala b/tests/warn/private-this-3.4.scala new file mode 100644 index 000000000000..1270eba116bc --- /dev/null +++ b/tests/warn/private-this-3.4.scala @@ -0,0 +1,5 @@ +import scala.language.`3.4` + +class Foo: + private[this] def foo: Int = ??? // warn: migration warning + protected[this] def bar: Int = ??? // warn: migration warning diff --git a/tests/warn/private-this-future-migration.scala b/tests/warn/private-this-future-migration.scala new file mode 100644 index 000000000000..d719187e534a --- /dev/null +++ b/tests/warn/private-this-future-migration.scala @@ -0,0 +1,5 @@ +import scala.language.`future-migration` + +class Foo: + private[this] def foo: Int = ??? // warn: migration warning + protected[this] def bar: Int = ??? // warn: migration warning diff --git a/tests/warn/quote-simple-hole.scala b/tests/warn/quote-simple-hole.scala new file mode 100644 index 000000000000..f23d2c0535c4 --- /dev/null +++ b/tests/warn/quote-simple-hole.scala @@ -0,0 +1,17 @@ + + +import scala.quoted.Quotes + +def test(using Quotes) = { + val x = '{0} + val y = '{ // warn: Canceled splice directly inside a quote. '{ ${ XYZ } } is equivalent to XYZ. + $x + } + val z = '{ + val a = ${ // warn: Canceled quote directly inside a splice. ${ '{ XYZ } } is equivalent to XYZ. + '{ + $y + } + } + } +} \ No newline at end of file diff --git a/tests/neg-deep-subtype/refined-types.scala b/tests/warn/refined-types.scala similarity index 66% rename from tests/neg-deep-subtype/refined-types.scala rename to tests/warn/refined-types.scala index 5f5cc5a45f04..1ef0f84c00d4 100644 --- a/tests/neg-deep-subtype/refined-types.scala +++ b/tests/warn/refined-types.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings + class A class B extends A @@ -18,7 +18,7 @@ def bl(x: AA) = x.isInstanceOf[BL] // was: the type test for BL cannot be checke def bu(x: AA) = x.isInstanceOf[BU] // was: the type test for BU cannot be checked at runtime // but static knowledge of only one bound makes checking against an alias unchecked: -def al_ba(x: AL) = x.isInstanceOf[BA] // error: the type test for BA cannot be checked at runtime -def au_ba(x: AU) = x.isInstanceOf[BA] // error: the type test for BA cannot be checked at runtime -def al_bu(x: AL) = x.isInstanceOf[BU] // error: the type test for BU cannot be checked at runtime -def au_bl(x: AU) = x.isInstanceOf[BL] // error: the type test for BL cannot be checked at runtime +def al_ba(x: AL) = x.isInstanceOf[BA] // warn: the type test for BA cannot be checked at runtime +def au_ba(x: AU) = x.isInstanceOf[BA] // warn: the type test for BA cannot be checked at runtime +def al_bu(x: AL) = x.isInstanceOf[BU] // warn: the type test for BU cannot be checked at runtime +def au_bl(x: AU) = x.isInstanceOf[BL] // warn: the type test for BL cannot be checked at runtime \ No newline at end of file diff --git a/tests/warn/refinements-this.scala b/tests/warn/refinements-this.scala new file mode 100644 index 000000000000..3e4c64cf1e59 --- /dev/null +++ b/tests/warn/refinements-this.scala @@ -0,0 +1,6 @@ + + +class Outer: + type X = { type O = Outer.this.type } // ok + type Y = { type O = this.type } // warn + diff --git a/tests/neg/rewrite-messages.check b/tests/warn/rewrite-messages.check similarity index 76% rename from tests/neg/rewrite-messages.check rename to tests/warn/rewrite-messages.check index f368c2dc8997..db97d2ed908a 100644 --- a/tests/neg/rewrite-messages.check +++ b/tests/warn/rewrite-messages.check @@ -1,10 +1,10 @@ --- Error: tests/neg/rewrite-messages.scala:3:18 ------------------------------------------------------------------------ -3 |import scala.util._ // error +-- Migration Warning: tests/warn/rewrite-messages.scala:3:18 ----------------------------------------------------------- +3 |import scala.util._ // warn | ^ | `_` is no longer supported for a wildcard import; use `*` instead | This construct can be rewritten automatically under -rewrite -source future-migration. --- Error: tests/neg/rewrite-messages.scala:7:4 ------------------------------------------------------------------------- -7 | 2 foo 4 // error +-- Migration Warning: tests/warn/rewrite-messages.scala:7:4 ------------------------------------------------------------ +7 | 2 foo 4 // warn | ^^^ | Alphanumeric method foo is not declared infix; it should not be used as infix operator. | Instead, use method syntax .foo(...) or backticked identifier `foo`. diff --git a/tests/warn/rewrite-messages.scala b/tests/warn/rewrite-messages.scala new file mode 100644 index 000000000000..88166f8e8ac2 --- /dev/null +++ b/tests/warn/rewrite-messages.scala @@ -0,0 +1,8 @@ +//> using options -source:future-migration -deprecation + +import scala.util._ // warn + +object Test { + extension (x: Int) def foo(y: Int) = x + y + 2 foo 4 // warn +} \ No newline at end of file diff --git a/tests/neg/i15503-scala2/scala2-t11681.scala b/tests/warn/scala2-t11681.scala similarity index 90% rename from tests/neg/i15503-scala2/scala2-t11681.scala rename to tests/warn/scala2-t11681.scala index 2436668e0c9c..ae2187181ceb 100644 --- a/tests/neg/i15503-scala2/scala2-t11681.scala +++ b/tests/warn/scala2-t11681.scala @@ -1,5 +1,5 @@ -//> using options -Xfatal-warnings -Wunused:params -// +//> using options -Wunused:params + import Answers._ @@ -10,7 +10,7 @@ trait InterFace { trait BadAPI extends InterFace { private def f(a: Int, - b: String, // error + b: String, // warn c: Double): Int = { println(c) a @@ -47,10 +47,9 @@ trait BadAPI extends InterFace { // mustn't alter warnings in super trait PoorClient extends BadAPI { override def meth(x: Int) = ??? // OK - override def f(a: Int, b: String, c: Double): Int = a + b.toInt + c.toInt } -class Unusing(u: Int) { // error +class Unusing(u: Int) { // warn def f = ??? } @@ -107,4 +106,4 @@ object Answers { def answer: Int = 42 } -val a$1 = 2 \ No newline at end of file +val a$1 = 2 diff --git a/tests/warn/strict-pattern-bindings-3.2.scala b/tests/warn/strict-pattern-bindings-3.2.scala new file mode 100644 index 000000000000..e4df8e770a01 --- /dev/null +++ b/tests/warn/strict-pattern-bindings-3.2.scala @@ -0,0 +1,37 @@ + +// These tests should fail under -Xfatal-warnings with source version source version 3.2 or later +import language.`3.2` + +object Test: + // from filtering-fors.scala + val xs: List[AnyRef] = ??? + + for ((x: String) <- xs) do () // warn + for (y@ (x: String) <- xs) do () // warn + for ((x, y) <- xs) do () // warn + + for ((x: String) <- xs if x.isEmpty) do () // warn + for ((x: String) <- xs; y = x) do () // warn + for ((x: String) <- xs; (y, z) <- xs) do () // warn // warn + for (case (x: String) <- xs; (y, z) <- xs) do () // warn + for ((x: String) <- xs; case (y, z) <- xs) do () // warn + + val pairs: List[AnyRef] = List((1, 2), "hello", (3, 4)) + for ((x, y) <- pairs) yield (y, x) // warn + + // from unchecked-patterns.scala + val y :: ys = List(1, 2, 3) // warn + val (1, c) = (1, 2) // warn + val 1 *: cs = 1 *: Tuple() // warn + + val (_: Int | _: AnyRef) = ??? : AnyRef // warn + + val 1 = 2 // warn + + object Positive { def unapply(i: Int): Option[Int] = Some(i).filter(_ > 0) } + object Always1 { def unapply(i: Int): Some[Int] = Some(i) } + object Pair { def unapply(t: (Int, Int)): t.type = t } + object Triple { def unapply(t: (Int, Int, Int)): (Int, Int, Int) = t } + + val Positive(p) = 5 // warn + val Some(s1) = Option(1) // warn \ No newline at end of file diff --git a/tests/neg/supertraits-b.scala b/tests/warn/supertraits-b.scala similarity index 69% rename from tests/neg/supertraits-b.scala rename to tests/warn/supertraits-b.scala index 78854537974e..b36fcb5634b7 100644 --- a/tests/neg/supertraits-b.scala +++ b/tests/warn/supertraits-b.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings + transparent sealed trait TA transparent sealed trait TB @@ -16,20 +16,20 @@ object Test: choose0(a, b) match case _: TA => ??? - case _: TB => ??? // error: unreachable + case _: TB => ??? // warn: unreachable choose1(a, b) match case _: TA => ??? - case _: TB => ??? // error: unreachable + case _: TB => ??? // warn: unreachable choose2(a, b) match case _: TB => ??? - case _: TA => ??? // error: unreachable + case _: TA => ??? // warn: unreachable choose3(a, b) match case _: Product => ??? - case _: TA => ??? // error: unreachable + case _: TA => ??? // warn: unreachable choose4(a, b) match case _: (TA & TB) => ??? - case _: Product => ??? // error: unreachable \ No newline at end of file + case _: Product => ??? // warn: unreachable \ No newline at end of file diff --git a/tests/neg/switches.scala b/tests/warn/switches.scala similarity index 77% rename from tests/neg/switches.scala rename to tests/warn/switches.scala index d405f8185706..9b45e3ed0d51 100644 --- a/tests/neg/switches.scala +++ b/tests/warn/switches.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings + import scala.annotation.switch @@ -38,7 +38,7 @@ object Main { // multiple annotations are processed correctly // thinks a val in an object is constant... so naive - def fail1(c: Char) = (c: @switch @unchecked) match { // error: Could not emit switch for @switch annotated match + def fail1(c: Char) = (c: @switch @unchecked) match { // warn: Could not emit switch for @switch annotated match case 'A' => true case 'B' => true case Other.C1 => true @@ -46,7 +46,7 @@ object Main { } // more naivete - def fail2(c: Char) = (c: @unchecked @switch) match { // error: Could not emit switch for @switch annotated match + def fail2(c: Char) = (c: @unchecked @switch) match { // warn: Could not emit switch for @switch annotated match case 'A' => true case 'B' => true case Other.C3 => true @@ -69,12 +69,12 @@ object Main { case _ => -1 } - def fail3(x: Any) = (x: @switch) match { // error: Could not emit switch for @switch annotated match + def fail3(x: Any) = (x: @switch) match { // warn: Could not emit switch for @switch annotated match case 1 | 2 | 3 => true case _ => false } - def fail4(x: AnyVal) = (x: @switch) match { // error: Could not emit switch for @switch annotated match + def fail4(x: AnyVal) = (x: @switch) match { // warn: Could not emit switch for @switch annotated match case 1 | 2 | 3 => true case _ => false } @@ -82,7 +82,7 @@ object Main { case class IntAnyVal(x: Int) extends AnyVal val Ten = IntAnyVal(10) - def fail5(x: IntAnyVal) = (x: @switch) match { // error: Could not emit switch for @switch annotated match + def fail5(x: IntAnyVal) = (x: @switch) match { // warn: Could not emit switch for @switch annotated match case IntAnyVal(1) => 0 case Ten => 1 case IntAnyVal(100) => 2 @@ -92,11 +92,11 @@ object Main { // the generated lookupswitch covers only a subset of the cases final val One = IntAnyVal(1) - def fail6(x: IntAnyVal) = (x: @switch) match { // error: Could not emit switch for @switch annotated match + def fail6(x: IntAnyVal) = (x: @switch) match { // warn: Could not emit switch for @switch annotated match case One => 0 case IntAnyVal(10) => 1 case IntAnyVal(100) => 2 case IntAnyVal(1000) => 3 case IntAnyVal(10000) => 4 } -} +} \ No newline at end of file diff --git a/tests/neg/symbolic-packages.check b/tests/warn/symbolic-packages.check similarity index 65% rename from tests/neg/symbolic-packages.check rename to tests/warn/symbolic-packages.check index 8e9b7e114829..c1d56f67eba7 100644 --- a/tests/neg/symbolic-packages.check +++ b/tests/warn/symbolic-packages.check @@ -1,16 +1,16 @@ --- Error: tests/neg/symbolic-packages.scala:3:8 ------------------------------------------------------------------------ -3 |package `with spaces` { // error +-- Warning: tests/warn/symbolic-packages.scala:3:8 --------------------------------------------------------------------- +3 |package `with spaces` { // warn | ^^^^^^^^^^^^^ | The package name `with spaces` will be encoded on the classpath, and can lead to undefined behaviour. --- Error: tests/neg/symbolic-packages.scala:7:10 ----------------------------------------------------------------------- -7 |package +.* { // error // error +-- Warning: tests/warn/symbolic-packages.scala:7:10 -------------------------------------------------------------------- +7 |package +.* { // warn // warn | ^ | The package name `*` will be encoded on the classpath, and can lead to undefined behaviour. --- Error: tests/neg/symbolic-packages.scala:7:8 ------------------------------------------------------------------------ -7 |package +.* { // error // error +-- Warning: tests/warn/symbolic-packages.scala:7:8 --------------------------------------------------------------------- +7 |package +.* { // warn // warn | ^ | The package name `+` will be encoded on the classpath, and can lead to undefined behaviour. --- Error: tests/neg/symbolic-packages.scala:11:16 ---------------------------------------------------------------------- -11 |package object `mixed_*` { // error +-- Warning: tests/warn/symbolic-packages.scala:11:16 ------------------------------------------------------------------- +11 |package object `mixed_*` { // warn | ^^^^^^^ | The package name `mixed_*` will be encoded on the classpath, and can lead to undefined behaviour. diff --git a/tests/warn/symbolic-packages.scala b/tests/warn/symbolic-packages.scala new file mode 100644 index 000000000000..6e0ef04da6bb --- /dev/null +++ b/tests/warn/symbolic-packages.scala @@ -0,0 +1,13 @@ + + +package `with spaces` { // warn + class Foo +} + +package +.* { // warn // warn + class Bar +} + +package object `mixed_*` { // warn + class Baz +} \ No newline at end of file diff --git a/tests/neg-deep-subtype/t2755.scala b/tests/warn/t2755.scala similarity index 91% rename from tests/neg-deep-subtype/t2755.scala rename to tests/warn/t2755.scala index ec3cb6aadefc..1aeb06d237d1 100644 --- a/tests/neg-deep-subtype/t2755.scala +++ b/tests/warn/t2755.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings + // Test cases: the only place we can cut and paste without crying // ourself to sleep. @@ -19,7 +19,7 @@ object Test { case x: Array[String] => x.size case x: Array[AnyRef] => 5 case x: Array[?] => 6 - case _ => 7 // error: only null is matched + case _ => 7 // warn: only null is matched } def f3[T](a: Array[T]) = a match { case x: Array[Int] => x(0) @@ -28,7 +28,7 @@ object Test { case x: Array[String] => x.size case x: Array[AnyRef] => 5 case x: Array[?] => 6 - case _ => 7 // error: only null is matched + case _ => 7 // warn: only null is matched } @@ -57,4 +57,4 @@ object Test { println(f3(Array(1L))) println(f3(null)) } -} +} \ No newline at end of file diff --git a/tests/neg/t3235-minimal.check b/tests/warn/t3235-minimal.check similarity index 75% rename from tests/neg/t3235-minimal.check rename to tests/warn/t3235-minimal.check index 83c287f85bc0..dcd28466f729 100644 --- a/tests/neg/t3235-minimal.check +++ b/tests/warn/t3235-minimal.check @@ -1,16 +1,16 @@ --- Error: tests/neg/t3235-minimal.scala:5:21 --------------------------------------------------------------------------- -5 | assert(123456789.round == 123456789) // error +-- Deprecation Warning: tests/warn/t3235-minimal.scala:5:21 ------------------------------------------------------------ +5 | assert(123456789.round == 123456789) // warn | ^^^^^^^^^^^^^^^ |method round in class RichInt is deprecated since 2.11.0: this is an integer type; there is no reason to round it. Perhaps you meant to call this on a floating-point value? --- Error: tests/neg/t3235-minimal.scala:6:16 --------------------------------------------------------------------------- -6 | assert(math.round(123456789) == 123456789) // error +-- Deprecation Warning: tests/warn/t3235-minimal.scala:6:16 ------------------------------------------------------------ +6 | assert(math.round(123456789) == 123456789) // warn | ^^^^^^^^^^ |method round in package scala.math is deprecated since 2.11.0: This is an integer type; there is no reason to round it. Perhaps you meant to call this with a floating-point value? --- Error: tests/neg/t3235-minimal.scala:7:32 --------------------------------------------------------------------------- -7 | assert(1234567890123456789L.round == 1234567890123456789L) // error +-- Deprecation Warning: tests/warn/t3235-minimal.scala:7:32 ------------------------------------------------------------ +7 | assert(1234567890123456789L.round == 1234567890123456789L) // warn | ^^^^^^^^^^^^^^^^^^^^^^^^^^ |method round in class RichLong is deprecated since 2.11.0: this is an integer type; there is no reason to round it. Perhaps you meant to call this on a floating-point value? --- Error: tests/neg/t3235-minimal.scala:8:16 --------------------------------------------------------------------------- -8 | assert(math.round(1234567890123456789L) == 1234567890123456789L) // error +-- Deprecation Warning: tests/warn/t3235-minimal.scala:8:16 ------------------------------------------------------------ +8 | assert(math.round(1234567890123456789L) == 1234567890123456789L) // warn | ^^^^^^^^^^ |method round in package scala.math is deprecated since 2.11.0: This is an integer type; there is no reason to round it. Perhaps you meant to call this with a floating-point value? diff --git a/tests/neg/t3235-minimal.scala b/tests/warn/t3235-minimal.scala similarity index 51% rename from tests/neg/t3235-minimal.scala rename to tests/warn/t3235-minimal.scala index f65ee13f87f5..22e6da9f31a0 100644 --- a/tests/neg/t3235-minimal.scala +++ b/tests/warn/t3235-minimal.scala @@ -1,10 +1,10 @@ -//> using options -Xfatal-warnings -deprecation +//> using options -deprecation object Test { def main(args: Array[String]): Unit = { - assert(123456789.round == 123456789) // error - assert(math.round(123456789) == 123456789) // error - assert(1234567890123456789L.round == 1234567890123456789L) // error - assert(math.round(1234567890123456789L) == 1234567890123456789L) // error + assert(123456789.round == 123456789) // warn + assert(math.round(123456789) == 123456789) // warn + assert(1234567890123456789L.round == 1234567890123456789L) // warn + assert(math.round(1234567890123456789L) == 1234567890123456789L) // warn } -} +} \ No newline at end of file diff --git a/tests/neg/t5830.scala b/tests/warn/t5830.scala similarity index 63% rename from tests/neg/t5830.scala rename to tests/warn/t5830.scala index 947b7bac4a22..41cdfb1059a7 100644 --- a/tests/neg/t5830.scala +++ b/tests/warn/t5830.scala @@ -1,11 +1,11 @@ -//> using options -Xfatal-warnings + import scala.annotation.switch class Test { def unreachable(ch: Char) = (ch: @switch) match { case 'a' => println("b") // ok - case 'a' => println("b") // error: unreachable case + case 'a' => println("b") // warn: unreachable case case 'c' => } } diff --git a/tests/neg-deep-subtype/type-lambda.scala b/tests/warn/type-lambda.scala similarity index 71% rename from tests/neg-deep-subtype/type-lambda.scala rename to tests/warn/type-lambda.scala index 4c4627fe1cf3..788647496a4f 100644 --- a/tests/neg-deep-subtype/type-lambda.scala +++ b/tests/warn/type-lambda.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings + trait A[T] trait B[T] extends A[T] @@ -10,7 +10,7 @@ object Test { } def bar(x: ([X] =>> A[X])[Any]) = x match { - case x: ([X] =>> B[Nothing])[Any] => // error + case x: ([X] =>> B[Nothing])[Any] => // warn case _ => } } diff --git a/tests/neg/type-test-paths-2.scala b/tests/warn/type-test-paths-2.scala similarity index 61% rename from tests/neg/type-test-paths-2.scala rename to tests/warn/type-test-paths-2.scala index 4bba2f87416e..79b22fa70049 100644 --- a/tests/neg/type-test-paths-2.scala +++ b/tests/warn/type-test-paths-2.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings + import scala.reflect.TypeTest @@ -29,15 +29,15 @@ object Test { val r2: R = RI r1.n match { - case n: r2.Nat => // error: the type test for Test.r2.Nat cannot be checked at runtime - case n: r1.Idx => // error: the type test for Test.r1.Idx cannot be checked at runtime + case n: r2.Nat => // warn: the type test for Test.r2.Nat cannot be checked at runtime + case n: r1.Idx => // warn: the type test for Test.r1.Idx cannot be checked at runtime case n: r1.Succ => // Ok case n: r1.Nat => // Ok } r1.one match { - case n: r2.Nat => // error: the type test for Test.r2.Nat cannot be checked at runtime - case n: r1.Idx => // error: the type test for Test.r1.Idx cannot be checked at runtime + case n: r2.Nat => // warn: the type test for Test.r2.Nat cannot be checked at runtime + case n: r1.Idx => // warn: the type test for Test.r1.Idx cannot be checked at runtime case n: r1.Nat => // Ok } -} +} \ No newline at end of file diff --git a/tests/neg/type-test-paths.scala b/tests/warn/type-test-paths.scala similarity index 88% rename from tests/neg/type-test-paths.scala rename to tests/warn/type-test-paths.scala index 324ed43ba7fa..03501cfd5957 100644 --- a/tests/neg/type-test-paths.scala +++ b/tests/warn/type-test-paths.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings + import scala.reflect.TypeTest @@ -8,7 +8,7 @@ object Test { val p2: T = T1 (p1.y: p1.X) match { - case x: p2.Y => // error: unchecked + case x: p2.Y => // warn: unchecked case x: p1.Y => case _ => } diff --git a/tests/neg/type-test-syntesize-b.scala b/tests/warn/type-test-syntesize-b.scala similarity index 74% rename from tests/neg/type-test-syntesize-b.scala rename to tests/warn/type-test-syntesize-b.scala index b5402eb92c66..ba8ffb8318b7 100644 --- a/tests/neg/type-test-syntesize-b.scala +++ b/tests/warn/type-test-syntesize-b.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings + import scala.reflect.TypeTest @@ -19,13 +19,13 @@ object Test { test[Any, Array[Int]] test[Seq[Int], List[Int]] - test[Any, Some[Int]] // error - test[Any, a.X] // error - test[a.X, a.Y] // error + test[Any, Some[Int]] // warn + test[Any, a.X] // warn + test[a.X, a.Y] // warn } class A { type X type Y <: X -} +} \ No newline at end of file diff --git a/tests/neg/uninitialized-3.4.check b/tests/warn/uninitialized-3.4.check similarity index 75% rename from tests/neg/uninitialized-3.4.check rename to tests/warn/uninitialized-3.4.check index 1c7b985072d0..ddf4bfed85ed 100644 --- a/tests/neg/uninitialized-3.4.check +++ b/tests/warn/uninitialized-3.4.check @@ -1,5 +1,5 @@ --- Error: tests/neg/uninitialized-3.4.scala:7:15 ----------------------------------------------------------------------- -7 | var a: Int = _ // error: migration warning +-- Warning: tests/warn/uninitialized-3.4.scala:5:15 -------------------------------------------------------------------- +5 | var a: Int = _ // warn | ^ | `= _` has been deprecated; use `= uninitialized` instead. | `uninitialized` can be imported with `scala.compiletime.uninitialized`. diff --git a/tests/neg/uninitialized-3.4.scala b/tests/warn/uninitialized-3.4.scala similarity index 60% rename from tests/neg/uninitialized-3.4.scala rename to tests/warn/uninitialized-3.4.scala index 174a95ae6c54..966f2e51af1c 100644 --- a/tests/neg/uninitialized-3.4.scala +++ b/tests/warn/uninitialized-3.4.scala @@ -1,8 +1,6 @@ -//> using options -Werror - import scala.language.`3.4` import scala.compiletime.uninitialized class Foo: - var a: Int = _ // error: migration warning + var a: Int = _ // warn var b: Int = uninitialized diff --git a/tests/neg/uninitialized-future-migration.scala b/tests/warn/uninitialized-future-migration.scala similarity index 62% rename from tests/neg/uninitialized-future-migration.scala rename to tests/warn/uninitialized-future-migration.scala index 05f7c6b67f38..7c24f2466221 100644 --- a/tests/neg/uninitialized-future-migration.scala +++ b/tests/warn/uninitialized-future-migration.scala @@ -1,8 +1,6 @@ -//> using options -Werror - import scala.language.`future-migration` import scala.compiletime.uninitialized class Foo: - var a: Int = _ // error: migration warning + var a: Int = _ // warn: migration warning var b: Int = uninitialized diff --git a/tests/warn/warn-value-discard.check b/tests/warn/warn-value-discard.check new file mode 100644 index 000000000000..ca6fedb29053 --- /dev/null +++ b/tests/warn/warn-value-discard.check @@ -0,0 +1,20 @@ +-- [E175] Potential Issue Warning: tests/warn/warn-value-discard.scala:27:36 ------------------------------------------- +27 | mutable.Set.empty[String].remove("") // warn + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | discarded non-Unit value of type Boolean +-- [E175] Potential Issue Warning: tests/warn/warn-value-discard.scala:39:41 ------------------------------------------- +39 | mutable.Set.empty[String].subtractOne("") // warn + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | discarded non-Unit value of type scala.collection.mutable.Set[String] +-- [E175] Potential Issue Warning: tests/warn/warn-value-discard.scala:59:4 -------------------------------------------- +59 | mutable.Set.empty[String] += "" // warn + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | discarded non-Unit value of type scala.collection.mutable.Set[String] +-- [E175] Potential Issue Warning: tests/warn/warn-value-discard.scala:15:35 ------------------------------------------- +15 | firstThing().map(_ => secondThing()) // warn + | ^^^^^^^^^^^^^ + | discarded non-Unit value of type Either[Failed, Unit] +-- [E175] Potential Issue Warning: tests/warn/warn-value-discard.scala:18:35 ------------------------------------------- +18 | firstThing().map(_ => secondThing()) // warn + | ^^^^^^^^^^^^^ + | discarded non-Unit value of type Either[Failed, Unit] diff --git a/tests/neg/warn-value-discard.scala b/tests/warn/warn-value-discard.scala similarity index 84% rename from tests/neg/warn-value-discard.scala rename to tests/warn/warn-value-discard.scala index fb01fdeda384..8bb9aebf515b 100644 --- a/tests/neg/warn-value-discard.scala +++ b/tests/warn/warn-value-discard.scala @@ -1,4 +1,4 @@ -//> using options -Wvalue-discard -Werror +//> using options -Wvalue-discard import scala.util.{Either, Right, Left} import scala.collection.mutable @@ -12,10 +12,10 @@ def secondThing(): Either[Failed, Unit] = Left(Failed("whoops you should have flatMapped me")) def singleExpr(): Either[Failed, Unit] = - firstThing().map(_ => secondThing()) // error + firstThing().map(_ => secondThing()) // warn def block(): Either[Failed, Unit] = { - firstThing().map(_ => secondThing()) // error + firstThing().map(_ => secondThing()) // warn } class ValueDiscardTest: @@ -24,7 +24,7 @@ class ValueDiscardTest: def remove(): Unit = // Set#remove returns a Boolean, not this.type // --> Warning - mutable.Set.empty[String].remove("") // error + mutable.Set.empty[String].remove("") // warn // TODO IMHO we don't need to support this, // as it's just as easy to add a @nowarn annotation as a Unit ascription @@ -36,7 +36,7 @@ class ValueDiscardTest: // - Set#subtractOne returns this.type // - receiver is not a field or a local variable (not quite sure what you'd call it) // --> Warning - mutable.Set.empty[String].subtractOne("") // error + mutable.Set.empty[String].subtractOne("") // warn def mutateLocalVariable(): Unit = { // - Set#subtractOne returns this.type @@ -56,11 +56,11 @@ class ValueDiscardTest: // - += returns this.type // - receiver is not a field or a local variable // --> Warning - mutable.Set.empty[String] += "" // error + mutable.Set.empty[String] += "" // warn def assignmentOperatorLocalVariable(): Unit = // - += returns this.type // - receiver is a local variable // --> No warning val s: mutable.Set[String] = mutable.Set.empty[String] - s += "" + s += "" \ No newline at end of file diff --git a/tests/neg/wildcard-type-syntax-3.4.scala b/tests/warn/wildcard-type-syntax-3.4.scala similarity index 52% rename from tests/neg/wildcard-type-syntax-3.4.scala rename to tests/warn/wildcard-type-syntax-3.4.scala index 1123c9cbbe35..2dd280259ac5 100644 --- a/tests/neg/wildcard-type-syntax-3.4.scala +++ b/tests/warn/wildcard-type-syntax-3.4.scala @@ -1,8 +1,6 @@ -//> using options -Werror - import scala.language.`3.4-migration` def test = Seq() match - case _: List[_] => // error: migration warning + case _: List[_] => // warn: migration warning case _: Seq[?] => diff --git a/tests/neg/wildcard-type-syntax-future-migration.scala b/tests/warn/wildcard-type-syntax-future-migration.scala similarity index 53% rename from tests/neg/wildcard-type-syntax-future-migration.scala rename to tests/warn/wildcard-type-syntax-future-migration.scala index 6a5367385ab0..1c55827adb90 100644 --- a/tests/neg/wildcard-type-syntax-future-migration.scala +++ b/tests/warn/wildcard-type-syntax-future-migration.scala @@ -1,8 +1,6 @@ -//> using options -Werror - import scala.language.`future-migration` def test = Seq() match - case _: List[_] => // error: migration warning + case _: List[_] => // warn: migration warning case _: Seq[?] => diff --git a/tests/neg/with-type-operator-future-migration.check b/tests/warn/with-type-operator-future-migration.check similarity index 61% rename from tests/neg/with-type-operator-future-migration.check rename to tests/warn/with-type-operator-future-migration.check index e56049880431..2842592bee64 100644 --- a/tests/neg/with-type-operator-future-migration.check +++ b/tests/warn/with-type-operator-future-migration.check @@ -1,5 +1,5 @@ --- [E003] Syntax Error: tests/neg/with-type-operator-future-migration.scala:5:13 --------------------------------------- -5 |def foo: Int with String = ??? // error +-- [E003] Syntax Migration Warning: tests/warn/with-type-operator-future-migration.scala:5:13 -------------------------- +5 |def foo: Int with String = ??? // warn | ^^^^ | with as a type operator has been deprecated; use & instead | This construct can be rewritten automatically under -rewrite -source 3.4-migration. diff --git a/tests/warn/with-type-operator-future-migration.scala b/tests/warn/with-type-operator-future-migration.scala new file mode 100644 index 000000000000..42b029665565 --- /dev/null +++ b/tests/warn/with-type-operator-future-migration.scala @@ -0,0 +1,6 @@ + + +import scala.language.`future-migration` + +def foo: Int with String = ??? // warn + diff --git a/tests/neg/xfatalWarnings.scala b/tests/warn/xfatalWarnings.scala similarity index 69% rename from tests/neg/xfatalWarnings.scala rename to tests/warn/xfatalWarnings.scala index 3f49e159cbc4..7e77ac468370 100644 --- a/tests/neg/xfatalWarnings.scala +++ b/tests/warn/xfatalWarnings.scala @@ -1,9 +1,9 @@ -//> using options -Xfatal-warnings + object xfatalWarnings { val opt:Option[String] = Some("test") - opt match { // error when running with -Xfatal-warnings + opt match { // warn case None => } @@ -11,3 +11,5 @@ object xfatalWarnings { while (true) {} // should be ok. no "pure expression does nothing in statement position" issued. } } + +// When running with fatal warnings: