From b98f66257afefd76e1b0969afe5460a8fccc5151 Mon Sep 17 00:00:00 2001 From: Szymon Rodziewicz Date: Fri, 15 Dec 2023 16:41:11 +0100 Subject: [PATCH 1/5] Change behavior of Xfatal-warnings & adjust final tests Revert "Fix i18118.check" --- compiler/src/dotty/tools/dotc/Run.scala | 1 + .../dotty/tools/dotc/reporting/Reporter.scala | 13 ++-- compiler/test-resources/repl/rewrite-messages | 13 ++-- .../init-global/neg/context-sensitivity.check | 11 +++ .../init-global/neg/context-sensitivity.scala | 4 +- tests/init-global/neg/global-cycle1.check | 15 +++-- tests/init-global/neg/global-cycle1.scala | 6 +- tests/init-global/neg/global-cycle14.check | 21 ++++++ tests/init-global/neg/global-cycle14.scala | 6 +- tests/init-global/neg/global-cycle2.check | 11 +++ tests/init-global/neg/global-cycle2.scala | 4 +- tests/init-global/neg/global-cycle3.check | 11 +++ tests/init-global/neg/global-cycle3.scala | 4 +- tests/init-global/neg/global-cycle4.check | 11 +++ tests/init-global/neg/global-cycle4.scala | 4 +- tests/init-global/neg/global-cycle5.check | 10 +++ tests/init-global/neg/global-cycle5.scala | 5 +- tests/init-global/neg/global-cycle6.check | 29 ++++++++ tests/init-global/neg/global-cycle6.scala | 7 +- tests/init-global/neg/global-cycle7.check | 21 ++++++ tests/init-global/neg/global-cycle7.scala | 6 +- tests/init-global/neg/global-cycle8.check | 17 +++++ tests/init-global/neg/global-cycle8.scala | 4 +- .../init-global/neg/global-irrelevance1.check | 10 +++ .../init-global/neg/global-irrelevance1.scala | 3 +- .../init-global/neg/global-irrelevance2.check | 14 ++++ .../init-global/neg/global-irrelevance2.scala | 4 +- .../init-global/neg/global-irrelevance3.check | 12 ++++ .../init-global/neg/global-irrelevance3.scala | 4 +- .../init-global/neg/global-irrelevance4.check | 12 ++++ .../init-global/neg/global-irrelevance4.scala | 4 +- .../init-global/neg/global-irrelevance5.check | 10 +++ .../init-global/neg/global-irrelevance5.scala | 4 +- .../init-global/neg/global-irrelevance6.check | 10 +++ .../init-global/neg/global-irrelevance6.scala | 4 +- .../init-global/neg/global-irrelevance7.check | 10 +++ .../init-global/neg/global-irrelevance7.scala | 4 +- tests/init-global/neg/global-list.check | 37 ++++++++++ tests/init-global/neg/global-list.scala | 5 +- tests/init-global/neg/global-local-var.check | 13 ++++ tests/init-global/neg/global-local-var.scala | 4 +- tests/init-global/neg/global-region1.check | 11 +++ tests/init-global/neg/global-region1.scala | 4 +- tests/init-global/neg/i11262.check | 15 +++++ tests/init-global/neg/i11262.scala | 6 +- tests/init-global/neg/i12544b.check | 21 ++++++ tests/init-global/neg/i12544b.scala | 6 +- tests/init-global/neg/i15883.scala | 2 - tests/init-global/neg/i9176.check | 9 +++ tests/init-global/neg/i9176.scala | 4 +- tests/init-global/neg/line-spacing.check | 7 +- tests/init-global/neg/line-spacing.scala | 4 +- tests/init-global/neg/mutable-array.check | 10 +++ tests/init-global/neg/mutable-array.scala | 4 +- tests/init-global/neg/mutable-read1.check | 10 +++ tests/init-global/neg/mutable-read1.scala | 3 +- tests/init-global/neg/mutable-read2.check | 10 +++ tests/init-global/neg/mutable-read2.scala | 3 +- tests/init-global/neg/mutable-read3.check | 10 +++ tests/init-global/neg/mutable-read3.scala | 3 +- tests/init-global/neg/mutable-read4.check | 10 +++ tests/init-global/neg/mutable-read4.scala | 3 +- tests/init-global/neg/mutable-read5.check | 12 ++++ tests/init-global/neg/mutable-read5.scala | 5 +- tests/init-global/neg/mutable-read6.check | 12 ++++ tests/init-global/neg/mutable-read6.scala | 5 +- tests/init-global/neg/mutable-read7.check | 16 +++++ tests/init-global/neg/mutable-read7.scala | 5 +- tests/init-global/neg/mutable-read8.check | 14 ++++ tests/init-global/neg/mutable-read8.scala | 5 +- tests/init-global/neg/partial-ordering.check | 13 ++++ tests/init-global/neg/partial-ordering.scala | 5 +- tests/init-global/neg/patmat-unapplySeq.check | 7 +- tests/init-global/neg/patmat-unapplySeq.scala | 4 +- .../init-global/neg/patmat-unapplySeq2.check | 12 ++++ .../init-global/neg/patmat-unapplySeq2.scala | 4 +- tests/init-global/neg/patmat.check | 27 ++++++++ tests/init-global/neg/patmat.scala | 6 +- tests/init-global/neg/return.check | 11 +++ tests/init-global/neg/return.scala | 4 +- tests/init-global/neg/return2.check | 15 +++++ tests/init-global/neg/return2.scala | 4 +- tests/init-global/neg/t5366.check | 21 ++++++ tests/init-global/neg/t5366.scala | 7 +- tests/init-global/neg/t9115.check | 21 ++++++ tests/init-global/neg/t9115.scala | 6 +- tests/init-global/neg/t9261.check | 9 +++ tests/init-global/neg/t9261.scala | 4 +- tests/init-global/neg/t9312.check | 29 ++++++++ tests/init-global/neg/t9312.scala | 6 +- tests/init-global/neg/t9360.check | 21 ++++++ tests/init-global/neg/t9360.scala | 6 +- .../neg/unapply-implicit-arg.check | 9 +++ .../neg/unapply-implicit-arg.scala | 5 +- .../neg/unapply-implicit-arg2.check | 13 ++++ .../neg/unapply-implicit-arg2.scala | 4 +- .../neg/unapply-implicit-arg3.check | 15 +++++ .../neg/unapply-implicit-arg3.scala | 4 +- .../neg/unapplySeq-implicit-arg.check | 9 +++ .../neg/unapplySeq-implicit-arg.scala | 4 +- .../neg/unapplySeq-implicit-arg2.check | 13 ++++ .../neg/unapplySeq-implicit-arg2.scala | 4 +- .../neg/unapplySeq-implicit-arg3.check | 15 +++++ .../neg/unapplySeq-implicit-arg3.scala | 4 +- tests/init-global/warn/i15883.scala | 2 + .../{neg => warn}/lazy-local-val.scala | 4 +- tests/neg-custom-args/sourcepath2/hi/A.check | 5 +- tests/neg-custom-args/sourcepath2/hi/A.scala | 3 +- tests/neg-macros/i9570.check | 5 +- tests/neg-macros/i9570.scala | 6 +- tests/neg-macros/macro-deprecation.check | 5 +- tests/neg-macros/macro-deprecation.scala | 6 +- tests/neg/adhoc-extension/B.scala | 11 +-- tests/neg/capt-wf.scala | 11 +-- .../neg/classtag-typetest/3_1-migration.scala | 3 +- tests/neg/classtag-typetest/3_1.scala | 3 +- tests/neg/i12188/Test.scala | 6 +- tests/neg/i13946/BadPrinter.scala | 3 +- tests/neg/i14386.scala | 5 +- tests/neg/i16876/Test.scala | 5 +- tests/neg/i17612b.check | 33 ++++----- tests/neg/i17612b/i17612b.scala | 11 +-- tests/neg/i17613b.check | 67 ++++++++++--------- tests/neg/i17613b/i17613b.scala | 39 ++++++----- tests/neg/i4986d.scala | 5 +- tests/neg/i8681.scala | 3 +- tests/neg/i8711.check | 17 +++-- tests/neg/i8711.scala | 4 +- tests/neg/i9408b.check | 5 +- tests/neg/i9408b/Test_2.scala | 4 +- tests/neg/impl-conv/A.scala | 2 +- tests/neg/impl-conv/B.scala | 3 +- tests/neg/indentLeft.scala | 3 +- tests/neg/indentRight.scala | 14 ++-- tests/neg/infix.check | 30 +++++++++ tests/neg/infix.scala | 4 +- tests/neg/missing-targetName.scala | 7 +- tests/neg/pureStatement.scala | 11 +-- tests/neg/structural-2.scala | 3 +- tests/neg/unchecked-patterns.scala | 17 ++--- tests/patmat/i18118.check | 1 + .../alphanumeric-infix-operator-3.4.scala | 4 +- .../alphanumeric-infix-operator.check | 4 +- .../alphanumeric-infix-operator.scala | 4 +- 144 files changed, 1097 insertions(+), 249 deletions(-) create mode 100644 tests/init-global/neg/context-sensitivity.check mode change 100755 => 100644 tests/init-global/neg/context-sensitivity.scala create mode 100644 tests/init-global/neg/global-cycle14.check create mode 100644 tests/init-global/neg/global-cycle2.check create mode 100644 tests/init-global/neg/global-cycle3.check create mode 100644 tests/init-global/neg/global-cycle4.check create mode 100644 tests/init-global/neg/global-cycle5.check mode change 100755 => 100644 tests/init-global/neg/global-cycle5.scala create mode 100644 tests/init-global/neg/global-cycle6.check create mode 100644 tests/init-global/neg/global-cycle7.check create mode 100644 tests/init-global/neg/global-cycle8.check create mode 100644 tests/init-global/neg/global-irrelevance1.check create mode 100644 tests/init-global/neg/global-irrelevance2.check create mode 100644 tests/init-global/neg/global-irrelevance3.check create mode 100644 tests/init-global/neg/global-irrelevance4.check create mode 100644 tests/init-global/neg/global-irrelevance5.check create mode 100644 tests/init-global/neg/global-irrelevance6.check create mode 100644 tests/init-global/neg/global-irrelevance7.check create mode 100644 tests/init-global/neg/global-list.check mode change 100755 => 100644 tests/init-global/neg/global-list.scala create mode 100644 tests/init-global/neg/global-local-var.check create mode 100644 tests/init-global/neg/global-region1.check create mode 100644 tests/init-global/neg/i11262.check create mode 100644 tests/init-global/neg/i12544b.check delete mode 100644 tests/init-global/neg/i15883.scala create mode 100644 tests/init-global/neg/i9176.check create mode 100644 tests/init-global/neg/mutable-array.check create mode 100644 tests/init-global/neg/mutable-read1.check mode change 100755 => 100644 tests/init-global/neg/mutable-read1.scala create mode 100644 tests/init-global/neg/mutable-read2.check mode change 100755 => 100644 tests/init-global/neg/mutable-read2.scala create mode 100644 tests/init-global/neg/mutable-read3.check mode change 100755 => 100644 tests/init-global/neg/mutable-read3.scala create mode 100644 tests/init-global/neg/mutable-read4.check mode change 100755 => 100644 tests/init-global/neg/mutable-read4.scala create mode 100644 tests/init-global/neg/mutable-read5.check mode change 100755 => 100644 tests/init-global/neg/mutable-read5.scala create mode 100644 tests/init-global/neg/mutable-read6.check mode change 100755 => 100644 tests/init-global/neg/mutable-read6.scala create mode 100644 tests/init-global/neg/mutable-read7.check mode change 100755 => 100644 tests/init-global/neg/mutable-read7.scala create mode 100644 tests/init-global/neg/mutable-read8.check mode change 100755 => 100644 tests/init-global/neg/mutable-read8.scala create mode 100644 tests/init-global/neg/partial-ordering.check mode change 100755 => 100644 tests/init-global/neg/partial-ordering.scala create mode 100644 tests/init-global/neg/patmat-unapplySeq2.check create mode 100644 tests/init-global/neg/patmat.check create mode 100644 tests/init-global/neg/return.check mode change 100755 => 100644 tests/init-global/neg/return.scala create mode 100644 tests/init-global/neg/return2.check mode change 100755 => 100644 tests/init-global/neg/return2.scala create mode 100644 tests/init-global/neg/t5366.check create mode 100644 tests/init-global/neg/t9115.check create mode 100644 tests/init-global/neg/t9261.check create mode 100644 tests/init-global/neg/t9312.check create mode 100644 tests/init-global/neg/t9360.check create mode 100644 tests/init-global/neg/unapply-implicit-arg.check create mode 100644 tests/init-global/neg/unapply-implicit-arg2.check create mode 100644 tests/init-global/neg/unapply-implicit-arg3.check create mode 100644 tests/init-global/neg/unapplySeq-implicit-arg.check create mode 100644 tests/init-global/neg/unapplySeq-implicit-arg2.check create mode 100644 tests/init-global/neg/unapplySeq-implicit-arg3.check create mode 100644 tests/init-global/warn/i15883.scala rename tests/init-global/{neg => warn}/lazy-local-val.scala (78%) create mode 100644 tests/neg/infix.check rename tests/{neg => warn}/alphanumeric-infix-operator-3.4.scala (63%) rename tests/{neg => warn}/alphanumeric-infix-operator.check (72%) rename tests/{neg => warn}/alphanumeric-infix-operator.scala (59%) diff --git a/compiler/src/dotty/tools/dotc/Run.scala b/compiler/src/dotty/tools/dotc/Run.scala index c3a91ef1ce1b..849d678279f1 100644 --- a/compiler/src/dotty/tools/dotc/Run.scala +++ b/compiler/src/dotty/tools/dotc/Run.scala @@ -348,6 +348,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 ca4114a82cdc..2426b569b0d8 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/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/i15883.scala b/tests/init-global/neg/i15883.scala deleted file mode 100644 index 80051c13b92b..000000000000 --- a/tests/init-global/neg/i15883.scala +++ /dev/null @@ -1,2 +0,0 @@ -val a = b // error -val b = 1 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/warn/i15883.scala b/tests/init-global/warn/i15883.scala new file mode 100644 index 000000000000..23128a745332 --- /dev/null +++ b/tests/init-global/warn/i15883.scala @@ -0,0 +1,2 @@ +val a = b // warn +val b = 1 diff --git a/tests/init-global/neg/lazy-local-val.scala b/tests/init-global/warn/lazy-local-val.scala similarity index 78% rename from tests/init-global/neg/lazy-local-val.scala rename to tests/init-global/warn/lazy-local-val.scala index 2a645ae78db1..30ae864ab169 100644 --- a/tests/init-global/neg/lazy-local-val.scala +++ b/tests/init-global/warn/lazy-local-val.scala @@ -5,7 +5,7 @@ object A: val b = a Box(b) - val box = f(n) // error + val box = f(n) // warn val n = 10 object B: @@ -15,5 +15,5 @@ object B: lazy val b = a Box(b) - val box = f(n) // error + val box = f(n) // warn val n = 10 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..051ed021d8ba 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 diff --git a/tests/neg-macros/i9570.check b/tests/neg-macros/i9570.check index 1e546c8cc485..16b71d317b7c 100644 --- a/tests/neg-macros/i9570.check +++ b/tests/neg-macros/i9570.check @@ -1,4 +1,5 @@ --- Error: tests/neg-macros/i9570.scala:15:21 --------------------------------------------------------------------------- -15 | case '{HCons(_,$t)} => // error +-- 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 0ac78285355c..0c67c2d0f8d1 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 + case '{HCons(_,$t)} => // warn (in .check file) sizeImpl(t,n+1) case '{HNil} => Expr(n) } @@ -20,7 +20,9 @@ object Macros { inline def size(inline expr: HList ): Int = { ${sizeImpl('expr,0)} - } + } } } + +// 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 index eaea18315e92..5ce8a2427127 100644 --- a/tests/neg-macros/macro-deprecation.check +++ b/tests/neg-macros/macro-deprecation.check @@ -1,4 +1,5 @@ --- Error: tests/neg-macros/macro-deprecation.scala:5:18 ---------------------------------------------------------------- -5 |inline def f = ${ impl } // error +-- 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 ffa146ef361c..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 -@deprecated def impl(using Quotes) = '{1} \ No newline at end of file +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/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/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/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/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/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/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/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/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/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/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/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..ddf6e22bff45 --- /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 3.4-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 3.4-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 3.4-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 3.4-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 3.4-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/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/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/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/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/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/neg/alphanumeric-infix-operator-3.4.scala b/tests/warn/alphanumeric-infix-operator-3.4.scala similarity index 63% rename from tests/neg/alphanumeric-infix-operator-3.4.scala rename to tests/warn/alphanumeric-infix-operator-3.4.scala index 14d3358127ca..1ea3d42f4ccd 100644 --- a/tests/neg/alphanumeric-infix-operator-3.4.scala +++ b/tests/warn/alphanumeric-infix-operator-3.4.scala @@ -1,5 +1,3 @@ -//> using options -Werror - import language.`3.4` class Foo: @@ -7,5 +5,5 @@ class Foo: infix def y(i: Int) = i def test(foo: Foo): Unit = - foo x 1 // error (because it was compiled with 3.4+) + foo x 1 // warn (because it was compiled with 3.4+) foo y 2 // ok: is marked as infix diff --git a/tests/neg/alphanumeric-infix-operator.check b/tests/warn/alphanumeric-infix-operator.check similarity index 72% rename from tests/neg/alphanumeric-infix-operator.check rename to tests/warn/alphanumeric-infix-operator.check index 52b08f16b88c..b35cfff793e2 100644 --- a/tests/neg/alphanumeric-infix-operator.check +++ b/tests/warn/alphanumeric-infix-operator.check @@ -1,5 +1,5 @@ --- Error: tests/neg/alphanumeric-infix-operator.scala:8:6 -------------------------------------------------------------- -8 | foo x 1 // error (because it was compiled with 3.4+) +-- Warning: tests/warn/alphanumeric-infix-operator.scala:6:6 ----------------------------------------------------------- +6 | foo x 1 // warn (because it was compiled with 3.4+) | ^ | Alphanumeric method x is not declared infix; it should not be used as infix operator. | Instead, use method syntax .x(...) or backticked identifier `x`. diff --git a/tests/neg/alphanumeric-infix-operator.scala b/tests/warn/alphanumeric-infix-operator.scala similarity index 59% rename from tests/neg/alphanumeric-infix-operator.scala rename to tests/warn/alphanumeric-infix-operator.scala index 1f2233dda6ce..ceba6174d312 100644 --- a/tests/neg/alphanumeric-infix-operator.scala +++ b/tests/warn/alphanumeric-infix-operator.scala @@ -1,9 +1,7 @@ -//> using options -Werror - class Foo: def x(i: Int) = i infix def y(i: Int) = i def test(foo: Foo): Unit = - foo x 1 // error (because it was compiled with 3.4+) + foo x 1 // warn (because it was compiled with 3.4+) foo y 2 // ok: is marked as infix From 363d3b52d8e4df647a26d6bd9f8bbe600088e0d5 Mon Sep 17 00:00:00 2001 From: Szymon Rodziewicz Date: Fri, 26 Jan 2024 12:58:51 +0100 Subject: [PATCH 2/5] Fix tests after rebase --- tests/neg-scalajs/enumeration-warnings.check | 49 ++++++++++---------- tests/neg-scalajs/enumeration-warnings.scala | 26 ++++++----- tests/patmat/i14407.dupe.check | 1 + 3 files changed, 40 insertions(+), 36 deletions(-) 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/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 From a452a73db054e85022cb901da53f33b89a9b06bc Mon Sep 17 00:00:00 2001 From: Szymon Rodziewicz Date: Fri, 26 Jan 2024 17:13:19 +0100 Subject: [PATCH 3/5] Moved tests --- tests/init-global/neg/global-cycle1.scala | 12 ------------ tests/init-global/neg/global-cycle2.scala | 9 --------- tests/init-global/neg/global-cycle3.scala | 9 --------- tests/init-global/neg/global-irrelevance1.scala | 6 ------ tests/init-global/neg/global-irrelevance2.scala | 10 ---------- tests/init-global/neg/global-irrelevance5.scala | 8 -------- tests/init-global/neg/global-list.scala | 10 ---------- tests/init-global/neg/i11262.scala | 4 ---- tests/init-global/neg/t9261.scala | 5 ----- .../{neg => warn}/context-sensitivity.check | 7 +++---- .../{neg => warn}/context-sensitivity.scala | 3 +-- tests/init-global/{neg => warn}/global-cycle1.check | 0 tests/init-global/warn/global-cycle1.scala | 11 +++++++++++ tests/init-global/{neg => warn}/global-cycle14.check | 0 tests/init-global/{neg => warn}/global-cycle14.scala | 5 ++--- tests/init-global/{neg => warn}/global-cycle2.check | 0 tests/init-global/warn/global-cycle2.scala | 8 ++++++++ tests/init-global/{neg => warn}/global-cycle3.check | 0 tests/init-global/warn/global-cycle3.scala | 8 ++++++++ tests/init-global/{neg => warn}/global-cycle4.check | 0 tests/init-global/{neg => warn}/global-cycle4.scala | 3 +-- tests/init-global/{neg => warn}/global-cycle5.check | 0 tests/init-global/{neg => warn}/global-cycle5.scala | 3 +-- tests/init-global/{neg => warn}/global-cycle6.check | 0 tests/init-global/{neg => warn}/global-cycle6.scala | 5 ++--- tests/init-global/{neg => warn}/global-cycle7.check | 0 tests/init-global/{neg => warn}/global-cycle7.scala | 5 ++--- tests/init-global/{neg => warn}/global-cycle8.check | 0 tests/init-global/{neg => warn}/global-cycle8.scala | 3 +-- .../{neg => warn}/global-irrelevance1.check | 0 tests/init-global/warn/global-irrelevance1.scala | 5 +++++ .../{neg => warn}/global-irrelevance2.check | 0 tests/init-global/warn/global-irrelevance2.scala | 9 +++++++++ .../{neg => warn}/global-irrelevance3.check | 0 .../{neg => warn}/global-irrelevance3.scala | 3 +-- .../{neg => warn}/global-irrelevance4.check | 0 .../{neg => warn}/global-irrelevance4.scala | 3 +-- .../{neg => warn}/global-irrelevance5.check | 0 tests/init-global/warn/global-irrelevance5.scala | 7 +++++++ .../{neg => warn}/global-irrelevance6.check | 0 .../{neg => warn}/global-irrelevance6.scala | 3 +-- .../{neg => warn}/global-irrelevance7.check | 0 .../{neg => warn}/global-irrelevance7.scala | 3 +-- tests/init-global/{neg => warn}/global-list.check | 0 tests/init-global/warn/global-list.scala | 9 +++++++++ .../init-global/{neg => warn}/global-local-var.check | 0 .../init-global/{neg => warn}/global-local-var.scala | 3 +-- tests/init-global/{neg => warn}/global-region1.check | 0 tests/init-global/{neg => warn}/global-region1.scala | 3 +-- tests/init-global/{neg => warn}/i11262.check | 0 tests/init-global/warn/i11262.scala | 3 +++ tests/init-global/{neg => warn}/i12544b.check | 0 tests/init-global/{neg => warn}/i12544b.scala | 5 ++--- tests/init-global/{neg => warn}/i9176.check | 0 tests/init-global/{neg => warn}/i9176.scala | 3 +-- tests/init-global/{neg => warn}/line-spacing.check | 0 tests/init-global/{neg => warn}/line-spacing.scala | 3 +-- tests/init-global/{neg => warn}/mutable-array.check | 0 tests/init-global/{neg => warn}/mutable-array.scala | 3 +-- tests/init-global/{neg => warn}/mutable-read1.check | 0 tests/init-global/{neg => warn}/mutable-read1.scala | 3 +-- tests/init-global/{neg => warn}/mutable-read2.check | 0 tests/init-global/{neg => warn}/mutable-read2.scala | 3 +-- tests/init-global/{neg => warn}/mutable-read3.check | 0 tests/init-global/{neg => warn}/mutable-read3.scala | 3 +-- tests/init-global/{neg => warn}/mutable-read4.check | 0 tests/init-global/{neg => warn}/mutable-read4.scala | 3 +-- tests/init-global/{neg => warn}/mutable-read5.check | 0 tests/init-global/{neg => warn}/mutable-read5.scala | 3 +-- tests/init-global/{neg => warn}/mutable-read6.check | 0 tests/init-global/{neg => warn}/mutable-read6.scala | 3 +-- tests/init-global/{neg => warn}/mutable-read7.check | 0 tests/init-global/{neg => warn}/mutable-read7.scala | 3 +-- tests/init-global/{neg => warn}/mutable-read8.check | 0 tests/init-global/{neg => warn}/mutable-read8.scala | 3 +-- .../init-global/{neg => warn}/partial-ordering.check | 0 .../init-global/{neg => warn}/partial-ordering.scala | 3 +-- .../{neg => warn}/patmat-unapplySeq.check | 0 .../{neg => warn}/patmat-unapplySeq.scala | 3 +-- .../{neg => warn}/patmat-unapplySeq2.check | 0 .../{neg => warn}/patmat-unapplySeq2.scala | 3 +-- tests/init-global/{neg => warn}/patmat.check | 0 tests/init-global/{neg => warn}/patmat.scala | 5 ++--- tests/init-global/{neg => warn}/return.check | 0 tests/init-global/{neg => warn}/return.scala | 3 +-- tests/init-global/{neg => warn}/return2.check | 0 tests/init-global/{neg => warn}/return2.scala | 3 +-- tests/init-global/{neg => warn}/t5366.check | 0 tests/init-global/{neg => warn}/t5366.scala | 5 ++--- tests/init-global/{neg => warn}/t9115.check | 0 tests/init-global/{neg => warn}/t9115.scala | 5 ++--- tests/init-global/{neg => warn}/t9261.check | 0 tests/init-global/warn/t9261.scala | 4 ++++ tests/init-global/{neg => warn}/t9312.check | 0 tests/init-global/{neg => warn}/t9312.scala | 5 ++--- tests/init-global/{neg => warn}/t9360.check | 0 tests/init-global/{neg => warn}/t9360.scala | 5 ++--- .../{neg => warn}/unapply-implicit-arg.check | 0 .../{neg => warn}/unapply-implicit-arg.scala | 3 +-- .../{neg => warn}/unapply-implicit-arg2.check | 0 .../{neg => warn}/unapply-implicit-arg2.scala | 3 +-- .../{neg => warn}/unapply-implicit-arg3.check | 0 .../{neg => warn}/unapply-implicit-arg3.scala | 3 +-- .../{neg => warn}/unapplySeq-implicit-arg.check | 0 .../{neg => warn}/unapplySeq-implicit-arg.scala | 3 +-- .../{neg => warn}/unapplySeq-implicit-arg2.check | 0 .../{neg => warn}/unapplySeq-implicit-arg2.scala | 3 +-- .../{neg => warn}/unapplySeq-implicit-arg3.check | 0 .../{neg => warn}/unapplySeq-implicit-arg3.scala | 3 +-- 109 files changed, 117 insertions(+), 168 deletions(-) delete mode 100644 tests/init-global/neg/global-cycle1.scala delete mode 100644 tests/init-global/neg/global-cycle2.scala delete mode 100644 tests/init-global/neg/global-cycle3.scala delete mode 100644 tests/init-global/neg/global-irrelevance1.scala delete mode 100644 tests/init-global/neg/global-irrelevance2.scala delete mode 100644 tests/init-global/neg/global-irrelevance5.scala delete mode 100644 tests/init-global/neg/global-list.scala delete mode 100644 tests/init-global/neg/i11262.scala delete mode 100644 tests/init-global/neg/t9261.scala rename tests/init-global/{neg => warn}/context-sensitivity.check (59%) rename tests/init-global/{neg => warn}/context-sensitivity.scala (76%) rename tests/init-global/{neg => warn}/global-cycle1.check (100%) create mode 100644 tests/init-global/warn/global-cycle1.scala rename tests/init-global/{neg => warn}/global-cycle14.check (100%) rename tests/init-global/{neg => warn}/global-cycle14.scala (58%) rename tests/init-global/{neg => warn}/global-cycle2.check (100%) create mode 100644 tests/init-global/warn/global-cycle2.scala rename tests/init-global/{neg => warn}/global-cycle3.check (100%) create mode 100644 tests/init-global/warn/global-cycle3.scala rename tests/init-global/{neg => warn}/global-cycle4.check (100%) rename tests/init-global/{neg => warn}/global-cycle4.scala (69%) rename tests/init-global/{neg => warn}/global-cycle5.check (100%) rename tests/init-global/{neg => warn}/global-cycle5.scala (70%) rename tests/init-global/{neg => warn}/global-cycle6.check (100%) rename tests/init-global/{neg => warn}/global-cycle6.scala (70%) rename tests/init-global/{neg => warn}/global-cycle7.check (100%) rename tests/init-global/{neg => warn}/global-cycle7.scala (71%) rename tests/init-global/{neg => warn}/global-cycle8.check (100%) rename tests/init-global/{neg => warn}/global-cycle8.scala (69%) rename tests/init-global/{neg => warn}/global-irrelevance1.check (100%) create mode 100644 tests/init-global/warn/global-irrelevance1.scala rename tests/init-global/{neg => warn}/global-irrelevance2.check (100%) create mode 100644 tests/init-global/warn/global-irrelevance2.scala rename tests/init-global/{neg => warn}/global-irrelevance3.check (100%) rename tests/init-global/{neg => warn}/global-irrelevance3.scala (70%) rename tests/init-global/{neg => warn}/global-irrelevance4.check (100%) rename tests/init-global/{neg => warn}/global-irrelevance4.scala (68%) rename tests/init-global/{neg => warn}/global-irrelevance5.check (100%) create mode 100644 tests/init-global/warn/global-irrelevance5.scala rename tests/init-global/{neg => warn}/global-irrelevance6.check (100%) rename tests/init-global/{neg => warn}/global-irrelevance6.scala (62%) rename tests/init-global/{neg => warn}/global-irrelevance7.check (100%) rename tests/init-global/{neg => warn}/global-irrelevance7.scala (64%) rename tests/init-global/{neg => warn}/global-list.check (100%) create mode 100644 tests/init-global/warn/global-list.scala rename tests/init-global/{neg => warn}/global-local-var.check (100%) rename tests/init-global/{neg => warn}/global-local-var.scala (68%) rename tests/init-global/{neg => warn}/global-region1.check (100%) rename tests/init-global/{neg => warn}/global-region1.scala (65%) rename tests/init-global/{neg => warn}/i11262.check (100%) create mode 100644 tests/init-global/warn/i11262.scala rename tests/init-global/{neg => warn}/i12544b.check (100%) rename tests/init-global/{neg => warn}/i12544b.scala (52%) rename tests/init-global/{neg => warn}/i9176.check (100%) rename tests/init-global/{neg => warn}/i9176.scala (65%) rename tests/init-global/{neg => warn}/line-spacing.check (100%) rename tests/init-global/{neg => warn}/line-spacing.scala (50%) rename tests/init-global/{neg => warn}/mutable-array.check (100%) rename tests/init-global/{neg => warn}/mutable-array.scala (63%) rename tests/init-global/{neg => warn}/mutable-read1.check (100%) rename tests/init-global/{neg => warn}/mutable-read1.scala (64%) rename tests/init-global/{neg => warn}/mutable-read2.check (100%) rename tests/init-global/{neg => warn}/mutable-read2.scala (66%) rename tests/init-global/{neg => warn}/mutable-read3.check (100%) rename tests/init-global/{neg => warn}/mutable-read3.scala (66%) rename tests/init-global/{neg => warn}/mutable-read4.check (100%) rename tests/init-global/{neg => warn}/mutable-read4.scala (64%) rename tests/init-global/{neg => warn}/mutable-read5.check (100%) rename tests/init-global/{neg => warn}/mutable-read5.scala (70%) rename tests/init-global/{neg => warn}/mutable-read6.check (100%) rename tests/init-global/{neg => warn}/mutable-read6.scala (78%) rename tests/init-global/{neg => warn}/mutable-read7.check (100%) rename tests/init-global/{neg => warn}/mutable-read7.scala (73%) rename tests/init-global/{neg => warn}/mutable-read8.check (100%) rename tests/init-global/{neg => warn}/mutable-read8.scala (60%) rename tests/init-global/{neg => warn}/partial-ordering.check (100%) rename tests/init-global/{neg => warn}/partial-ordering.scala (73%) rename tests/init-global/{neg => warn}/patmat-unapplySeq.check (100%) rename tests/init-global/{neg => warn}/patmat-unapplySeq.scala (74%) rename tests/init-global/{neg => warn}/patmat-unapplySeq2.check (100%) rename tests/init-global/{neg => warn}/patmat-unapplySeq2.scala (74%) rename tests/init-global/{neg => warn}/patmat.check (100%) rename tests/init-global/{neg => warn}/patmat.scala (84%) rename tests/init-global/{neg => warn}/return.check (100%) rename tests/init-global/{neg => warn}/return.scala (56%) rename tests/init-global/{neg => warn}/return2.check (100%) rename tests/init-global/{neg => warn}/return2.scala (64%) rename tests/init-global/{neg => warn}/t5366.check (100%) rename tests/init-global/{neg => warn}/t5366.scala (61%) rename tests/init-global/{neg => warn}/t9115.check (100%) rename tests/init-global/{neg => warn}/t9115.scala (61%) rename tests/init-global/{neg => warn}/t9261.check (100%) create mode 100644 tests/init-global/warn/t9261.scala rename tests/init-global/{neg => warn}/t9312.check (100%) rename tests/init-global/{neg => warn}/t9312.scala (78%) rename tests/init-global/{neg => warn}/t9360.check (100%) rename tests/init-global/{neg => warn}/t9360.scala (68%) rename tests/init-global/{neg => warn}/unapply-implicit-arg.check (100%) rename tests/init-global/{neg => warn}/unapply-implicit-arg.scala (76%) rename tests/init-global/{neg => warn}/unapply-implicit-arg2.check (100%) rename tests/init-global/{neg => warn}/unapply-implicit-arg2.scala (67%) rename tests/init-global/{neg => warn}/unapply-implicit-arg3.check (100%) rename tests/init-global/{neg => warn}/unapply-implicit-arg3.scala (75%) rename tests/init-global/{neg => warn}/unapplySeq-implicit-arg.check (100%) rename tests/init-global/{neg => warn}/unapplySeq-implicit-arg.scala (78%) rename tests/init-global/{neg => warn}/unapplySeq-implicit-arg2.check (100%) rename tests/init-global/{neg => warn}/unapplySeq-implicit-arg2.scala (72%) rename tests/init-global/{neg => warn}/unapplySeq-implicit-arg3.check (100%) rename tests/init-global/{neg => warn}/unapplySeq-implicit-arg3.scala (70%) diff --git a/tests/init-global/neg/global-cycle1.scala b/tests/init-global/neg/global-cycle1.scala deleted file mode 100644 index 992d3eacc6f5..000000000000 --- a/tests/init-global/neg/global-cycle1.scala +++ /dev/null @@ -1,12 +0,0 @@ -object A { - val a: Int = B.b -} - -object B { - 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-cycle2.scala b/tests/init-global/neg/global-cycle2.scala deleted file mode 100644 index f3bd33a1c179..000000000000 --- a/tests/init-global/neg/global-cycle2.scala +++ /dev/null @@ -1,9 +0,0 @@ -object A { - val a: Int = B.foo() -} - -object B { - 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.scala b/tests/init-global/neg/global-cycle3.scala deleted file mode 100644 index 5e97ba59c735..000000000000 --- a/tests/init-global/neg/global-cycle3.scala +++ /dev/null @@ -1,9 +0,0 @@ -class A(x: Int) { - 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-irrelevance1.scala b/tests/init-global/neg/global-irrelevance1.scala deleted file mode 100644 index 2eb5511001e2..000000000000 --- a/tests/init-global/neg/global-irrelevance1.scala +++ /dev/null @@ -1,6 +0,0 @@ -object A: - var x = 6 - -object B: - 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.scala b/tests/init-global/neg/global-irrelevance2.scala deleted file mode 100644 index 8804eed6cc52..000000000000 --- a/tests/init-global/neg/global-irrelevance2.scala +++ /dev/null @@ -1,10 +0,0 @@ -object A: - var x = 6 - -class B(b: Int): - 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-irrelevance5.scala b/tests/init-global/neg/global-irrelevance5.scala deleted file mode 100644 index a1cff0aeb802..000000000000 --- a/tests/init-global/neg/global-irrelevance5.scala +++ /dev/null @@ -1,8 +0,0 @@ -object A: - val array: Array[Int] = new Array(1) - array(0) = 10 - -object B: - 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-list.scala b/tests/init-global/neg/global-list.scala deleted file mode 100644 index e9fed153f78f..000000000000 --- a/tests/init-global/neg/global-list.scala +++ /dev/null @@ -1,10 +0,0 @@ -case class Foo(name: String) - -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) -// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/i11262.scala b/tests/init-global/neg/i11262.scala deleted file mode 100644 index befc9ca0834d..000000000000 --- a/tests/init-global/neg/i11262.scala +++ /dev/null @@ -1,4 +0,0 @@ -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/t9261.scala b/tests/init-global/neg/t9261.scala deleted file mode 100644 index 9eb7f255492c..000000000000 --- a/tests/init-global/neg/t9261.scala +++ /dev/null @@ -1,5 +0,0 @@ -sealed abstract class OrderType(val reverse: OrderType) -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/context-sensitivity.check b/tests/init-global/warn/context-sensitivity.check similarity index 59% rename from tests/init-global/neg/context-sensitivity.check rename to tests/init-global/warn/context-sensitivity.check index e5eaad3d2a58..bc0453b1bc88 100644 --- a/tests/init-global/neg/context-sensitivity.check +++ b/tests/init-global/warn/context-sensitivity.check @@ -1,11 +1,10 @@ --- Warning: tests/init-global/neg/context-sensitivity.scala:9:21 ------------------------------------------------------- -9 | def foo(): Int = A.m +-- Warning: tests/init-global/warn/context-sensitivity.scala:9:21 ------------------------------------------------------ +9 | def foo(): Int = A.m // warn | ^^^ | 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 ] + | └── def foo(): Int = A.m // warn [ 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/warn/context-sensitivity.scala similarity index 76% rename from tests/init-global/neg/context-sensitivity.scala rename to tests/init-global/warn/context-sensitivity.scala index 7b7477df5773..9150a81619cc 100644 --- a/tests/init-global/neg/context-sensitivity.scala +++ b/tests/init-global/warn/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 + def foo(): Int = A.m // warn } class Box(var value: Foo) @@ -16,4 +16,3 @@ object A: 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/warn/global-cycle1.check similarity index 100% rename from tests/init-global/neg/global-cycle1.check rename to tests/init-global/warn/global-cycle1.check diff --git a/tests/init-global/warn/global-cycle1.scala b/tests/init-global/warn/global-cycle1.scala new file mode 100644 index 000000000000..37c3c59f6926 --- /dev/null +++ b/tests/init-global/warn/global-cycle1.scala @@ -0,0 +1,11 @@ +object A { + val a: Int = B.b +} + +object B { + val b: Int = A.a +} + +@main +def Test = print(A.a) + diff --git a/tests/init-global/neg/global-cycle14.check b/tests/init-global/warn/global-cycle14.check similarity index 100% rename from tests/init-global/neg/global-cycle14.check rename to tests/init-global/warn/global-cycle14.check diff --git a/tests/init-global/neg/global-cycle14.scala b/tests/init-global/warn/global-cycle14.scala similarity index 58% rename from tests/init-global/neg/global-cycle14.scala rename to tests/init-global/warn/global-cycle14.scala index 35a3019a2a64..5028d70cf13c 100644 --- a/tests/init-global/neg/global-cycle14.scala +++ b/tests/init-global/warn/global-cycle14.scala @@ -5,12 +5,11 @@ object O { val d = Data(3) } -object A { +object A { val n: Int = B.m } object B { - val m: Int = A.n + 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/warn/global-cycle2.check similarity index 100% rename from tests/init-global/neg/global-cycle2.check rename to tests/init-global/warn/global-cycle2.check diff --git a/tests/init-global/warn/global-cycle2.scala b/tests/init-global/warn/global-cycle2.scala new file mode 100644 index 000000000000..396e257befd3 --- /dev/null +++ b/tests/init-global/warn/global-cycle2.scala @@ -0,0 +1,8 @@ +object A { + val a: Int = B.foo() +} + +object B { + def foo(): Int = A.a * 2 +} + diff --git a/tests/init-global/neg/global-cycle3.check b/tests/init-global/warn/global-cycle3.check similarity index 100% rename from tests/init-global/neg/global-cycle3.check rename to tests/init-global/warn/global-cycle3.check diff --git a/tests/init-global/warn/global-cycle3.scala b/tests/init-global/warn/global-cycle3.scala new file mode 100644 index 000000000000..e37a15cb4e5b --- /dev/null +++ b/tests/init-global/warn/global-cycle3.scala @@ -0,0 +1,8 @@ +class A(x: Int) { + def foo(): Int = B.a + 10 +} + +object B { + val a: Int = A(4).foo() +} + diff --git a/tests/init-global/neg/global-cycle4.check b/tests/init-global/warn/global-cycle4.check similarity index 100% rename from tests/init-global/neg/global-cycle4.check rename to tests/init-global/warn/global-cycle4.check diff --git a/tests/init-global/neg/global-cycle4.scala b/tests/init-global/warn/global-cycle4.scala similarity index 69% rename from tests/init-global/neg/global-cycle4.scala rename to tests/init-global/warn/global-cycle4.scala index 789d682da3be..d61bca1ad2e3 100644 --- a/tests/init-global/neg/global-cycle4.scala +++ b/tests/init-global/warn/global-cycle4.scala @@ -7,7 +7,7 @@ class B extends A { } class C extends A { - def foo(): Int = O.a + 10 + def foo(): Int = O.a + 10 } class D(x: Int) { @@ -18,4 +18,3 @@ 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/warn/global-cycle5.check similarity index 100% rename from tests/init-global/neg/global-cycle5.check rename to tests/init-global/warn/global-cycle5.check diff --git a/tests/init-global/neg/global-cycle5.scala b/tests/init-global/warn/global-cycle5.scala similarity index 70% rename from tests/init-global/neg/global-cycle5.scala rename to tests/init-global/warn/global-cycle5.scala index 281ea9b879d1..c6eede89f901 100644 --- a/tests/init-global/neg/global-cycle5.scala +++ b/tests/init-global/warn/global-cycle5.scala @@ -7,7 +7,7 @@ object A { } object B { - val b: Int = A.a.foo() + val b: Int = A.a.foo() } class Y extends X { @@ -21,4 +21,3 @@ object C { def main = { A.a = new Y(); C } -// 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/warn/global-cycle6.check similarity index 100% rename from tests/init-global/neg/global-cycle6.check rename to tests/init-global/warn/global-cycle6.check diff --git a/tests/init-global/neg/global-cycle6.scala b/tests/init-global/warn/global-cycle6.scala similarity index 70% rename from tests/init-global/neg/global-cycle6.scala rename to tests/init-global/warn/global-cycle6.scala index 88adc536b307..216628fe6b38 100644 --- a/tests/init-global/neg/global-cycle6.scala +++ b/tests/init-global/warn/global-cycle6.scala @@ -1,7 +1,7 @@ -object A { +object A { val n: Int = B.m class Inner { - println(n) + println(n) } } @@ -23,4 +23,3 @@ object O { val m: Int = 10 } } -// 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/warn/global-cycle7.check similarity index 100% rename from tests/init-global/neg/global-cycle7.check rename to tests/init-global/warn/global-cycle7.check diff --git a/tests/init-global/neg/global-cycle7.scala b/tests/init-global/warn/global-cycle7.scala similarity index 71% rename from tests/init-global/neg/global-cycle7.scala rename to tests/init-global/warn/global-cycle7.scala index b8084984aeec..bffe6e0ff564 100644 --- a/tests/init-global/neg/global-cycle7.scala +++ b/tests/init-global/warn/global-cycle7.scala @@ -1,9 +1,9 @@ -object A { +object A { val n: Int = B.m } object B { - val m: Int = A.n + val m: Int = A.n } abstract class TokensCommon { @@ -17,4 +17,3 @@ object JavaTokens extends TokensCommon { 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/warn/global-cycle8.check similarity index 100% rename from tests/init-global/neg/global-cycle8.check rename to tests/init-global/warn/global-cycle8.check diff --git a/tests/init-global/neg/global-cycle8.scala b/tests/init-global/warn/global-cycle8.scala similarity index 69% rename from tests/init-global/neg/global-cycle8.scala rename to tests/init-global/warn/global-cycle8.scala index 91290da30353..6b3c4b9fffc6 100644 --- a/tests/init-global/neg/global-cycle8.scala +++ b/tests/init-global/warn/global-cycle8.scala @@ -6,7 +6,7 @@ class B { val a = new A } -object O { +object O { val n: Int = 10 println(P.m) } @@ -19,4 +19,3 @@ 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/warn/global-irrelevance1.check similarity index 100% rename from tests/init-global/neg/global-irrelevance1.check rename to tests/init-global/warn/global-irrelevance1.check diff --git a/tests/init-global/warn/global-irrelevance1.scala b/tests/init-global/warn/global-irrelevance1.scala new file mode 100644 index 000000000000..5cc6f8f39049 --- /dev/null +++ b/tests/init-global/warn/global-irrelevance1.scala @@ -0,0 +1,5 @@ +object A: + var x = 6 + +object B: + var y = A.x * 2 diff --git a/tests/init-global/neg/global-irrelevance2.check b/tests/init-global/warn/global-irrelevance2.check similarity index 100% rename from tests/init-global/neg/global-irrelevance2.check rename to tests/init-global/warn/global-irrelevance2.check diff --git a/tests/init-global/warn/global-irrelevance2.scala b/tests/init-global/warn/global-irrelevance2.scala new file mode 100644 index 000000000000..ad1f2e1b4fb4 --- /dev/null +++ b/tests/init-global/warn/global-irrelevance2.scala @@ -0,0 +1,9 @@ +object A: + var x = 6 + +class B(b: Int): + A.x = b * 2 + +object B: + new B(10) + diff --git a/tests/init-global/neg/global-irrelevance3.check b/tests/init-global/warn/global-irrelevance3.check similarity index 100% rename from tests/init-global/neg/global-irrelevance3.check rename to tests/init-global/warn/global-irrelevance3.check diff --git a/tests/init-global/neg/global-irrelevance3.scala b/tests/init-global/warn/global-irrelevance3.scala similarity index 70% rename from tests/init-global/neg/global-irrelevance3.scala rename to tests/init-global/warn/global-irrelevance3.scala index 4b53c0335314..7c2c42fe0490 100644 --- a/tests/init-global/neg/global-irrelevance3.scala +++ b/tests/init-global/warn/global-irrelevance3.scala @@ -6,11 +6,10 @@ object A: var x = 6 new Pair( y => x = y, - (() => x) + (() => 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/warn/global-irrelevance4.check similarity index 100% rename from tests/init-global/neg/global-irrelevance4.check rename to tests/init-global/warn/global-irrelevance4.check diff --git a/tests/init-global/neg/global-irrelevance4.scala b/tests/init-global/warn/global-irrelevance4.scala similarity index 68% rename from tests/init-global/neg/global-irrelevance4.scala rename to tests/init-global/warn/global-irrelevance4.scala index caf7f2bb6466..00bd77a63393 100644 --- a/tests/init-global/neg/global-irrelevance4.scala +++ b/tests/init-global/warn/global-irrelevance4.scala @@ -5,11 +5,10 @@ object A: def foo(): Pair = var x = 6 new Pair( - (y => x = y), + (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/warn/global-irrelevance5.check similarity index 100% rename from tests/init-global/neg/global-irrelevance5.check rename to tests/init-global/warn/global-irrelevance5.check diff --git a/tests/init-global/warn/global-irrelevance5.scala b/tests/init-global/warn/global-irrelevance5.scala new file mode 100644 index 000000000000..e47548ce2088 --- /dev/null +++ b/tests/init-global/warn/global-irrelevance5.scala @@ -0,0 +1,7 @@ +object A: + val array: Array[Int] = new Array(1) + array(0) = 10 + +object B: + var y = A.array(0) * 2 + diff --git a/tests/init-global/neg/global-irrelevance6.check b/tests/init-global/warn/global-irrelevance6.check similarity index 100% rename from tests/init-global/neg/global-irrelevance6.check rename to tests/init-global/warn/global-irrelevance6.check diff --git a/tests/init-global/neg/global-irrelevance6.scala b/tests/init-global/warn/global-irrelevance6.scala similarity index 62% rename from tests/init-global/neg/global-irrelevance6.scala rename to tests/init-global/warn/global-irrelevance6.scala index a16849a81934..a2727cf1d0b9 100644 --- a/tests/init-global/neg/global-irrelevance6.scala +++ b/tests/init-global/warn/global-irrelevance6.scala @@ -6,6 +6,5 @@ object A: val n = array(0).foo() // ok, no crash object B: - var y = A.array(0).foo() * 2 + 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/warn/global-irrelevance7.check similarity index 100% rename from tests/init-global/neg/global-irrelevance7.check rename to tests/init-global/warn/global-irrelevance7.check diff --git a/tests/init-global/neg/global-irrelevance7.scala b/tests/init-global/warn/global-irrelevance7.scala similarity index 64% rename from tests/init-global/neg/global-irrelevance7.scala rename to tests/init-global/warn/global-irrelevance7.scala index f679c9cc60b7..e55f646cbc39 100644 --- a/tests/init-global/neg/global-irrelevance7.scala +++ b/tests/init-global/warn/global-irrelevance7.scala @@ -7,6 +7,5 @@ object A: val n = array(0).foo() // ok object B: - var y = A.array(0).foo() * 2 + 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/warn/global-list.check similarity index 100% rename from tests/init-global/neg/global-list.check rename to tests/init-global/warn/global-list.check diff --git a/tests/init-global/warn/global-list.scala b/tests/init-global/warn/global-list.scala new file mode 100644 index 000000000000..eb8fad77372b --- /dev/null +++ b/tests/init-global/warn/global-list.scala @@ -0,0 +1,9 @@ +case class Foo(name: String) + +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) diff --git a/tests/init-global/neg/global-local-var.check b/tests/init-global/warn/global-local-var.check similarity index 100% rename from tests/init-global/neg/global-local-var.check rename to tests/init-global/warn/global-local-var.check diff --git a/tests/init-global/neg/global-local-var.scala b/tests/init-global/warn/global-local-var.scala similarity index 68% rename from tests/init-global/neg/global-local-var.scala rename to tests/init-global/warn/global-local-var.scala index 9db071de5ae8..c9c2d07e615e 100644 --- a/tests/init-global/neg/global-local-var.scala +++ b/tests/init-global/warn/global-local-var.scala @@ -7,7 +7,7 @@ class A(x: Int) { sum += i i += 1 - B.a + 10 + sum + B.a + 10 + sum } } @@ -15,4 +15,3 @@ 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/warn/global-region1.check similarity index 100% rename from tests/init-global/neg/global-region1.check rename to tests/init-global/warn/global-region1.check diff --git a/tests/init-global/neg/global-region1.scala b/tests/init-global/warn/global-region1.scala similarity index 65% rename from tests/init-global/neg/global-region1.scala rename to tests/init-global/warn/global-region1.scala index f47e10a06424..611c2bea553c 100644 --- a/tests/init-global/neg/global-region1.scala +++ b/tests/init-global/warn/global-region1.scala @@ -1,6 +1,6 @@ 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 } +class D(var y: Int) extends B { def foo(): Int = A.m } class Box(var value: B) object A: @@ -8,4 +8,3 @@ object A: 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/warn/i11262.check similarity index 100% rename from tests/init-global/neg/i11262.check rename to tests/init-global/warn/i11262.check diff --git a/tests/init-global/warn/i11262.scala b/tests/init-global/warn/i11262.scala new file mode 100644 index 000000000000..78e779e00efc --- /dev/null +++ b/tests/init-global/warn/i11262.scala @@ -0,0 +1,3 @@ +object A { val x: String = B.y } +object B { val y: String = A.x } + diff --git a/tests/init-global/neg/i12544b.check b/tests/init-global/warn/i12544b.check similarity index 100% rename from tests/init-global/neg/i12544b.check rename to tests/init-global/warn/i12544b.check diff --git a/tests/init-global/neg/i12544b.scala b/tests/init-global/warn/i12544b.scala similarity index 52% rename from tests/init-global/neg/i12544b.scala rename to tests/init-global/warn/i12544b.scala index 759829e3bd75..886d1619fc10 100644 --- a/tests/init-global/neg/i12544b.scala +++ b/tests/init-global/warn/i12544b.scala @@ -2,13 +2,12 @@ enum Enum: case Case object Enum: - object nested: + object nested: val a: Enum = Case - val b: Enum = f(nested.a) + 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/warn/i9176.check similarity index 100% rename from tests/init-global/neg/i9176.check rename to tests/init-global/warn/i9176.check diff --git a/tests/init-global/neg/i9176.scala b/tests/init-global/warn/i9176.scala similarity index 65% rename from tests/init-global/neg/i9176.scala rename to tests/init-global/warn/i9176.scala index fe1c5388029e..82776d85fcd9 100644 --- a/tests/init-global/neg/i9176.scala +++ b/tests/init-global/warn/i9176.scala @@ -1,5 +1,5 @@ class Foo(val opposite: Foo) -case object A extends Foo(B) +case object A extends Foo(B) case object B extends Foo(A) object Test { def main(args: Array[String]): Unit = { @@ -8,4 +8,3 @@ object Test { } } -// 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/warn/line-spacing.check similarity index 100% rename from tests/init-global/neg/line-spacing.check rename to tests/init-global/warn/line-spacing.check diff --git a/tests/init-global/neg/line-spacing.scala b/tests/init-global/warn/line-spacing.scala similarity index 50% rename from tests/init-global/neg/line-spacing.scala rename to tests/init-global/warn/line-spacing.scala index 7855e82954b8..334425bbc9a8 100644 --- a/tests/init-global/neg/line-spacing.scala +++ b/tests/init-global/warn/line-spacing.scala @@ -1,11 +1,10 @@ object A { def a: Int = B - .s.length + .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/warn/mutable-array.check similarity index 100% rename from tests/init-global/neg/mutable-array.check rename to tests/init-global/warn/mutable-array.check diff --git a/tests/init-global/neg/mutable-array.scala b/tests/init-global/warn/mutable-array.scala similarity index 63% rename from tests/init-global/neg/mutable-array.scala rename to tests/init-global/warn/mutable-array.scala index 4fea9a813423..7b26656b5acb 100644 --- a/tests/init-global/neg/mutable-array.scala +++ b/tests/init-global/warn/mutable-array.scala @@ -5,6 +5,5 @@ object A: object B: val boxes: Array[A.Box] = Array(A.box) val box: A.Box = boxes(0) - val x: Int = box.value + 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/warn/mutable-read1.check similarity index 100% rename from tests/init-global/neg/mutable-read1.check rename to tests/init-global/warn/mutable-read1.check diff --git a/tests/init-global/neg/mutable-read1.scala b/tests/init-global/warn/mutable-read1.scala similarity index 64% rename from tests/init-global/neg/mutable-read1.scala rename to tests/init-global/warn/mutable-read1.scala index 78aa0e1c4ff3..1fb3e8935c59 100644 --- a/tests/init-global/neg/mutable-read1.scala +++ b/tests/init-global/warn/mutable-read1.scala @@ -7,5 +7,4 @@ object B: val boxB: Box = new Box(5) val boxA: Box = A.box val m: Int = boxB.value - val n: Int = boxA.value -// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file + val n: Int = boxA.value diff --git a/tests/init-global/neg/mutable-read2.check b/tests/init-global/warn/mutable-read2.check similarity index 100% rename from tests/init-global/neg/mutable-read2.check rename to tests/init-global/warn/mutable-read2.check diff --git a/tests/init-global/neg/mutable-read2.scala b/tests/init-global/warn/mutable-read2.scala similarity index 66% rename from tests/init-global/neg/mutable-read2.scala rename to tests/init-global/warn/mutable-read2.scala index d223de11d801..d982d78e153e 100644 --- a/tests/init-global/neg/mutable-read2.scala +++ b/tests/init-global/warn/mutable-read2.scala @@ -7,5 +7,4 @@ object A: object B: val box: A.Box = A.box val a: Int = box.initial - val b: Int = box.value -// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file + val b: Int = box.value diff --git a/tests/init-global/neg/mutable-read3.check b/tests/init-global/warn/mutable-read3.check similarity index 100% rename from tests/init-global/neg/mutable-read3.check rename to tests/init-global/warn/mutable-read3.check diff --git a/tests/init-global/neg/mutable-read3.scala b/tests/init-global/warn/mutable-read3.scala similarity index 66% rename from tests/init-global/neg/mutable-read3.scala rename to tests/init-global/warn/mutable-read3.scala index d5cf067f7609..057cfe6f25b9 100644 --- a/tests/init-global/neg/mutable-read3.scala +++ b/tests/init-global/warn/mutable-read3.scala @@ -6,5 +6,4 @@ 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 -// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file + val x: Int = box.value diff --git a/tests/init-global/neg/mutable-read4.check b/tests/init-global/warn/mutable-read4.check similarity index 100% rename from tests/init-global/neg/mutable-read4.check rename to tests/init-global/warn/mutable-read4.check diff --git a/tests/init-global/neg/mutable-read4.scala b/tests/init-global/warn/mutable-read4.scala similarity index 64% rename from tests/init-global/neg/mutable-read4.scala rename to tests/init-global/warn/mutable-read4.scala index 78aa0e1c4ff3..1fb3e8935c59 100644 --- a/tests/init-global/neg/mutable-read4.scala +++ b/tests/init-global/warn/mutable-read4.scala @@ -7,5 +7,4 @@ object B: val boxB: Box = new Box(5) val boxA: Box = A.box val m: Int = boxB.value - val n: Int = boxA.value -// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file + val n: Int = boxA.value diff --git a/tests/init-global/neg/mutable-read5.check b/tests/init-global/warn/mutable-read5.check similarity index 100% rename from tests/init-global/neg/mutable-read5.check rename to tests/init-global/warn/mutable-read5.check diff --git a/tests/init-global/neg/mutable-read5.scala b/tests/init-global/warn/mutable-read5.scala similarity index 70% rename from tests/init-global/neg/mutable-read5.scala rename to tests/init-global/warn/mutable-read5.scala index 884f027c970e..c48eeff365c4 100644 --- a/tests/init-global/neg/mutable-read5.scala +++ b/tests/init-global/warn/mutable-read5.scala @@ -1,10 +1,9 @@ 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) + 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") -// 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/warn/mutable-read6.check similarity index 100% rename from tests/init-global/neg/mutable-read6.check rename to tests/init-global/warn/mutable-read6.check diff --git a/tests/init-global/neg/mutable-read6.scala b/tests/init-global/warn/mutable-read6.scala similarity index 78% rename from tests/init-global/neg/mutable-read6.scala rename to tests/init-global/warn/mutable-read6.scala index ce6034769f60..1b706a576060 100644 --- a/tests/init-global/neg/mutable-read6.scala +++ b/tests/init-global/warn/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 + final def source: SourceFile = _source def setSource(source: SourceFile) = { this._source = source } @@ -13,4 +13,3 @@ object Implicits: import Contexts.* case class SearchFailure(tag: Int, source: SourceFile) 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/warn/mutable-read7.check similarity index 100% rename from tests/init-global/neg/mutable-read7.check rename to tests/init-global/warn/mutable-read7.check diff --git a/tests/init-global/neg/mutable-read7.scala b/tests/init-global/warn/mutable-read7.scala similarity index 73% rename from tests/init-global/neg/mutable-read7.scala rename to tests/init-global/warn/mutable-read7.scala index b840bdc11a5d..83da25fc0c25 100644 --- a/tests/init-global/neg/mutable-read7.scala +++ b/tests/init-global/warn/mutable-read7.scala @@ -4,11 +4,10 @@ object Positioned: var nextId: Int = 0 abstract class Positioned: - if (Positioned.debug) { + if (Positioned.debug) { println("do debugging") } object Trees: class Tree extends Positioned 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/warn/mutable-read8.check similarity index 100% rename from tests/init-global/neg/mutable-read8.check rename to tests/init-global/warn/mutable-read8.check diff --git a/tests/init-global/neg/mutable-read8.scala b/tests/init-global/warn/mutable-read8.scala similarity index 60% rename from tests/init-global/neg/mutable-read8.scala rename to tests/init-global/warn/mutable-read8.scala index 0e84fe534b26..7dc55830cee4 100644 --- a/tests/init-global/neg/mutable-read8.scala +++ b/tests/init-global/warn/mutable-read8.scala @@ -3,10 +3,9 @@ object Stats { } class UncachedGroundType { - if (Stats.monitored) println("record stats") + if (Stats.monitored) println("record stats") } class LazyType extends UncachedGroundType 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/warn/partial-ordering.check similarity index 100% rename from tests/init-global/neg/partial-ordering.check rename to tests/init-global/warn/partial-ordering.check diff --git a/tests/init-global/neg/partial-ordering.scala b/tests/init-global/warn/partial-ordering.scala similarity index 73% rename from tests/init-global/neg/partial-ordering.scala rename to tests/init-global/warn/partial-ordering.scala index 7cc1333706a9..d0e05c13174e 100644 --- a/tests/init-global/neg/partial-ordering.scala +++ b/tests/init-global/warn/partial-ordering.scala @@ -1,4 +1,4 @@ -object Names: +object Names: val ctorString = "" val ctorName: MethodName = MethodName.apply(ctorString) @@ -6,4 +6,3 @@ class MethodName(encoded: String) object MethodName: val ctor: MethodName = new MethodName(Names.ctorString) 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/warn/patmat-unapplySeq.check similarity index 100% rename from tests/init-global/neg/patmat-unapplySeq.check rename to tests/init-global/warn/patmat-unapplySeq.check diff --git a/tests/init-global/neg/patmat-unapplySeq.scala b/tests/init-global/warn/patmat-unapplySeq.scala similarity index 74% rename from tests/init-global/neg/patmat-unapplySeq.scala rename to tests/init-global/warn/patmat-unapplySeq.scala index 3f0f1c60c801..1849cf0478e1 100644 --- a/tests/init-global/neg/patmat-unapplySeq.scala +++ b/tests/init-global/warn/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) + def apply(i: Int): Box = array(i) def drop(n: Int): Seq[Box] = array.toSeq def toSeq: Seq[Box] = array.toSeq @@ -16,4 +16,3 @@ 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/warn/patmat-unapplySeq2.check similarity index 100% rename from tests/init-global/neg/patmat-unapplySeq2.check rename to tests/init-global/warn/patmat-unapplySeq2.check diff --git a/tests/init-global/neg/patmat-unapplySeq2.scala b/tests/init-global/warn/patmat-unapplySeq2.scala similarity index 74% rename from tests/init-global/neg/patmat-unapplySeq2.scala rename to tests/init-global/warn/patmat-unapplySeq2.scala index c890a09efd2e..c93b05650a8e 100644 --- a/tests/init-global/neg/patmat-unapplySeq2.scala +++ b/tests/init-global/warn/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) + def apply(i: Int): Box = array(i) def drop(n: Int): Seq[Box] = array.toSeq def toSeq: Seq[Box] = array.toSeq @@ -16,4 +16,3 @@ 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/warn/patmat.check similarity index 100% rename from tests/init-global/neg/patmat.check rename to tests/init-global/warn/patmat.check diff --git a/tests/init-global/neg/patmat.scala b/tests/init-global/warn/patmat.scala similarity index 84% rename from tests/init-global/neg/patmat.scala rename to tests/init-global/warn/patmat.scala index 05f6ea0cdbac..0d3e74e42cbe 100644 --- a/tests/init-global/neg/patmat.scala +++ b/tests/init-global/warn/patmat.scala @@ -1,4 +1,4 @@ -object A: +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: + object Inner: val b: Int = 10 val foo: () => Int = () => C.a @@ -35,4 +35,3 @@ object C: 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/warn/return.check similarity index 100% rename from tests/init-global/neg/return.check rename to tests/init-global/warn/return.check diff --git a/tests/init-global/neg/return.scala b/tests/init-global/warn/return.scala similarity index 56% rename from tests/init-global/neg/return.scala rename to tests/init-global/warn/return.scala index 442b0f200f45..fb138d381fa5 100644 --- a/tests/init-global/neg/return.scala +++ b/tests/init-global/warn/return.scala @@ -1,7 +1,7 @@ object A: def foo(x: Int): Int => Int = if x <= 0 then - return (a: Int) => a + B.n + return (a: Int) => a + B.n (a: Int) => a * a + x @@ -9,4 +9,3 @@ 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/warn/return2.check similarity index 100% rename from tests/init-global/neg/return2.check rename to tests/init-global/warn/return2.check diff --git a/tests/init-global/neg/return2.scala b/tests/init-global/warn/return2.scala similarity index 64% rename from tests/init-global/neg/return2.scala rename to tests/init-global/warn/return2.scala index 3c93fe9120c6..c41154e8caa5 100644 --- a/tests/init-global/neg/return2.scala +++ b/tests/init-global/warn/return2.scala @@ -1,6 +1,6 @@ object A: def foo(x: Int): Int => Int = - val f = (a: Int) => a + B.n + val f = (a: Int) => a + B.n var i = 0 val g = () => return f @@ -12,4 +12,3 @@ 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/warn/t5366.check similarity index 100% rename from tests/init-global/neg/t5366.check rename to tests/init-global/warn/t5366.check diff --git a/tests/init-global/neg/t5366.scala b/tests/init-global/warn/t5366.scala similarity index 61% rename from tests/init-global/neg/t5366.scala rename to tests/init-global/warn/t5366.scala index 2283b79bfb8f..2c1b18889a2d 100644 --- a/tests/init-global/neg/t5366.scala +++ b/tests/init-global/warn/t5366.scala @@ -1,9 +1,9 @@ class IdAndMsg(val id: Int, val msg: String = "") -case object ObjA extends IdAndMsg(1) +case object ObjA extends IdAndMsg(1) case object ObjB extends IdAndMsg(2) -object IdAndMsg { +object IdAndMsg { val values = List(ObjA , ObjB) } @@ -13,4 +13,3 @@ object Test { println(IdAndMsg.values) } } -// 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/warn/t9115.check similarity index 100% rename from tests/init-global/neg/t9115.check rename to tests/init-global/warn/t9115.check diff --git a/tests/init-global/neg/t9115.scala b/tests/init-global/warn/t9115.scala similarity index 61% rename from tests/init-global/neg/t9115.scala rename to tests/init-global/warn/t9115.scala index aa9573554260..fc1e8e72c6e3 100644 --- a/tests/init-global/neg/t9115.scala +++ b/tests/init-global/warn/t9115.scala @@ -1,10 +1,9 @@ -object D { +object D { def aaa = 1 //that’s the reason class Z (depends: Any) - case object D1 extends Z(aaa) + 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/warn/t9261.check similarity index 100% rename from tests/init-global/neg/t9261.check rename to tests/init-global/warn/t9261.check diff --git a/tests/init-global/warn/t9261.scala b/tests/init-global/warn/t9261.scala new file mode 100644 index 000000000000..0888337d7a94 --- /dev/null +++ b/tests/init-global/warn/t9261.scala @@ -0,0 +1,4 @@ +sealed abstract class OrderType(val reverse: OrderType) +case object Buy extends OrderType(Sell) +case object Sell extends OrderType(Buy) + diff --git a/tests/init-global/neg/t9312.check b/tests/init-global/warn/t9312.check similarity index 100% rename from tests/init-global/neg/t9312.check rename to tests/init-global/warn/t9312.check diff --git a/tests/init-global/neg/t9312.scala b/tests/init-global/warn/t9312.scala similarity index 78% rename from tests/init-global/neg/t9312.scala rename to tests/init-global/warn/t9312.scala index 7dc9af580162..d06a7f1bcefb 100644 --- a/tests/init-global/neg/t9312.scala +++ b/tests/init-global/warn/t9312.scala @@ -8,18 +8,17 @@ object DeadLockTest { } - object Parent { + object Parent { trait Child { Thread.sleep(2000) // ensure concurrent behavior val parent = Parent def siblings = parent.children - this } - object Child1 extends Child + 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/warn/t9360.check similarity index 100% rename from tests/init-global/neg/t9360.check rename to tests/init-global/warn/t9360.check diff --git a/tests/init-global/neg/t9360.scala b/tests/init-global/warn/t9360.scala similarity index 68% rename from tests/init-global/neg/t9360.scala rename to tests/init-global/warn/t9360.scala index 0fca843cd01d..423da308064b 100644 --- a/tests/init-global/neg/t9360.scala +++ b/tests/init-global/warn/t9360.scala @@ -2,10 +2,10 @@ class BaseClass(s: String) { def print: Unit = () } -object Obj { +object Obj { val s: String = "hello" - object AObj extends BaseClass(s) + object AObj extends BaseClass(s) object BObj extends BaseClass(s) @@ -24,4 +24,3 @@ object ObjectInit { } } -// 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/warn/unapply-implicit-arg.check similarity index 100% rename from tests/init-global/neg/unapply-implicit-arg.check rename to tests/init-global/warn/unapply-implicit-arg.check diff --git a/tests/init-global/neg/unapply-implicit-arg.scala b/tests/init-global/warn/unapply-implicit-arg.scala similarity index 76% rename from tests/init-global/neg/unapply-implicit-arg.scala rename to tests/init-global/warn/unapply-implicit-arg.scala index dd8d03821d0a..5bccff951b4d 100644 --- a/tests/init-global/neg/unapply-implicit-arg.scala +++ b/tests/init-global/warn/unapply-implicit-arg.scala @@ -8,8 +8,7 @@ object Bar { given Foo = new Foo val i1: Int = 0 - val i2: Int = i2 match + val i2: Int = 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/unapply-implicit-arg2.check b/tests/init-global/warn/unapply-implicit-arg2.check similarity index 100% rename from tests/init-global/neg/unapply-implicit-arg2.check rename to tests/init-global/warn/unapply-implicit-arg2.check diff --git a/tests/init-global/neg/unapply-implicit-arg2.scala b/tests/init-global/warn/unapply-implicit-arg2.scala similarity index 67% rename from tests/init-global/neg/unapply-implicit-arg2.scala rename to tests/init-global/warn/unapply-implicit-arg2.scala index b180e5eee495..7e1e53881f2e 100644 --- a/tests/init-global/neg/unapply-implicit-arg2.scala +++ b/tests/init-global/warn/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)) + if i == 0 then Some(f1.m1(i1)) else Some(f1.m2(i2)) given Foo = new Foo val i1: Int = 0 @@ -13,4 +13,3 @@ 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/unapply-implicit-arg3.check b/tests/init-global/warn/unapply-implicit-arg3.check similarity index 100% rename from tests/init-global/neg/unapply-implicit-arg3.check rename to tests/init-global/warn/unapply-implicit-arg3.check diff --git a/tests/init-global/neg/unapply-implicit-arg3.scala b/tests/init-global/warn/unapply-implicit-arg3.scala similarity index 75% rename from tests/init-global/neg/unapply-implicit-arg3.scala rename to tests/init-global/warn/unapply-implicit-arg3.scala index 3bf923eeeb4e..1d2fa76d5299 100644 --- a/tests/init-global/neg/unapply-implicit-arg3.scala +++ b/tests/init-global/warn/unapply-implicit-arg3.scala @@ -1,7 +1,7 @@ object Bar { class Foo { def m1(i: Int) = i + i1 - def m2(i: Int) = i + i2 + 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)) @@ -13,4 +13,3 @@ 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/unapplySeq-implicit-arg.check b/tests/init-global/warn/unapplySeq-implicit-arg.check similarity index 100% rename from tests/init-global/neg/unapplySeq-implicit-arg.check rename to tests/init-global/warn/unapplySeq-implicit-arg.check diff --git a/tests/init-global/neg/unapplySeq-implicit-arg.scala b/tests/init-global/warn/unapplySeq-implicit-arg.scala similarity index 78% rename from tests/init-global/neg/unapplySeq-implicit-arg.scala rename to tests/init-global/warn/unapplySeq-implicit-arg.scala index 1ec3ab6fa79a..31e16e74897a 100644 --- a/tests/init-global/neg/unapplySeq-implicit-arg.scala +++ b/tests/init-global/warn/unapplySeq-implicit-arg.scala @@ -8,9 +8,8 @@ object Bar { given Foo = new Foo val i1: Int = 0 - val i2: Int = Seq(i2) match + 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/warn/unapplySeq-implicit-arg2.check similarity index 100% rename from tests/init-global/neg/unapplySeq-implicit-arg2.check rename to tests/init-global/warn/unapplySeq-implicit-arg2.check diff --git a/tests/init-global/neg/unapplySeq-implicit-arg2.scala b/tests/init-global/warn/unapplySeq-implicit-arg2.scala similarity index 72% rename from tests/init-global/neg/unapplySeq-implicit-arg2.scala rename to tests/init-global/warn/unapplySeq-implicit-arg2.scala index 7a48651a3a7a..0d506c778e17 100644 --- a/tests/init-global/neg/unapplySeq-implicit-arg2.scala +++ b/tests/init-global/warn/unapplySeq-implicit-arg2.scala @@ -1,7 +1,7 @@ object Bar { class Foo def unapplySeq(using f1: Foo)(using f2: Foo)(seqi: Seq[Int])(using Foo): Option[Seq[Int]] = - Some(i1 +: seqi) + Some(i1 +: seqi) given Foo = new Foo val i1: Int = Seq(0) match { case Bar(i) => i @@ -9,4 +9,3 @@ object Bar { } } -// 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/warn/unapplySeq-implicit-arg3.check similarity index 100% rename from tests/init-global/neg/unapplySeq-implicit-arg3.check rename to tests/init-global/warn/unapplySeq-implicit-arg3.check diff --git a/tests/init-global/neg/unapplySeq-implicit-arg3.scala b/tests/init-global/warn/unapplySeq-implicit-arg3.scala similarity index 70% rename from tests/init-global/neg/unapplySeq-implicit-arg3.scala rename to tests/init-global/warn/unapplySeq-implicit-arg3.scala index 9efcac577bd3..c941e9b6f65c 100644 --- a/tests/init-global/neg/unapplySeq-implicit-arg3.scala +++ b/tests/init-global/warn/unapplySeq-implicit-arg3.scala @@ -1,6 +1,6 @@ object Bar { class Foo { - def m(seq: Seq[Int]) = i1 +: seq + def m(seq: Seq[Int]) = i1 +: seq } def unapplySeq(using f1: Foo)(seqi: Seq[Int])(using Foo): Option[Seq[Int]] = Some(f1.m(seqi)) @@ -11,4 +11,3 @@ object Bar { } } -// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file From 749fc3c94a08d64d12ebec30e963942a32ad927b Mon Sep 17 00:00:00 2001 From: Szymon Rodziewicz Date: Fri, 26 Jan 2024 17:25:42 +0100 Subject: [PATCH 4/5] Fixed warn tests for init-global --- .../dotty/tools/dotc/CompilationTests.scala | 1 - tests/init-global/warn/global-cycle1.check | 15 +++--- tests/init-global/warn/global-cycle1.scala | 5 +- tests/init-global/warn/global-cycle14.check | 15 +++--- tests/init-global/warn/global-cycle14.scala | 5 +- tests/init-global/warn/global-cycle2.check | 7 ++- tests/init-global/warn/global-cycle2.scala | 3 +- tests/init-global/warn/global-cycle3.check | 7 ++- tests/init-global/warn/global-cycle3.scala | 3 +- tests/init-global/warn/global-cycle4.check | 7 ++- tests/init-global/warn/global-cycle4.scala | 3 +- tests/init-global/warn/global-cycle5.check | 7 ++- tests/init-global/warn/global-cycle5.scala | 4 +- tests/init-global/warn/global-cycle6.check | 15 +++--- tests/init-global/warn/global-cycle6.scala | 6 +-- tests/init-global/warn/global-cycle7.check | 15 +++--- tests/init-global/warn/global-cycle7.scala | 5 +- tests/init-global/warn/global-cycle8.check | 7 ++- tests/init-global/warn/global-cycle8.scala | 3 +- .../warn/global-irrelevance1.check | 7 ++- .../warn/global-irrelevance1.scala | 2 +- .../warn/global-irrelevance2.check | 7 ++- .../warn/global-irrelevance2.scala | 3 +- .../warn/global-irrelevance3.check | 7 ++- .../warn/global-irrelevance3.scala | 3 +- .../warn/global-irrelevance4.check | 7 ++- .../warn/global-irrelevance4.scala | 3 +- .../warn/global-irrelevance5.check | 7 ++- .../warn/global-irrelevance5.scala | 3 +- .../warn/global-irrelevance6.check | 7 ++- .../warn/global-irrelevance6.scala | 3 +- .../warn/global-irrelevance7.check | 7 ++- .../warn/global-irrelevance7.scala | 3 +- tests/init-global/warn/global-list.check | 51 +++++++++---------- tests/init-global/warn/global-list.scala | 4 +- tests/init-global/warn/global-local-var.check | 7 ++- tests/init-global/warn/global-local-var.scala | 3 +- tests/init-global/warn/global-region1.check | 19 ++++--- tests/init-global/warn/global-region1.scala | 3 +- tests/init-global/warn/i11262.check | 15 +++--- tests/init-global/warn/i11262.scala | 5 +- tests/init-global/warn/i12544b.check | 15 +++--- tests/init-global/warn/i12544b.scala | 5 +- tests/init-global/warn/i9176.check | 7 ++- tests/init-global/warn/i9176.scala | 3 +- tests/init-global/warn/line-spacing.check | 7 ++- tests/init-global/warn/line-spacing.scala | 3 +- tests/init-global/warn/mutable-array.check | 7 ++- tests/init-global/warn/mutable-array.scala | 3 +- tests/init-global/warn/mutable-read1.check | 7 ++- tests/init-global/warn/mutable-read1.scala | 2 +- tests/init-global/warn/mutable-read2.check | 7 ++- tests/init-global/warn/mutable-read2.scala | 2 +- tests/init-global/warn/mutable-read3.check | 7 ++- tests/init-global/warn/mutable-read3.scala | 2 +- tests/init-global/warn/mutable-read4.check | 7 ++- tests/init-global/warn/mutable-read4.scala | 2 +- tests/init-global/warn/mutable-read5.check | 7 ++- tests/init-global/warn/mutable-read5.scala | 4 +- tests/init-global/warn/mutable-read6.check | 7 ++- tests/init-global/warn/mutable-read6.scala | 4 +- tests/init-global/warn/mutable-read7.check | 7 ++- tests/init-global/warn/mutable-read7.scala | 4 +- tests/init-global/warn/mutable-read8.check | 7 ++- tests/init-global/warn/mutable-read8.scala | 4 +- tests/init-global/warn/partial-ordering.check | 7 ++- tests/init-global/warn/partial-ordering.scala | 4 +- .../init-global/warn/patmat-unapplySeq.check | 7 ++- .../init-global/warn/patmat-unapplySeq.scala | 3 +- .../init-global/warn/patmat-unapplySeq2.check | 7 ++- .../init-global/warn/patmat-unapplySeq2.scala | 3 +- tests/init-global/warn/patmat.check | 13 +++-- tests/init-global/warn/patmat.scala | 5 +- tests/init-global/warn/return.check | 7 ++- tests/init-global/warn/return.scala | 3 +- tests/init-global/warn/return2.check | 11 ++-- tests/init-global/warn/return2.scala | 5 +- tests/init-global/warn/t5366.check | 15 +++--- tests/init-global/warn/t5366.scala | 6 +-- tests/init-global/warn/t9115.check | 15 +++--- tests/init-global/warn/t9115.scala | 5 +- tests/init-global/warn/t9261.check | 7 ++- tests/init-global/warn/t9261.scala | 3 +- tests/init-global/warn/t9312.check | 15 +++--- tests/init-global/warn/t9312.scala | 5 +- tests/init-global/warn/t9360.check | 15 +++--- tests/init-global/warn/t9360.scala | 5 +- .../warn/unapply-implicit-arg.check | 7 ++- .../warn/unapply-implicit-arg.scala | 4 +- .../warn/unapply-implicit-arg2.check | 23 ++++----- .../warn/unapply-implicit-arg2.scala | 3 +- .../warn/unapply-implicit-arg3.check | 7 ++- .../warn/unapply-implicit-arg3.scala | 3 +- .../warn/unapplySeq-implicit-arg.check | 7 ++- .../warn/unapplySeq-implicit-arg.scala | 3 +- .../warn/unapplySeq-implicit-arg2.check | 7 ++- .../warn/unapplySeq-implicit-arg2.scala | 3 +- .../warn/unapplySeq-implicit-arg3.check | 7 ++- .../warn/unapplySeq-implicit-arg3.scala | 3 +- 99 files changed, 299 insertions(+), 383 deletions(-) diff --git a/compiler/test/dotty/tools/dotc/CompilationTests.scala b/compiler/test/dotty/tools/dotc/CompilationTests.scala index 95b5362d77c0..d1ec6eeda0bd 100644 --- a/compiler/test/dotty/tools/dotc/CompilationTests.scala +++ b/compiler/test/dotty/tools/dotc/CompilationTests.scala @@ -216,7 +216,6 @@ 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, 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() } diff --git a/tests/init-global/warn/global-cycle1.check b/tests/init-global/warn/global-cycle1.check index 81859776b06f..adee7e47dd54 100644 --- a/tests/init-global/warn/global-cycle1.check +++ b/tests/init-global/warn/global-cycle1.check @@ -1,21 +1,20 @@ --- Warning: tests/init-global/neg/global-cycle1.scala:1:7 -------------------------------------------------------------- -1 |object A { +-- Warning: tests/init-global/warn/global-cycle1.scala:1:7 ------------------------------------------------------------- +1 |object A { // warn | ^ | Cyclic initialization: object A -> object B -> object A. Calling trace: - | ├── object A { [ global-cycle1.scala:1 ] + | ├── object A { // warn [ global-cycle1.scala:1 ] | │ ^ | ├── val a: Int = B.b [ global-cycle1.scala:2 ] | │ ^ | ├── object B { [ global-cycle1.scala:5 ] | │ ^ - | └── val b: Int = A.a [ global-cycle1.scala:6 ] + | └── val b: Int = A.a // warn [ global-cycle1.scala:6 ] | ^ --- Warning: tests/init-global/neg/global-cycle1.scala:6:17 ------------------------------------------------------------- -6 | val b: Int = A.a +-- Warning: tests/init-global/warn/global-cycle1.scala:6:17 ------------------------------------------------------------ +6 | val b: Int = A.a // warn | ^^^ | Access uninitialized field value a. Calling trace: | ├── object B { [ global-cycle1.scala:5 ] | │ ^ - | └── val b: Int = A.a [ global-cycle1.scala:6 ] + | └── val b: Int = A.a // warn [ global-cycle1.scala:6 ] | ^^^ -No warnings can be incurred under -Werror. diff --git a/tests/init-global/warn/global-cycle1.scala b/tests/init-global/warn/global-cycle1.scala index 37c3c59f6926..e3951f155b76 100644 --- a/tests/init-global/warn/global-cycle1.scala +++ b/tests/init-global/warn/global-cycle1.scala @@ -1,11 +1,10 @@ -object A { +object A { // warn val a: Int = B.b } object B { - val b: Int = A.a + val b: Int = A.a // warn } @main def Test = print(A.a) - diff --git a/tests/init-global/warn/global-cycle14.check b/tests/init-global/warn/global-cycle14.check index d976653c05f0..ebdb4667f877 100644 --- a/tests/init-global/warn/global-cycle14.check +++ b/tests/init-global/warn/global-cycle14.check @@ -1,21 +1,20 @@ --- Warning: tests/init-global/neg/global-cycle14.scala:8:7 ------------------------------------------------------------- -8 |object A { +-- Warning: tests/init-global/warn/global-cycle14.scala:8:7 ------------------------------------------------------------ +8 |object A { // warn | ^ | Cyclic initialization: object A -> object B -> object A. Calling trace: - | ├── object A { [ global-cycle14.scala:8 ] + | ├── object A { // warn [ 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 ] + | └── val m: Int = A.n // warn [ global-cycle14.scala:13 ] | ^ --- Warning: tests/init-global/neg/global-cycle14.scala:13:17 ----------------------------------------------------------- -13 | val m: Int = A.n +-- Warning: tests/init-global/warn/global-cycle14.scala:13:17 ---------------------------------------------------------- +13 | val m: Int = A.n // warn | ^^^ | Access uninitialized field value n. Calling trace: | ├── object B { [ global-cycle14.scala:12 ] | │ ^ - | └── val m: Int = A.n [ global-cycle14.scala:13 ] + | └── val m: Int = A.n // warn [ global-cycle14.scala:13 ] | ^^^ -No warnings can be incurred under -Werror. diff --git a/tests/init-global/warn/global-cycle14.scala b/tests/init-global/warn/global-cycle14.scala index 5028d70cf13c..696c7ba672f3 100644 --- a/tests/init-global/warn/global-cycle14.scala +++ b/tests/init-global/warn/global-cycle14.scala @@ -5,11 +5,10 @@ object O { val d = Data(3) } -object A { +object A { // warn val n: Int = B.m } object B { - val m: Int = A.n + val m: Int = A.n // warn } - diff --git a/tests/init-global/warn/global-cycle2.check b/tests/init-global/warn/global-cycle2.check index e01fb2f15aea..37c99b36ac25 100644 --- a/tests/init-global/warn/global-cycle2.check +++ b/tests/init-global/warn/global-cycle2.check @@ -1,11 +1,10 @@ --- Warning: tests/init-global/neg/global-cycle2.scala:6:21 ------------------------------------------------------------- -6 | def foo(): Int = A.a * 2 +-- Warning: tests/init-global/warn/global-cycle2.scala:6:21 ------------------------------------------------------------ +6 | def foo(): Int = A.a * 2 // warn | ^^^ | 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 ] + | └── def foo(): Int = A.a * 2 // warn [ global-cycle2.scala:6 ] | ^^^ -No warnings can be incurred under -Werror. diff --git a/tests/init-global/warn/global-cycle2.scala b/tests/init-global/warn/global-cycle2.scala index 396e257befd3..90ca855b00e8 100644 --- a/tests/init-global/warn/global-cycle2.scala +++ b/tests/init-global/warn/global-cycle2.scala @@ -3,6 +3,5 @@ object A { } object B { - def foo(): Int = A.a * 2 + def foo(): Int = A.a * 2 // warn } - diff --git a/tests/init-global/warn/global-cycle3.check b/tests/init-global/warn/global-cycle3.check index 1b3ccd8dd857..d250c3fda5e3 100644 --- a/tests/init-global/warn/global-cycle3.check +++ b/tests/init-global/warn/global-cycle3.check @@ -1,11 +1,10 @@ --- Warning: tests/init-global/neg/global-cycle3.scala:2:21 ------------------------------------------------------------- -2 | def foo(): Int = B.a + 10 +-- Warning: tests/init-global/warn/global-cycle3.scala:2:21 ------------------------------------------------------------ +2 | def foo(): Int = B.a + 10 // warn | ^^^ | 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 ] + | └── def foo(): Int = B.a + 10 // warn [ global-cycle3.scala:2 ] | ^^^ -No warnings can be incurred under -Werror. diff --git a/tests/init-global/warn/global-cycle3.scala b/tests/init-global/warn/global-cycle3.scala index e37a15cb4e5b..9d72ac6321fb 100644 --- a/tests/init-global/warn/global-cycle3.scala +++ b/tests/init-global/warn/global-cycle3.scala @@ -1,8 +1,7 @@ class A(x: Int) { - def foo(): Int = B.a + 10 + def foo(): Int = B.a + 10 // warn } object B { val a: Int = A(4).foo() } - diff --git a/tests/init-global/warn/global-cycle4.check b/tests/init-global/warn/global-cycle4.check index 68a4dcae4b77..030f62782631 100644 --- a/tests/init-global/warn/global-cycle4.check +++ b/tests/init-global/warn/global-cycle4.check @@ -1,11 +1,10 @@ --- Warning: tests/init-global/neg/global-cycle4.scala:10:21 ------------------------------------------------------------ -10 | def foo(): Int = O.a + 10 +-- Warning: tests/init-global/warn/global-cycle4.scala:10:21 ----------------------------------------------------------- +10 | def foo(): Int = O.a + 10 // warn | ^^^ | 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 ] + | └── def foo(): Int = O.a + 10 // warn [ global-cycle4.scala:10 ] | ^^^ -No warnings can be incurred under -Werror. diff --git a/tests/init-global/warn/global-cycle4.scala b/tests/init-global/warn/global-cycle4.scala index d61bca1ad2e3..dea2a0b486cf 100644 --- a/tests/init-global/warn/global-cycle4.scala +++ b/tests/init-global/warn/global-cycle4.scala @@ -7,7 +7,7 @@ class B extends A { } class C extends A { - def foo(): Int = O.a + 10 + def foo(): Int = O.a + 10 // warn } class D(x: Int) { @@ -17,4 +17,3 @@ class D(x: Int) { object O { val a: Int = D(5).bar().foo() } - diff --git a/tests/init-global/warn/global-cycle5.check b/tests/init-global/warn/global-cycle5.check index c1d21cb77a45..072a80e4530f 100644 --- a/tests/init-global/warn/global-cycle5.check +++ b/tests/init-global/warn/global-cycle5.check @@ -1,10 +1,9 @@ --- Warning: tests/init-global/neg/global-cycle5.scala:10:17 ------------------------------------------------------------ -10 | val b: Int = A.a.foo() +-- Warning: tests/init-global/warn/global-cycle5.scala:10:17 ----------------------------------------------------------- +10 | val b: Int = A.a.foo() // warn | ^^^ |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 ] + |└── val b: Int = A.a.foo() // warn [ global-cycle5.scala:10 ] | ^^^ -No warnings can be incurred under -Werror. diff --git a/tests/init-global/warn/global-cycle5.scala b/tests/init-global/warn/global-cycle5.scala index c6eede89f901..7c3710cb815b 100644 --- a/tests/init-global/warn/global-cycle5.scala +++ b/tests/init-global/warn/global-cycle5.scala @@ -7,7 +7,7 @@ object A { } object B { - val b: Int = A.a.foo() + val b: Int = A.a.foo() // warn } class Y extends X { @@ -20,4 +20,4 @@ object C { def main = { A.a = new Y(); C -} +} \ No newline at end of file diff --git a/tests/init-global/warn/global-cycle6.check b/tests/init-global/warn/global-cycle6.check index 47a1c1543773..b6454a5d2cce 100644 --- a/tests/init-global/warn/global-cycle6.check +++ b/tests/init-global/warn/global-cycle6.check @@ -1,8 +1,8 @@ --- Warning: tests/init-global/neg/global-cycle6.scala:1:7 -------------------------------------------------------------- -1 |object A { +-- Warning: tests/init-global/warn/global-cycle6.scala:1:7 ------------------------------------------------------------- +1 |object A { // warn | ^ | Cyclic initialization: object A -> object B -> object A. Calling trace: - | ├── object A { [ global-cycle6.scala:1 ] + | ├── object A { // warn [ global-cycle6.scala:1 ] | │ ^ | ├── val n: Int = B.m [ global-cycle6.scala:2 ] | │ ^ @@ -12,10 +12,10 @@ | │ ^^^^^^^^^^^ | ├── class Inner { [ global-cycle6.scala:3 ] | │ ^ - | └── println(n) [ global-cycle6.scala:4 ] + | └── println(n) // warn [ global-cycle6.scala:4 ] | ^ --- Warning: tests/init-global/neg/global-cycle6.scala:4:12 ------------------------------------------------------------- -4 | println(n) +-- Warning: tests/init-global/warn/global-cycle6.scala:4:12 ------------------------------------------------------------ +4 | println(n) // warn | ^ | Access uninitialized field value n. Calling trace: | ├── object B { [ global-cycle6.scala:8 ] @@ -24,6 +24,5 @@ | │ ^^^^^^^^^^^ | ├── class Inner { [ global-cycle6.scala:3 ] | │ ^ - | └── println(n) [ global-cycle6.scala:4 ] + | └── println(n) // warn [ global-cycle6.scala:4 ] | ^ -No warnings can be incurred under -Werror. diff --git a/tests/init-global/warn/global-cycle6.scala b/tests/init-global/warn/global-cycle6.scala index 216628fe6b38..030e08d37117 100644 --- a/tests/init-global/warn/global-cycle6.scala +++ b/tests/init-global/warn/global-cycle6.scala @@ -1,7 +1,7 @@ -object A { +object A { // warn val n: Int = B.m class Inner { - println(n) + println(n) // warn } } @@ -22,4 +22,4 @@ object O { val a = new A.Inner val m: Int = 10 } -} +} \ No newline at end of file diff --git a/tests/init-global/warn/global-cycle7.check b/tests/init-global/warn/global-cycle7.check index 96a63b77b73e..366857885769 100644 --- a/tests/init-global/warn/global-cycle7.check +++ b/tests/init-global/warn/global-cycle7.check @@ -1,21 +1,20 @@ --- Warning: tests/init-global/neg/global-cycle7.scala:1:7 -------------------------------------------------------------- -1 |object A { +-- Warning: tests/init-global/warn/global-cycle7.scala:1:7 ------------------------------------------------------------- +1 |object A { // warn | ^ | Cyclic initialization: object A -> object B -> object A. Calling trace: - | ├── object A { [ global-cycle7.scala:1 ] + | ├── object A { // warn [ 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 ] + | └── val m: Int = A.n // warn [ global-cycle7.scala:6 ] | ^ --- Warning: tests/init-global/neg/global-cycle7.scala:6:17 ------------------------------------------------------------- -6 | val m: Int = A.n +-- Warning: tests/init-global/warn/global-cycle7.scala:6:17 ------------------------------------------------------------ +6 | val m: Int = A.n // warn | ^^^ | Access uninitialized field value n. Calling trace: | ├── object B { [ global-cycle7.scala:5 ] | │ ^ - | └── val m: Int = A.n [ global-cycle7.scala:6 ] + | └── val m: Int = A.n // warn [ global-cycle7.scala:6 ] | ^^^ -No warnings can be incurred under -Werror. diff --git a/tests/init-global/warn/global-cycle7.scala b/tests/init-global/warn/global-cycle7.scala index bffe6e0ff564..30b74ceb95c4 100644 --- a/tests/init-global/warn/global-cycle7.scala +++ b/tests/init-global/warn/global-cycle7.scala @@ -1,9 +1,9 @@ -object A { +object A { // warn val n: Int = B.m } object B { - val m: Int = A.n + val m: Int = A.n // warn } abstract class TokensCommon { @@ -16,4 +16,3 @@ object JavaTokens extends TokensCommon { final def maxToken: Int = DOUBLE final val DOUBLE = 188 } - diff --git a/tests/init-global/warn/global-cycle8.check b/tests/init-global/warn/global-cycle8.check index 6dc544fe8e7c..93c9699c653e 100644 --- a/tests/init-global/warn/global-cycle8.check +++ b/tests/init-global/warn/global-cycle8.check @@ -1,8 +1,8 @@ --- Warning: tests/init-global/neg/global-cycle8.scala:9:7 -------------------------------------------------------------- -9 |object O { +-- Warning: tests/init-global/warn/global-cycle8.scala:9:7 ------------------------------------------------------------- +9 |object O { // warn | ^ | Cyclic initialization: object O -> object P -> object O. Calling trace: - | ├── object O { [ global-cycle8.scala:9 ] + | ├── object O { // warn [ global-cycle8.scala:9 ] | │ ^ | ├── println(P.m) [ global-cycle8.scala:11 ] | │ ^ @@ -14,4 +14,3 @@ | │ ^^^^^^^^^ | └── def foo() = println(O.n) [ global-cycle8.scala:2 ] | ^ -No warnings can be incurred under -Werror. diff --git a/tests/init-global/warn/global-cycle8.scala b/tests/init-global/warn/global-cycle8.scala index 6b3c4b9fffc6..de4e6620585d 100644 --- a/tests/init-global/warn/global-cycle8.scala +++ b/tests/init-global/warn/global-cycle8.scala @@ -6,7 +6,7 @@ class B { val a = new A } -object O { +object O { // warn val n: Int = 10 println(P.m) } @@ -18,4 +18,3 @@ object P { object Q { def bar(b: B) = b.a.foo() } - diff --git a/tests/init-global/warn/global-irrelevance1.check b/tests/init-global/warn/global-irrelevance1.check index 799d80ec9623..447ba6b6b29a 100644 --- a/tests/init-global/warn/global-irrelevance1.check +++ b/tests/init-global/warn/global-irrelevance1.check @@ -1,10 +1,9 @@ --- Warning: tests/init-global/neg/global-irrelevance1.scala:5:12 ------------------------------------------------------- -5 | var y = A.x * 2 +-- Warning: tests/init-global/warn/global-irrelevance1.scala:5:12 ------------------------------------------------------ +5 | var y = A.x * 2 // warn | ^^^ |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 ] + |└── var y = A.x * 2 // warn [ global-irrelevance1.scala:5 ] | ^^^ -No warnings can be incurred under -Werror. diff --git a/tests/init-global/warn/global-irrelevance1.scala b/tests/init-global/warn/global-irrelevance1.scala index 5cc6f8f39049..d19099f287ba 100644 --- a/tests/init-global/warn/global-irrelevance1.scala +++ b/tests/init-global/warn/global-irrelevance1.scala @@ -2,4 +2,4 @@ object A: var x = 6 object B: - var y = A.x * 2 + var y = A.x * 2 // warn \ No newline at end of file diff --git a/tests/init-global/warn/global-irrelevance2.check b/tests/init-global/warn/global-irrelevance2.check index 56263b936308..156b34fa6aa5 100644 --- a/tests/init-global/warn/global-irrelevance2.check +++ b/tests/init-global/warn/global-irrelevance2.check @@ -1,5 +1,5 @@ --- Warning: tests/init-global/neg/global-irrelevance2.scala:5:6 -------------------------------------------------------- -5 | A.x = b * 2 +-- Warning: tests/init-global/warn/global-irrelevance2.scala:5:6 ------------------------------------------------------- +5 | A.x = b * 2 // warn | ^^^^^^^^^^^^ | Mutating object A during initialization of object B. | Mutating other static objects during the initialization of one static object is forbidden. Calling trace: @@ -9,6 +9,5 @@ | │ ^^^^^^^^^ | ├── class B(b: Int): [ global-irrelevance2.scala:4 ] | │ ^ - | └── A.x = b * 2 [ global-irrelevance2.scala:5 ] + | └── A.x = b * 2 // warn [ global-irrelevance2.scala:5 ] | ^^^^^^^^^^^^ -No warnings can be incurred under -Werror. diff --git a/tests/init-global/warn/global-irrelevance2.scala b/tests/init-global/warn/global-irrelevance2.scala index ad1f2e1b4fb4..9bf7acab4343 100644 --- a/tests/init-global/warn/global-irrelevance2.scala +++ b/tests/init-global/warn/global-irrelevance2.scala @@ -2,8 +2,7 @@ object A: var x = 6 class B(b: Int): - A.x = b * 2 + A.x = b * 2 // warn object B: new B(10) - diff --git a/tests/init-global/warn/global-irrelevance3.check b/tests/init-global/warn/global-irrelevance3.check index 7d7f9dbfb1fc..dba945224f97 100644 --- a/tests/init-global/warn/global-irrelevance3.check +++ b/tests/init-global/warn/global-irrelevance3.check @@ -1,5 +1,5 @@ --- Warning: tests/init-global/neg/global-irrelevance3.scala:9:13 ------------------------------------------------------- -9 | (() => x) +-- Warning: tests/init-global/warn/global-irrelevance3.scala:9:13 ------------------------------------------------------ +9 | (() => x) // warn | ^ |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,6 +7,5 @@ |│ ^ |├── var y = A.p.g() [ global-irrelevance3.scala:14 ] |│ ^^^^^^^ - |└── (() => x) [ global-irrelevance3.scala:9 ] + |└── (() => x) // warn [ global-irrelevance3.scala:9 ] | ^ -No warnings can be incurred under -Werror. diff --git a/tests/init-global/warn/global-irrelevance3.scala b/tests/init-global/warn/global-irrelevance3.scala index 7c2c42fe0490..f8db31f14a72 100644 --- a/tests/init-global/warn/global-irrelevance3.scala +++ b/tests/init-global/warn/global-irrelevance3.scala @@ -6,10 +6,9 @@ object A: var x = 6 new Pair( y => x = y, - (() => x) + (() => x) // warn ) object B: var y = A.p.g() - diff --git a/tests/init-global/warn/global-irrelevance4.check b/tests/init-global/warn/global-irrelevance4.check index ebabde96294d..7253e5b39688 100644 --- a/tests/init-global/warn/global-irrelevance4.check +++ b/tests/init-global/warn/global-irrelevance4.check @@ -1,5 +1,5 @@ --- Warning: tests/init-global/neg/global-irrelevance4.scala:8:9 -------------------------------------------------------- -8 | (y => x = y), +-- Warning: tests/init-global/warn/global-irrelevance4.scala:8:9 ------------------------------------------------------- +8 | (y => x = y), // warn | ^^^^^^^^^^ | Mutating object A during initialization of object B. | Mutating other static objects during the initialization of one static object is forbidden. Calling trace: @@ -7,6 +7,5 @@ | │ ^ | ├── A.p.f(10) [ global-irrelevance4.scala:13 ] | │ ^^^^^^^^^ - | └── (y => x = y), [ global-irrelevance4.scala:8 ] + | └── (y => x = y), // warn [ global-irrelevance4.scala:8 ] | ^^^^^^^^^^ -No warnings can be incurred under -Werror. diff --git a/tests/init-global/warn/global-irrelevance4.scala b/tests/init-global/warn/global-irrelevance4.scala index 00bd77a63393..4ddf3d78e4ae 100644 --- a/tests/init-global/warn/global-irrelevance4.scala +++ b/tests/init-global/warn/global-irrelevance4.scala @@ -5,10 +5,9 @@ object A: def foo(): Pair = var x = 6 new Pair( - (y => x = y), + (y => x = y), // warn () => x ) object B: A.p.f(10) - diff --git a/tests/init-global/warn/global-irrelevance5.check b/tests/init-global/warn/global-irrelevance5.check index 7d472621821c..c3581e0b9bbc 100644 --- a/tests/init-global/warn/global-irrelevance5.check +++ b/tests/init-global/warn/global-irrelevance5.check @@ -1,10 +1,9 @@ --- Warning: tests/init-global/neg/global-irrelevance5.scala:6:17 ------------------------------------------------------- -6 | var y = A.array(0) * 2 +-- Warning: tests/init-global/warn/global-irrelevance5.scala:6:17 ------------------------------------------------------ +6 | var y = A.array(0) * 2 // warn | ^^^^^^^^^^ |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 ] + |└── var y = A.array(0) * 2 // warn [ global-irrelevance5.scala:6 ] | ^^^^^^^^^^ -No warnings can be incurred under -Werror. diff --git a/tests/init-global/warn/global-irrelevance5.scala b/tests/init-global/warn/global-irrelevance5.scala index e47548ce2088..f557157ded21 100644 --- a/tests/init-global/warn/global-irrelevance5.scala +++ b/tests/init-global/warn/global-irrelevance5.scala @@ -3,5 +3,4 @@ object A: array(0) = 10 object B: - var y = A.array(0) * 2 - + var y = A.array(0) * 2 // warn diff --git a/tests/init-global/warn/global-irrelevance6.check b/tests/init-global/warn/global-irrelevance6.check index 52df6bd253e2..3e447a915ba3 100644 --- a/tests/init-global/warn/global-irrelevance6.check +++ b/tests/init-global/warn/global-irrelevance6.check @@ -1,10 +1,9 @@ --- Warning: tests/init-global/neg/global-irrelevance6.scala:9:17 ------------------------------------------------------- -9 | var y = A.array(0).foo() * 2 +-- Warning: tests/init-global/warn/global-irrelevance6.scala:9:17 ------------------------------------------------------ +9 | var y = A.array(0).foo() * 2 // warn | ^^^^^^^^^^ |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 ] + |└── var y = A.array(0).foo() * 2 // warn [ global-irrelevance6.scala:9 ] | ^^^^^^^^^^ -No warnings can be incurred under -Werror. diff --git a/tests/init-global/warn/global-irrelevance6.scala b/tests/init-global/warn/global-irrelevance6.scala index a2727cf1d0b9..43983f05ffac 100644 --- a/tests/init-global/warn/global-irrelevance6.scala +++ b/tests/init-global/warn/global-irrelevance6.scala @@ -6,5 +6,4 @@ object A: val n = array(0).foo() // ok, no crash object B: - var y = A.array(0).foo() * 2 - + var y = A.array(0).foo() * 2 // warn diff --git a/tests/init-global/warn/global-irrelevance7.check b/tests/init-global/warn/global-irrelevance7.check index 3178c21cbca5..c5f0da1a204b 100644 --- a/tests/init-global/warn/global-irrelevance7.check +++ b/tests/init-global/warn/global-irrelevance7.check @@ -1,10 +1,9 @@ --- Warning: tests/init-global/neg/global-irrelevance7.scala:10:17 ------------------------------------------------------ -10 | var y = A.array(0).foo() * 2 +-- Warning: tests/init-global/warn/global-irrelevance7.scala:10:17 ----------------------------------------------------- +10 | var y = A.array(0).foo() * 2 // warn | ^^^^^^^^^^ |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 ] + |└── var y = A.array(0).foo() * 2 // warn [ global-irrelevance7.scala:10 ] | ^^^^^^^^^^ -No warnings can be incurred under -Werror. diff --git a/tests/init-global/warn/global-irrelevance7.scala b/tests/init-global/warn/global-irrelevance7.scala index e55f646cbc39..5f92dde9a3f9 100644 --- a/tests/init-global/warn/global-irrelevance7.scala +++ b/tests/init-global/warn/global-irrelevance7.scala @@ -7,5 +7,4 @@ object A: val n = array(0).foo() // ok object B: - var y = A.array(0).foo() * 2 - + var y = A.array(0).foo() * 2 // warn diff --git a/tests/init-global/warn/global-list.check b/tests/init-global/warn/global-list.check index 4d4bc3d7e8ca..f8a57918e411 100644 --- a/tests/init-global/warn/global-list.check +++ b/tests/init-global/warn/global-list.check @@ -1,37 +1,36 @@ --- Warning: tests/init-global/neg/global-list.scala:3:7 ---------------------------------------------------------------- -3 |object O: +-- Warning: tests/init-global/warn/global-list.scala:3:7 --------------------------------------------------------------- +3 |object O: // warn | ^ | Cyclic initialization: object O -> object Foo -> object O. Calling trace: - | ├── object O: [ global-list.scala:3 ] + | ├── object O: // warn [ 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 ] + | └── val all: List[Foo] = List(O.a, O.b, O.c) // warn // warn // warn [ 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) +-- Warning: tests/init-global/warn/global-list.scala:9:30 -------------------------------------------------------------- +9 | val all: List[Foo] = List(O.a, O.b, O.c) // warn // warn // warn | ^^^ - | 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 a. Calling trace: + | ├── object Foo: [ global-list.scala:8 ] + | │ ^ + | └── val all: List[Foo] = List(O.a, O.b, O.c) // warn // warn // warn [ global-list.scala:9 ] + | ^^^ +-- Warning: tests/init-global/warn/global-list.scala:9:35 -------------------------------------------------------------- +9 | val all: List[Foo] = List(O.a, O.b, O.c) // warn // warn // warn | ^^^ - | 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 b. Calling trace: + | ├── object Foo: [ global-list.scala:8 ] + | │ ^ + | └── val all: List[Foo] = List(O.a, O.b, O.c) // warn // warn // warn [ global-list.scala:9 ] + | ^^^ +-- Warning: tests/init-global/warn/global-list.scala:9:40 -------------------------------------------------------------- +9 | val all: List[Foo] = List(O.a, O.b, O.c) // warn // warn // warn | ^^^ - | 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. + | Access uninitialized field value c. Calling trace: + | ├── object Foo: [ global-list.scala:8 ] + | │ ^ + | └── val all: List[Foo] = List(O.a, O.b, O.c) // warn // warn // warn [ global-list.scala:9 ] + | ^^^ diff --git a/tests/init-global/warn/global-list.scala b/tests/init-global/warn/global-list.scala index eb8fad77372b..8202d03584a9 100644 --- a/tests/init-global/warn/global-list.scala +++ b/tests/init-global/warn/global-list.scala @@ -1,9 +1,9 @@ case class Foo(name: String) -object O: +object O: // warn 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) + val all: List[Foo] = List(O.a, O.b, O.c) // warn // warn // warn \ No newline at end of file diff --git a/tests/init-global/warn/global-local-var.check b/tests/init-global/warn/global-local-var.check index bbedc06dce3d..028ad87e6716 100644 --- a/tests/init-global/warn/global-local-var.check +++ b/tests/init-global/warn/global-local-var.check @@ -1,5 +1,5 @@ --- Warning: tests/init-global/neg/global-local-var.scala:10:6 ---------------------------------------------------------- -10 | B.a + 10 + sum +-- Warning: tests/init-global/warn/global-local-var.scala:10:6 --------------------------------------------------------- +10 | B.a + 10 + sum // warn | ^^^ | Access uninitialized field value a. Calling trace: | ├── object B { [ global-local-var.scala:14 ] @@ -8,6 +8,5 @@ | │ ^^^^^^^^^^ | ├── def foo(): Int = { [ global-local-var.scala:2 ] | │ ^ - | └── B.a + 10 + sum [ global-local-var.scala:10 ] + | └── B.a + 10 + sum // warn [ global-local-var.scala:10 ] | ^^^ -No warnings can be incurred under -Werror. diff --git a/tests/init-global/warn/global-local-var.scala b/tests/init-global/warn/global-local-var.scala index c9c2d07e615e..384694d7aa15 100644 --- a/tests/init-global/warn/global-local-var.scala +++ b/tests/init-global/warn/global-local-var.scala @@ -7,11 +7,10 @@ class A(x: Int) { sum += i i += 1 - B.a + 10 + sum + B.a + 10 + sum // warn } } object B { val a: Int = A(4).foo() } - diff --git a/tests/init-global/warn/global-region1.check b/tests/init-global/warn/global-region1.check index b3b7e2a3b7ca..342de87cfa05 100644 --- a/tests/init-global/warn/global-region1.check +++ b/tests/init-global/warn/global-region1.check @@ -1,11 +1,10 @@ --- Warning: tests/init-global/neg/global-region1.scala:3:51 ------------------------------------------------------------ -3 |class D(var y: Int) extends B { def foo(): Int = A.m } +-- Warning: tests/init-global/warn/global-region1.scala:3:51 ----------------------------------------------------------- +3 |class D(var y: Int) extends B { def foo(): Int = A.m } // warn | ^^^ - | 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. + | 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 } // warn [ global-region1.scala:3 ] + | ^^^ diff --git a/tests/init-global/warn/global-region1.scala b/tests/init-global/warn/global-region1.scala index 611c2bea553c..91789507a373 100644 --- a/tests/init-global/warn/global-region1.scala +++ b/tests/init-global/warn/global-region1.scala @@ -1,10 +1,9 @@ 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 } +class D(var y: Int) extends B { def foo(): Int = A.m } // warn 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() - diff --git a/tests/init-global/warn/i11262.check b/tests/init-global/warn/i11262.check index 643a70838167..ac80445e9886 100644 --- a/tests/init-global/warn/i11262.check +++ b/tests/init-global/warn/i11262.check @@ -1,15 +1,14 @@ --- Warning: tests/init-global/neg/i11262.scala:1:7 --------------------------------------------------------------------- -1 |object A { val x: String = B.y } +-- Warning: tests/init-global/warn/i11262.scala:1:7 -------------------------------------------------------------------- +1 |object A { val x: String = B.y } // warn | ^ | Cyclic initialization: object A -> object B -> object A. Calling trace: - | ├── object A { val x: String = B.y } [ i11262.scala:1 ] + | ├── object A { val x: String = B.y } // warn [ i11262.scala:1 ] | │ ^ - | └── object B { val y: String = A.x } [ i11262.scala:2 ] + | └── object B { val y: String = A.x } // warn [ i11262.scala:2 ] | ^ --- Warning: tests/init-global/neg/i11262.scala:2:29 -------------------------------------------------------------------- -2 |object B { val y: String = A.x } +-- Warning: tests/init-global/warn/i11262.scala:2:29 ------------------------------------------------------------------- +2 |object B { val y: String = A.x } // warn | ^^^ | Access uninitialized field value x. Calling trace: - | └── object B { val y: String = A.x } [ i11262.scala:2 ] + | └── object B { val y: String = A.x } // warn [ i11262.scala:2 ] | ^^^ -No warnings can be incurred under -Werror. diff --git a/tests/init-global/warn/i11262.scala b/tests/init-global/warn/i11262.scala index 78e779e00efc..896e4db4a0ed 100644 --- a/tests/init-global/warn/i11262.scala +++ b/tests/init-global/warn/i11262.scala @@ -1,3 +1,2 @@ -object A { val x: String = B.y } -object B { val y: String = A.x } - +object A { val x: String = B.y } // warn +object B { val y: String = A.x } // warn diff --git a/tests/init-global/warn/i12544b.check b/tests/init-global/warn/i12544b.check index 7680b62d0b7b..9f97ea36f7fa 100644 --- a/tests/init-global/warn/i12544b.check +++ b/tests/init-global/warn/i12544b.check @@ -1,21 +1,20 @@ --- Warning: tests/init-global/neg/i12544b.scala:5:9 -------------------------------------------------------------------- -5 | object nested: +-- Warning: tests/init-global/warn/i12544b.scala:5:9 ------------------------------------------------------------------- +5 | object nested: // warn | ^ | Cyclic initialization: object nested -> object Enum -> object nested. Calling trace: - | ├── object nested: [ i12544b.scala:5 ] + | ├── object nested: // warn [ i12544b.scala:5 ] | │ ^ | ├── val a: Enum = Case [ i12544b.scala:6 ] | │ ^^^^ | ├── object Enum: [ i12544b.scala:4 ] | │ ^ - | └── val b: Enum = f(nested.a) [ i12544b.scala:8 ] + | └── val b: Enum = f(nested.a) // warn [ i12544b.scala:8 ] | ^^^^^^ --- Warning: tests/init-global/neg/i12544b.scala:8:25 ------------------------------------------------------------------- -8 | val b: Enum = f(nested.a) +-- Warning: tests/init-global/warn/i12544b.scala:8:25 ------------------------------------------------------------------ +8 | val b: Enum = f(nested.a) // warn | ^^^^^^^^ | Access uninitialized field value a. Calling trace: | ├── object Enum: [ i12544b.scala:4 ] | │ ^ - | └── val b: Enum = f(nested.a) [ i12544b.scala:8 ] + | └── val b: Enum = f(nested.a) // warn [ i12544b.scala:8 ] | ^^^^^^^^ -No warnings can be incurred under -Werror. diff --git a/tests/init-global/warn/i12544b.scala b/tests/init-global/warn/i12544b.scala index 886d1619fc10..e79e9b400353 100644 --- a/tests/init-global/warn/i12544b.scala +++ b/tests/init-global/warn/i12544b.scala @@ -2,12 +2,11 @@ enum Enum: case Case object Enum: - object nested: + object nested: // warn val a: Enum = Case - val b: Enum = f(nested.a) + val b: Enum = f(nested.a) // warn def f(e: Enum): Enum = e @main def main(): Unit = println(Enum.b) - diff --git a/tests/init-global/warn/i9176.check b/tests/init-global/warn/i9176.check index a26b66081d75..05a208d1f8a1 100644 --- a/tests/init-global/warn/i9176.check +++ b/tests/init-global/warn/i9176.check @@ -1,9 +1,8 @@ --- Warning: tests/init-global/neg/i9176.scala:2:12 --------------------------------------------------------------------- -2 |case object A extends Foo(B) +-- Warning: tests/init-global/warn/i9176.scala:2:12 -------------------------------------------------------------------- +2 |case object A extends Foo(B) // warn | ^ | Cyclic initialization: object A -> object B -> object A. Calling trace: - | ├── case object A extends Foo(B) [ i9176.scala:2 ] + | ├── case object A extends Foo(B) // warn [ 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/warn/i9176.scala b/tests/init-global/warn/i9176.scala index 82776d85fcd9..86b65f6d8c0f 100644 --- a/tests/init-global/warn/i9176.scala +++ b/tests/init-global/warn/i9176.scala @@ -1,5 +1,5 @@ class Foo(val opposite: Foo) -case object A extends Foo(B) +case object A extends Foo(B) // warn case object B extends Foo(A) object Test { def main(args: Array[String]): Unit = { @@ -7,4 +7,3 @@ object Test { println(B.opposite) } } - diff --git a/tests/init-global/warn/line-spacing.check b/tests/init-global/warn/line-spacing.check index 66f695d62ca5..c38f89ddc69e 100644 --- a/tests/init-global/warn/line-spacing.check +++ b/tests/init-global/warn/line-spacing.check @@ -1,6 +1,6 @@ --- Warning: tests/init-global/neg/line-spacing.scala:4:7 --------------------------------------------------------------- +-- Warning: tests/init-global/warn/line-spacing.scala:4:7 -------------------------------------------------------------- 3 | B -4 | .s.length +4 | .s.length // warn | ^ | Access uninitialized field value s. Calling trace: | ├── object B { [ line-spacing.scala:7 ] @@ -9,6 +9,5 @@ | │ ^^^ | ├── def a: Int = [ line-spacing.scala:2 ] | │ ^ - | └── .s.length [ line-spacing.scala:4 ] + | └── .s.length // warn [ line-spacing.scala:4 ] | ^ -No warnings can be incurred under -Werror. diff --git a/tests/init-global/warn/line-spacing.scala b/tests/init-global/warn/line-spacing.scala index 334425bbc9a8..cfea71b2ee59 100644 --- a/tests/init-global/warn/line-spacing.scala +++ b/tests/init-global/warn/line-spacing.scala @@ -1,10 +1,9 @@ object A { def a: Int = B - .s.length + .s.length // warn } object B { val s: String = s"${A.a}a" } - diff --git a/tests/init-global/warn/mutable-array.check b/tests/init-global/warn/mutable-array.check index 9a877be4eff4..fb96b33c85a9 100644 --- a/tests/init-global/warn/mutable-array.check +++ b/tests/init-global/warn/mutable-array.check @@ -1,10 +1,9 @@ --- Warning: tests/init-global/neg/mutable-array.scala:8:19 ------------------------------------------------------------- -8 | val x: Int = box.value +-- Warning: tests/init-global/warn/mutable-array.scala:8:19 ------------------------------------------------------------ +8 | val x: Int = box.value // warn | ^^^^^^^^^ |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 ] + |└── val x: Int = box.value // warn [ mutable-array.scala:8 ] | ^^^^^^^^^ -No warnings can be incurred under -Werror. diff --git a/tests/init-global/warn/mutable-array.scala b/tests/init-global/warn/mutable-array.scala index 7b26656b5acb..a0ea2ea0f465 100644 --- a/tests/init-global/warn/mutable-array.scala +++ b/tests/init-global/warn/mutable-array.scala @@ -5,5 +5,4 @@ object A: object B: val boxes: Array[A.Box] = Array(A.box) val box: A.Box = boxes(0) - val x: Int = box.value - + val x: Int = box.value // warn diff --git a/tests/init-global/warn/mutable-read1.check b/tests/init-global/warn/mutable-read1.check index 4e446490d7e5..e141ced0c70d 100644 --- a/tests/init-global/warn/mutable-read1.check +++ b/tests/init-global/warn/mutable-read1.check @@ -1,10 +1,9 @@ --- Warning: tests/init-global/neg/mutable-read1.scala:10:20 ------------------------------------------------------------ -10 | val n: Int = boxA.value +-- Warning: tests/init-global/warn/mutable-read1.scala:10:20 ----------------------------------------------------------- +10 | val n: Int = boxA.value // warn | ^^^^^^^^^^ |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 ] + |└── val n: Int = boxA.value // warn [ mutable-read1.scala:10 ] | ^^^^^^^^^^ -No warnings can be incurred under -Werror. diff --git a/tests/init-global/warn/mutable-read1.scala b/tests/init-global/warn/mutable-read1.scala index 1fb3e8935c59..82bcfb3918c7 100644 --- a/tests/init-global/warn/mutable-read1.scala +++ b/tests/init-global/warn/mutable-read1.scala @@ -7,4 +7,4 @@ object B: val boxB: Box = new Box(5) val boxA: Box = A.box val m: Int = boxB.value - val n: Int = boxA.value + val n: Int = boxA.value // warn \ No newline at end of file diff --git a/tests/init-global/warn/mutable-read2.check b/tests/init-global/warn/mutable-read2.check index 24c3c0ef3789..906a82ec09a5 100644 --- a/tests/init-global/warn/mutable-read2.check +++ b/tests/init-global/warn/mutable-read2.check @@ -1,10 +1,9 @@ --- Warning: tests/init-global/neg/mutable-read2.scala:10:19 ------------------------------------------------------------ -10 | val b: Int = box.value +-- Warning: tests/init-global/warn/mutable-read2.scala:10:19 ----------------------------------------------------------- +10 | val b: Int = box.value // warn | ^^^^^^^^^ |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 ] + |└── val b: Int = box.value // warn [ mutable-read2.scala:10 ] | ^^^^^^^^^ -No warnings can be incurred under -Werror. diff --git a/tests/init-global/warn/mutable-read2.scala b/tests/init-global/warn/mutable-read2.scala index d982d78e153e..3337bd3e30bb 100644 --- a/tests/init-global/warn/mutable-read2.scala +++ b/tests/init-global/warn/mutable-read2.scala @@ -7,4 +7,4 @@ object A: object B: val box: A.Box = A.box val a: Int = box.initial - val b: Int = box.value + val b: Int = box.value // warn \ No newline at end of file diff --git a/tests/init-global/warn/mutable-read3.check b/tests/init-global/warn/mutable-read3.check index e0eeb62cee63..754196794a1f 100644 --- a/tests/init-global/warn/mutable-read3.check +++ b/tests/init-global/warn/mutable-read3.check @@ -1,10 +1,9 @@ --- Warning: tests/init-global/neg/mutable-read3.scala:9:19 ------------------------------------------------------------- -9 | val x: Int = box.value +-- Warning: tests/init-global/warn/mutable-read3.scala:9:19 ------------------------------------------------------------ +9 | val x: Int = box.value // warn | ^^^^^^^^^ |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 ] + |└── val x: Int = box.value // warn [ mutable-read3.scala:9 ] | ^^^^^^^^^ -No warnings can be incurred under -Werror. diff --git a/tests/init-global/warn/mutable-read3.scala b/tests/init-global/warn/mutable-read3.scala index 057cfe6f25b9..7f0cbb3664c0 100644 --- a/tests/init-global/warn/mutable-read3.scala +++ b/tests/init-global/warn/mutable-read3.scala @@ -6,4 +6,4 @@ 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 + val x: Int = box.value // warn \ No newline at end of file diff --git a/tests/init-global/warn/mutable-read4.check b/tests/init-global/warn/mutable-read4.check index 81f3a68e0f8b..0ccb8e61549d 100644 --- a/tests/init-global/warn/mutable-read4.check +++ b/tests/init-global/warn/mutable-read4.check @@ -1,10 +1,9 @@ --- Warning: tests/init-global/neg/mutable-read4.scala:10:20 ------------------------------------------------------------ -10 | val n: Int = boxA.value +-- Warning: tests/init-global/warn/mutable-read4.scala:10:20 ----------------------------------------------------------- +10 | val n: Int = boxA.value // warn | ^^^^^^^^^^ |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 ] + |└── val n: Int = boxA.value // warn [ mutable-read4.scala:10 ] | ^^^^^^^^^^ -No warnings can be incurred under -Werror. diff --git a/tests/init-global/warn/mutable-read4.scala b/tests/init-global/warn/mutable-read4.scala index 1fb3e8935c59..82bcfb3918c7 100644 --- a/tests/init-global/warn/mutable-read4.scala +++ b/tests/init-global/warn/mutable-read4.scala @@ -7,4 +7,4 @@ object B: val boxB: Box = new Box(5) val boxA: Box = A.box val m: Int = boxB.value - val n: Int = boxA.value + val n: Int = boxA.value // warn \ No newline at end of file diff --git a/tests/init-global/warn/mutable-read5.check b/tests/init-global/warn/mutable-read5.check index 0fa788588d97..ffbf1c71fc2c 100644 --- a/tests/init-global/warn/mutable-read5.check +++ b/tests/init-global/warn/mutable-read5.check @@ -1,5 +1,5 @@ --- Warning: tests/init-global/neg/mutable-read5.scala:4:38 ------------------------------------------------------------- -4 | def name(s: String): Name = Name(0, chrs.length) +-- Warning: tests/init-global/warn/mutable-read5.scala:4:38 ------------------------------------------------------------ +4 | def name(s: String): Name = Name(0, chrs.length) // warn | ^^^^ |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: @@ -7,6 +7,5 @@ |│ ^ |├── val AnyRef: Names.Name = Names.name("AnyRef") [ mutable-read5.scala:7 ] |│ ^^^^^^^^^^^^^^^^^^^^ - |└── def name(s: String): Name = Name(0, chrs.length) [ mutable-read5.scala:4 ] + |└── def name(s: String): Name = Name(0, chrs.length) // warn [ mutable-read5.scala:4 ] | ^^^^ -No warnings can be incurred under -Werror. diff --git a/tests/init-global/warn/mutable-read5.scala b/tests/init-global/warn/mutable-read5.scala index c48eeff365c4..10977cc9cc5c 100644 --- a/tests/init-global/warn/mutable-read5.scala +++ b/tests/init-global/warn/mutable-read5.scala @@ -1,9 +1,9 @@ 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) + def name(s: String): Name = Name(0, chrs.length) // warn object StdNames: val AnyRef: Names.Name = Names.name("AnyRef") val Array: Names.Name = Names.name("Array") - val List: Names.Name = Names.name("List") + val List: Names.Name = Names.name("List") \ No newline at end of file diff --git a/tests/init-global/warn/mutable-read6.check b/tests/init-global/warn/mutable-read6.check index a43e62bafae0..92d2f58c3ecc 100644 --- a/tests/init-global/warn/mutable-read6.check +++ b/tests/init-global/warn/mutable-read6.check @@ -1,5 +1,5 @@ --- Warning: tests/init-global/neg/mutable-read6.scala:7:35 ------------------------------------------------------------- -7 | final def source: SourceFile = _source +-- Warning: tests/init-global/warn/mutable-read6.scala:7:35 ------------------------------------------------------------ +7 | final def source: SourceFile = _source // warn | ^^^^^^^ |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: @@ -7,6 +7,5 @@ |│ ^ |├── val NoMatchingFailure: SearchFailure = SearchFailure(1, NoContext.source) [ mutable-read6.scala:15 ] |│ ^^^^^^^^^^^^^^^^ - |└── final def source: SourceFile = _source [ mutable-read6.scala:7 ] + |└── final def source: SourceFile = _source // warn [ mutable-read6.scala:7 ] | ^^^^^^^ -No warnings can be incurred under -Werror. diff --git a/tests/init-global/warn/mutable-read6.scala b/tests/init-global/warn/mutable-read6.scala index 1b706a576060..013f7c998221 100644 --- a/tests/init-global/warn/mutable-read6.scala +++ b/tests/init-global/warn/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 + final def source: SourceFile = _source // warn def setSource(source: SourceFile) = { this._source = source } @@ -12,4 +12,4 @@ object Contexts: object Implicits: import Contexts.* case class SearchFailure(tag: Int, source: SourceFile) - val NoMatchingFailure: SearchFailure = SearchFailure(1, NoContext.source) + val NoMatchingFailure: SearchFailure = SearchFailure(1, NoContext.source) \ No newline at end of file diff --git a/tests/init-global/warn/mutable-read7.check b/tests/init-global/warn/mutable-read7.check index 5198721ebf40..244ed1519cdf 100644 --- a/tests/init-global/warn/mutable-read7.check +++ b/tests/init-global/warn/mutable-read7.check @@ -1,5 +1,5 @@ --- Warning: tests/init-global/neg/mutable-read7.scala:7:17 ------------------------------------------------------------- -7 | if (Positioned.debug) { +-- Warning: tests/init-global/warn/mutable-read7.scala:7:17 ------------------------------------------------------------ +7 | if (Positioned.debug) { // warn | ^^^^^^^^^^^^^^^^ |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: @@ -11,6 +11,5 @@ |│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |├── abstract class Positioned: [ mutable-read7.scala:6 ] |│ ^ - |└── if (Positioned.debug) { [ mutable-read7.scala:7 ] + |└── if (Positioned.debug) { // warn [ mutable-read7.scala:7 ] | ^^^^^^^^^^^^^^^^ -No warnings can be incurred under -Werror. diff --git a/tests/init-global/warn/mutable-read7.scala b/tests/init-global/warn/mutable-read7.scala index 83da25fc0c25..952628d8e09c 100644 --- a/tests/init-global/warn/mutable-read7.scala +++ b/tests/init-global/warn/mutable-read7.scala @@ -4,10 +4,10 @@ object Positioned: var nextId: Int = 0 abstract class Positioned: - if (Positioned.debug) { + if (Positioned.debug) { // warn println("do debugging") } object Trees: class Tree extends Positioned - val emptyTree = new Tree + val emptyTree = new Tree \ No newline at end of file diff --git a/tests/init-global/warn/mutable-read8.check b/tests/init-global/warn/mutable-read8.check index 030208a605dd..4527a2e5e5d8 100644 --- a/tests/init-global/warn/mutable-read8.check +++ b/tests/init-global/warn/mutable-read8.check @@ -1,5 +1,5 @@ --- Warning: tests/init-global/neg/mutable-read8.scala:6:12 ------------------------------------------------------------- -6 | if (Stats.monitored) println("record stats") +-- Warning: tests/init-global/warn/mutable-read8.scala:6:12 ------------------------------------------------------------ +6 | if (Stats.monitored) println("record stats") // warn | ^^^^^^^^^^^^^^^ |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: @@ -9,6 +9,5 @@ |│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |├── class UncachedGroundType { [ mutable-read8.scala:5 ] |│ ^ - |└── if (Stats.monitored) println("record stats") [ mutable-read8.scala:6 ] + |└── if (Stats.monitored) println("record stats") // warn [ mutable-read8.scala:6 ] | ^^^^^^^^^^^^^^^ -No warnings can be incurred under -Werror. diff --git a/tests/init-global/warn/mutable-read8.scala b/tests/init-global/warn/mutable-read8.scala index 7dc55830cee4..1481cdb0f83c 100644 --- a/tests/init-global/warn/mutable-read8.scala +++ b/tests/init-global/warn/mutable-read8.scala @@ -3,9 +3,9 @@ object Stats { } class UncachedGroundType { - if (Stats.monitored) println("record stats") + if (Stats.monitored) println("record stats") // warn } class LazyType extends UncachedGroundType -object NoCompleter extends LazyType +object NoCompleter extends LazyType \ No newline at end of file diff --git a/tests/init-global/warn/partial-ordering.check b/tests/init-global/warn/partial-ordering.check index d7a71995dd4c..1f8ace07f6c3 100644 --- a/tests/init-global/warn/partial-ordering.check +++ b/tests/init-global/warn/partial-ordering.check @@ -1,8 +1,8 @@ --- Warning: tests/init-global/neg/partial-ordering.scala:1:7 ----------------------------------------------------------- -1 |object Names: +-- Warning: tests/init-global/warn/partial-ordering.scala:1:7 ---------------------------------------------------------- +1 |object Names: // warn | ^ | Cyclic initialization: object Names -> object MethodName -> object Names. Calling trace: - | ├── object Names: [ partial-ordering.scala:1 ] + | ├── object Names: // warn [ partial-ordering.scala:1 ] | │ ^ | ├── val ctorName: MethodName = MethodName.apply(ctorString) [ partial-ordering.scala:3 ] | │ ^^^^^^^^^^ @@ -10,4 +10,3 @@ | │ ^ | └── val ctor: MethodName = new MethodName(Names.ctorString) [ partial-ordering.scala:7 ] | ^^^^^ -No warnings can be incurred under -Werror. diff --git a/tests/init-global/warn/partial-ordering.scala b/tests/init-global/warn/partial-ordering.scala index d0e05c13174e..1c932014bba1 100644 --- a/tests/init-global/warn/partial-ordering.scala +++ b/tests/init-global/warn/partial-ordering.scala @@ -1,8 +1,8 @@ -object Names: +object Names: // warn 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) + def apply(name: String): MethodName = new MethodName(name) \ No newline at end of file diff --git a/tests/init-global/warn/patmat-unapplySeq.check b/tests/init-global/warn/patmat-unapplySeq.check index 8131e730b8b2..e46de1d60910 100644 --- a/tests/init-global/warn/patmat-unapplySeq.check +++ b/tests/init-global/warn/patmat-unapplySeq.check @@ -1,5 +1,5 @@ --- Warning: tests/init-global/neg/patmat-unapplySeq.scala:8:32 --------------------------------------------------------- -8 | def apply(i: Int): Box = array(i) +-- Warning: tests/init-global/warn/patmat-unapplySeq.scala:8:32 -------------------------------------------------------- +8 | def apply(i: Int): Box = array(i) // warn | ^^^^^^^^ |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,6 +7,5 @@ |│ ^ |├── case A(b) => [ patmat-unapplySeq.scala:17 ] |│ ^^^^ - |└── def apply(i: Int): Box = array(i) [ patmat-unapplySeq.scala:8 ] + |└── def apply(i: Int): Box = array(i) // warn [ patmat-unapplySeq.scala:8 ] | ^^^^^^^^ -No warnings can be incurred under -Werror. diff --git a/tests/init-global/warn/patmat-unapplySeq.scala b/tests/init-global/warn/patmat-unapplySeq.scala index 1849cf0478e1..4c87846c8430 100644 --- a/tests/init-global/warn/patmat-unapplySeq.scala +++ b/tests/init-global/warn/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) + def apply(i: Int): Box = array(i) // warn def drop(n: Int): Seq[Box] = array.toSeq def toSeq: Seq[Box] = array.toSeq @@ -15,4 +15,3 @@ object A: object B: A.array match case A(b) => - diff --git a/tests/init-global/warn/patmat-unapplySeq2.check b/tests/init-global/warn/patmat-unapplySeq2.check index 57a67452c10f..5b5c89122f67 100644 --- a/tests/init-global/warn/patmat-unapplySeq2.check +++ b/tests/init-global/warn/patmat-unapplySeq2.check @@ -1,5 +1,5 @@ --- Warning: tests/init-global/neg/patmat-unapplySeq2.scala:8:32 -------------------------------------------------------- -8 | def apply(i: Int): Box = array(i) +-- Warning: tests/init-global/warn/patmat-unapplySeq2.scala:8:32 ------------------------------------------------------- +8 | def apply(i: Int): Box = array(i) // warn | ^^^^^^^^ |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,6 +7,5 @@ |│ ^ |├── case A(b*) => [ patmat-unapplySeq2.scala:17 ] |│ ^^^^^ - |└── def apply(i: Int): Box = array(i) [ patmat-unapplySeq2.scala:8 ] + |└── def apply(i: Int): Box = array(i) // warn [ patmat-unapplySeq2.scala:8 ] | ^^^^^^^^ -No warnings can be incurred under -Werror. diff --git a/tests/init-global/warn/patmat-unapplySeq2.scala b/tests/init-global/warn/patmat-unapplySeq2.scala index c93b05650a8e..7ebf435b5508 100644 --- a/tests/init-global/warn/patmat-unapplySeq2.scala +++ b/tests/init-global/warn/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) + def apply(i: Int): Box = array(i) // warn def drop(n: Int): Seq[Box] = array.toSeq def toSeq: Seq[Box] = array.toSeq @@ -15,4 +15,3 @@ object A: object B: A.array match case A(b*) => - diff --git a/tests/init-global/warn/patmat.check b/tests/init-global/warn/patmat.check index e05d144db7ce..603aacdc451c 100644 --- a/tests/init-global/warn/patmat.check +++ b/tests/init-global/warn/patmat.check @@ -1,8 +1,8 @@ --- Warning: tests/init-global/neg/patmat.scala:1:7 --------------------------------------------------------------------- -1 |object A: +-- Warning: tests/init-global/warn/patmat.scala:1:7 -------------------------------------------------------------------- +1 |object A: // warn | ^ | Cyclic initialization: object A -> object B -> object A. Calling trace: - | ├── object A: [ patmat.scala:1 ] + | ├── object A: // warn [ patmat.scala:1 ] | │ ^ | ├── case Some(x) => println(x * 2 + B.a.size) [ patmat.scala:4 ] | │ ^ @@ -10,11 +10,11 @@ | │ ^ | └── if A.a.isEmpty then println(xs.size) [ patmat.scala:12 ] | ^ --- Warning: tests/init-global/neg/patmat.scala:29:9 -------------------------------------------------------------------- -29 | object Inner: +-- Warning: tests/init-global/warn/patmat.scala:29:9 ------------------------------------------------------------------- +29 | object Inner: // warn | ^ | Cyclic initialization: object Inner -> object C -> object Inner. Calling trace: - | ├── object Inner: [ patmat.scala:29 ] + | ├── object Inner: // warn [ patmat.scala:29 ] | │ ^ | ├── case Box(f) => f() [ patmat.scala:35 ] | │ ^^^ @@ -24,4 +24,3 @@ | │ ^ | └── val a: Int = Inner.b [ patmat.scala:27 ] | ^^^^^ -No warnings can be incurred under -Werror. diff --git a/tests/init-global/warn/patmat.scala b/tests/init-global/warn/patmat.scala index 0d3e74e42cbe..6ac51f948464 100644 --- a/tests/init-global/warn/patmat.scala +++ b/tests/init-global/warn/patmat.scala @@ -1,4 +1,4 @@ -object A: +object A: // warn 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: + object Inner: // warn val b: Int = 10 val foo: () => Int = () => C.a @@ -34,4 +34,3 @@ object C: (Box(foo): Box[() => Int] | Holder[Int]) match case Box(f) => f() case Holder(x) => x - diff --git a/tests/init-global/warn/return.check b/tests/init-global/warn/return.check index a420b2bab4c3..9f84dae62554 100644 --- a/tests/init-global/warn/return.check +++ b/tests/init-global/warn/return.check @@ -1,11 +1,10 @@ --- Warning: tests/init-global/neg/return.scala:4:31 -------------------------------------------------------------------- -4 | return (a: Int) => a + B.n +-- Warning: tests/init-global/warn/return.scala:4:31 ------------------------------------------------------------------- +4 | return (a: Int) => a + B.n // warn | ^^^ | 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 ] + | └── return (a: Int) => a + B.n // warn [ return.scala:4 ] | ^^^ -No warnings can be incurred under -Werror. diff --git a/tests/init-global/warn/return.scala b/tests/init-global/warn/return.scala index fb138d381fa5..46f4a6cb4b10 100644 --- a/tests/init-global/warn/return.scala +++ b/tests/init-global/warn/return.scala @@ -1,11 +1,10 @@ object A: def foo(x: Int): Int => Int = if x <= 0 then - return (a: Int) => a + B.n + return (a: Int) => a + B.n // warn (a: Int) => a * a + x object B: val n = A.foo(-10)(20) - diff --git a/tests/init-global/warn/return2.check b/tests/init-global/warn/return2.check index e0d9a6e33b14..58f43f383e5d 100644 --- a/tests/init-global/warn/return2.check +++ b/tests/init-global/warn/return2.check @@ -1,15 +1,14 @@ --- Warning: tests/init-global/neg/return2.scala:3:30 ------------------------------------------------------------------- -3 | val f = (a: Int) => a + B.n +-- Warning: tests/init-global/warn/return2.scala:3:30 ------------------------------------------------------------------ +3 | val f = (a: Int) => a + B.n // warn | ^^^ | 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 ] + | └── val f = (a: Int) => a + B.n // warn [ return2.scala:3 ] | ^^^ --- Warning: tests/init-global/neg/return2.scala:6:18 ------------------------------------------------------------------- -6 | val g = () => return f +-- Warning: tests/init-global/warn/return2.scala:6:18 ------------------------------------------------------------------ +6 | val g = () => return f // warn | ^^^^^^^^ | 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/warn/return2.scala b/tests/init-global/warn/return2.scala index c41154e8caa5..7c9bdc8dbadb 100644 --- a/tests/init-global/warn/return2.scala +++ b/tests/init-global/warn/return2.scala @@ -1,9 +1,9 @@ object A: def foo(x: Int): Int => Int = - val f = (a: Int) => a + B.n + val f = (a: Int) => a + B.n // warn var i = 0 - val g = () => return f + val g = () => return f // warn if x <= 0 then g() @@ -11,4 +11,3 @@ object A: object B: val n = A.foo(-10)(20) - diff --git a/tests/init-global/warn/t5366.check b/tests/init-global/warn/t5366.check index 3aeda68fd96f..31091a8b7460 100644 --- a/tests/init-global/warn/t5366.check +++ b/tests/init-global/warn/t5366.check @@ -1,21 +1,20 @@ --- Warning: tests/init-global/neg/t5366.scala:3:12 --------------------------------------------------------------------- -3 |case object ObjA extends IdAndMsg(1) +-- Warning: tests/init-global/warn/t5366.scala:3:12 -------------------------------------------------------------------- +3 |case object ObjA extends IdAndMsg(1) // warn | ^ | Cyclic initialization: object ObjA -> object IdAndMsg -> object ObjA. Calling trace: - | ├── case object ObjA extends IdAndMsg(1) [ t5366.scala:3 ] + | ├── case object ObjA extends IdAndMsg(1) // warn [ t5366.scala:3 ] | │ ^ - | ├── object IdAndMsg { [ t5366.scala:6 ] + | ├── object IdAndMsg { // warn [ t5366.scala:6 ] | │ ^ | └── val values = List(ObjA , ObjB) [ t5366.scala:7 ] | ^^^^ --- Warning: tests/init-global/neg/t5366.scala:6:7 ---------------------------------------------------------------------- -6 |object IdAndMsg { +-- Warning: tests/init-global/warn/t5366.scala:6:7 --------------------------------------------------------------------- +6 |object IdAndMsg { // warn | ^ | Cyclic initialization: object IdAndMsg -> object ObjB -> object IdAndMsg. Calling trace: - | ├── object IdAndMsg { [ t5366.scala:6 ] + | ├── object IdAndMsg { // warn [ 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/warn/t5366.scala b/tests/init-global/warn/t5366.scala index 2c1b18889a2d..be333cbaf183 100644 --- a/tests/init-global/warn/t5366.scala +++ b/tests/init-global/warn/t5366.scala @@ -1,9 +1,9 @@ class IdAndMsg(val id: Int, val msg: String = "") -case object ObjA extends IdAndMsg(1) +case object ObjA extends IdAndMsg(1) // warn case object ObjB extends IdAndMsg(2) -object IdAndMsg { +object IdAndMsg { // warn val values = List(ObjA , ObjB) } @@ -12,4 +12,4 @@ object Test { ObjA println(IdAndMsg.values) } -} +} \ No newline at end of file diff --git a/tests/init-global/warn/t9115.check b/tests/init-global/warn/t9115.check index a55c2eb151a1..7d85026eb970 100644 --- a/tests/init-global/warn/t9115.check +++ b/tests/init-global/warn/t9115.check @@ -1,21 +1,20 @@ --- Warning: tests/init-global/neg/t9115.scala:4:14 --------------------------------------------------------------------- -4 | case object D1 extends Z(aaa) +-- Warning: tests/init-global/warn/t9115.scala:4:14 -------------------------------------------------------------------- +4 | case object D1 extends Z(aaa) // warn | ^ | Cyclic initialization: object D1 -> object D -> object D1. Calling trace: - | ├── case object D1 extends Z(aaa) [ t9115.scala:4 ] + | ├── case object D1 extends Z(aaa) // warn [ t9115.scala:4 ] | │ ^^^ - | ├── object D { [ t9115.scala:1 ] + | ├── object D { // warn [ t9115.scala:1 ] | │ ^ | └── println(D1) [ t9115.scala:6 ] | ^^ --- Warning: tests/init-global/neg/t9115.scala:1:7 ---------------------------------------------------------------------- -1 |object D { +-- Warning: tests/init-global/warn/t9115.scala:1:7 --------------------------------------------------------------------- +1 |object D { // warn | ^ | Cyclic initialization: object D -> object D2 -> object D. Calling trace: - | ├── object D { [ t9115.scala:1 ] + | ├── object D { // warn [ 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/warn/t9115.scala b/tests/init-global/warn/t9115.scala index fc1e8e72c6e3..a5062c1aa10b 100644 --- a/tests/init-global/warn/t9115.scala +++ b/tests/init-global/warn/t9115.scala @@ -1,9 +1,8 @@ -object D { +object D { // warn def aaa = 1 //that’s the reason class Z (depends: Any) - case object D1 extends Z(aaa) + case object D1 extends Z(aaa) // warn case object D2 extends Z(aaa) // 'null' when calling D.D2 first time println(D1) println(D2) } - diff --git a/tests/init-global/warn/t9261.check b/tests/init-global/warn/t9261.check index dbda32347e74..1e8b05d1ffa2 100644 --- a/tests/init-global/warn/t9261.check +++ b/tests/init-global/warn/t9261.check @@ -1,9 +1,8 @@ --- Warning: tests/init-global/neg/t9261.scala:2:12 --------------------------------------------------------------------- -2 |case object Buy extends OrderType(Sell) +-- Warning: tests/init-global/warn/t9261.scala:2:12 -------------------------------------------------------------------- +2 |case object Buy extends OrderType(Sell) // warn | ^ | Cyclic initialization: object Buy -> object Sell -> object Buy. Calling trace: - | ├── case object Buy extends OrderType(Sell) [ t9261.scala:2 ] + | ├── case object Buy extends OrderType(Sell) // warn [ 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/warn/t9261.scala b/tests/init-global/warn/t9261.scala index 0888337d7a94..fcb2f3c62901 100644 --- a/tests/init-global/warn/t9261.scala +++ b/tests/init-global/warn/t9261.scala @@ -1,4 +1,3 @@ sealed abstract class OrderType(val reverse: OrderType) -case object Buy extends OrderType(Sell) +case object Buy extends OrderType(Sell) // warn case object Sell extends OrderType(Buy) - diff --git a/tests/init-global/warn/t9312.check b/tests/init-global/warn/t9312.check index d6f1b00b1a09..2a2aed6d9a40 100644 --- a/tests/init-global/warn/t9312.check +++ b/tests/init-global/warn/t9312.check @@ -1,22 +1,22 @@ --- Warning: tests/init-global/neg/t9312.scala:18:11 -------------------------------------------------------------------- -18 | object Child1 extends Child +-- Warning: tests/init-global/warn/t9312.scala:18:11 ------------------------------------------------------------------- +18 | object Child1 extends Child // warn | ^ | Cyclic initialization: object Child1 -> object Parent -> object Child1. Calling trace: - | ├── object Child1 extends Child [ t9312.scala:18 ] + | ├── object Child1 extends Child // warn [ t9312.scala:18 ] | │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ├── trait Child { [ t9312.scala:12 ] | │ ^ | ├── val parent = Parent [ t9312.scala:14 ] | │ ^^^^^^ - | ├── object Parent { [ t9312.scala:11 ] + | ├── object Parent { // warn [ t9312.scala:11 ] | │ ^ | └── final val children = Set(Child1, Child2) [ t9312.scala:21 ] | ^^^^^^ --- Warning: tests/init-global/neg/t9312.scala:11:9 --------------------------------------------------------------------- -11 | object Parent { +-- Warning: tests/init-global/warn/t9312.scala:11:9 -------------------------------------------------------------------- +11 | object Parent { // warn | ^ | Cyclic initialization: object Parent -> object Child2 -> object Parent. Calling trace: - | ├── object Parent { [ t9312.scala:11 ] + | ├── object Parent { // warn [ t9312.scala:11 ] | │ ^ | ├── final val children = Set(Child1, Child2) [ t9312.scala:21 ] | │ ^^^^^^ @@ -26,4 +26,3 @@ | │ ^ | └── val parent = Parent [ t9312.scala:14 ] | ^^^^^^ -No warnings can be incurred under -Werror. diff --git a/tests/init-global/warn/t9312.scala b/tests/init-global/warn/t9312.scala index d06a7f1bcefb..68282ff9e3e6 100644 --- a/tests/init-global/warn/t9312.scala +++ b/tests/init-global/warn/t9312.scala @@ -8,17 +8,16 @@ object DeadLockTest { } - object Parent { + object Parent { // warn trait Child { Thread.sleep(2000) // ensure concurrent behavior val parent = Parent def siblings = parent.children - this } - object Child1 extends Child + object Child1 extends Child // warn object Child2 extends Child final val children = Set(Child1, Child2) } } - diff --git a/tests/init-global/warn/t9360.check b/tests/init-global/warn/t9360.check index 23ceea224a10..2d77b8c1055a 100644 --- a/tests/init-global/warn/t9360.check +++ b/tests/init-global/warn/t9360.check @@ -1,21 +1,20 @@ --- Warning: tests/init-global/neg/t9360.scala:8:9 ---------------------------------------------------------------------- -8 | object AObj extends BaseClass(s) +-- Warning: tests/init-global/warn/t9360.scala:8:9 --------------------------------------------------------------------- +8 | object AObj extends BaseClass(s) // warn | ^ | Cyclic initialization: object AObj -> object Obj -> object AObj. Calling trace: - | ├── object AObj extends BaseClass(s) [ t9360.scala:8 ] + | ├── object AObj extends BaseClass(s) // warn [ t9360.scala:8 ] | │ ^ - | ├── object Obj { [ t9360.scala:5 ] + | ├── object Obj { // warn [ t9360.scala:5 ] | │ ^ | └── val list = List(AObj, BObj) [ t9360.scala:12 ] | ^^^^ --- Warning: tests/init-global/neg/t9360.scala:5:7 ---------------------------------------------------------------------- -5 |object Obj { +-- Warning: tests/init-global/warn/t9360.scala:5:7 --------------------------------------------------------------------- +5 |object Obj { // warn | ^ | Cyclic initialization: object Obj -> object BObj -> object Obj. Calling trace: - | ├── object Obj { [ t9360.scala:5 ] + | ├── object Obj { // warn [ 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/warn/t9360.scala b/tests/init-global/warn/t9360.scala index 423da308064b..3f5464637457 100644 --- a/tests/init-global/warn/t9360.scala +++ b/tests/init-global/warn/t9360.scala @@ -2,10 +2,10 @@ class BaseClass(s: String) { def print: Unit = () } -object Obj { +object Obj { // warn val s: String = "hello" - object AObj extends BaseClass(s) + object AObj extends BaseClass(s) // warn object BObj extends BaseClass(s) @@ -23,4 +23,3 @@ object ObjectInit { Obj.print } } - diff --git a/tests/init-global/warn/unapply-implicit-arg.check b/tests/init-global/warn/unapply-implicit-arg.check index 4e45d79e7e14..37458a878319 100644 --- a/tests/init-global/warn/unapply-implicit-arg.check +++ b/tests/init-global/warn/unapply-implicit-arg.check @@ -1,9 +1,8 @@ --- Warning: tests/init-global/neg/unapply-implicit-arg.scala:11:16 ----------------------------------------------------- -11 | val i2: Int = i2 match +-- Warning: tests/init-global/warn/unapply-implicit-arg.scala:11:16 ---------------------------------------------------- +11 | val i2: Int = i2 match // warn | ^^ | Access uninitialized field value i2. Calling trace: | ├── object Bar { [ unapply-implicit-arg.scala:1 ] | │ ^ - | └── val i2: Int = i2 match [ unapply-implicit-arg.scala:11 ] + | └── val i2: Int = i2 match // warn [ unapply-implicit-arg.scala:11 ] | ^^ -No warnings can be incurred under -Werror. diff --git a/tests/init-global/warn/unapply-implicit-arg.scala b/tests/init-global/warn/unapply-implicit-arg.scala index 5bccff951b4d..89c9fe9e2d04 100644 --- a/tests/init-global/warn/unapply-implicit-arg.scala +++ b/tests/init-global/warn/unapply-implicit-arg.scala @@ -8,7 +8,7 @@ object Bar { given Foo = new Foo val i1: Int = 0 - val i2: Int = i2 match + val i2: Int = i2 match // warn case Bar(i) => i case _ => 0 -} +} \ No newline at end of file diff --git a/tests/init-global/warn/unapply-implicit-arg2.check b/tests/init-global/warn/unapply-implicit-arg2.check index ec317d59f1bd..f04473c64a17 100644 --- a/tests/init-global/warn/unapply-implicit-arg2.check +++ b/tests/init-global/warn/unapply-implicit-arg2.check @@ -1,13 +1,12 @@ --- 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)) +-- Warning: tests/init-global/warn/unapply-implicit-arg2.scala:7:51 ---------------------------------------------------- +7 | if i == 0 then Some(f1.m1(i1)) else Some(f1.m2(i2)) // warn | ^^ - | 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. + | 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)) // warn [ unapply-implicit-arg2.scala:7 ] + | ^^ diff --git a/tests/init-global/warn/unapply-implicit-arg2.scala b/tests/init-global/warn/unapply-implicit-arg2.scala index 7e1e53881f2e..bec427d4489d 100644 --- a/tests/init-global/warn/unapply-implicit-arg2.scala +++ b/tests/init-global/warn/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)) + if i == 0 then Some(f1.m1(i1)) else Some(f1.m2(i2)) // warn given Foo = new Foo val i1: Int = 0 @@ -12,4 +12,3 @@ object Bar { case Bar(i) => i case _ => 0 } - diff --git a/tests/init-global/warn/unapply-implicit-arg3.check b/tests/init-global/warn/unapply-implicit-arg3.check index 3bb9c0ad2930..18503ac0670b 100644 --- a/tests/init-global/warn/unapply-implicit-arg3.check +++ b/tests/init-global/warn/unapply-implicit-arg3.check @@ -1,5 +1,5 @@ --- Warning: tests/init-global/neg/unapply-implicit-arg3.scala:4:25 ----------------------------------------------------- -4 | def m2(i: Int) = i + i2 +-- Warning: tests/init-global/warn/unapply-implicit-arg3.scala:4:25 ---------------------------------------------------- +4 | def m2(i: Int) = i + i2 // warn | ^^ | Access uninitialized field value i2. Calling trace: | ├── object Bar { [ unapply-implicit-arg3.scala:1 ] @@ -10,6 +10,5 @@ | │ ^ | ├── 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 ] + | └── def m2(i: Int) = i + i2 // warn [ unapply-implicit-arg3.scala:4 ] | ^^ -No warnings can be incurred under -Werror. diff --git a/tests/init-global/warn/unapply-implicit-arg3.scala b/tests/init-global/warn/unapply-implicit-arg3.scala index 1d2fa76d5299..ae7a7a8315da 100644 --- a/tests/init-global/warn/unapply-implicit-arg3.scala +++ b/tests/init-global/warn/unapply-implicit-arg3.scala @@ -1,7 +1,7 @@ object Bar { class Foo { def m1(i: Int) = i + i1 - def m2(i: Int) = i + i2 + def m2(i: Int) = i + i2 // warn } def unapply(using f1: Foo)(i: Int): Option[Int] = if i == 0 then Some(f1.m1(i)) else Some(f1.m2(i)) @@ -12,4 +12,3 @@ object Bar { case Bar(i) => i case _ => 0 } - diff --git a/tests/init-global/warn/unapplySeq-implicit-arg.check b/tests/init-global/warn/unapplySeq-implicit-arg.check index d021cd1f5d94..ec08187f058f 100644 --- a/tests/init-global/warn/unapplySeq-implicit-arg.check +++ b/tests/init-global/warn/unapplySeq-implicit-arg.check @@ -1,9 +1,8 @@ --- Warning: tests/init-global/neg/unapplySeq-implicit-arg.scala:11:20 -------------------------------------------------- -11 | val i2: Int = Seq(i2) match +-- Warning: tests/init-global/warn/unapplySeq-implicit-arg.scala:11:20 ------------------------------------------------- +11 | val i2: Int = Seq(i2) match // warn | ^^ | 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 ] + | └── val i2: Int = Seq(i2) match // warn [ unapplySeq-implicit-arg.scala:11 ] | ^^ -No warnings can be incurred under -Werror. diff --git a/tests/init-global/warn/unapplySeq-implicit-arg.scala b/tests/init-global/warn/unapplySeq-implicit-arg.scala index 31e16e74897a..1b06fadca63f 100644 --- a/tests/init-global/warn/unapplySeq-implicit-arg.scala +++ b/tests/init-global/warn/unapplySeq-implicit-arg.scala @@ -8,8 +8,7 @@ object Bar { given Foo = new Foo val i1: Int = 0 - val i2: Int = Seq(i2) match + val i2: Int = Seq(i2) match // warn case Bar(i) => i case _ => 0 } - diff --git a/tests/init-global/warn/unapplySeq-implicit-arg2.check b/tests/init-global/warn/unapplySeq-implicit-arg2.check index 2e5164d7b405..e75b66495d4b 100644 --- a/tests/init-global/warn/unapplySeq-implicit-arg2.check +++ b/tests/init-global/warn/unapplySeq-implicit-arg2.check @@ -1,5 +1,5 @@ --- Warning: tests/init-global/neg/unapplySeq-implicit-arg2.scala:4:9 --------------------------------------------------- -4 | Some(i1 +: seqi) +-- Warning: tests/init-global/warn/unapplySeq-implicit-arg2.scala:4:9 -------------------------------------------------- +4 | Some(i1 +: seqi) // warn | ^^ |Access uninitialized field value i1. Calling trace: |├── object Bar { [ unapplySeq-implicit-arg2.scala:1 ] @@ -8,6 +8,5 @@ |│ ^^^^^^ |├── 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 ] + |└── Some(i1 +: seqi) // warn [ unapplySeq-implicit-arg2.scala:4 ] | ^^ -No warnings can be incurred under -Werror. diff --git a/tests/init-global/warn/unapplySeq-implicit-arg2.scala b/tests/init-global/warn/unapplySeq-implicit-arg2.scala index 0d506c778e17..adac49ade28d 100644 --- a/tests/init-global/warn/unapplySeq-implicit-arg2.scala +++ b/tests/init-global/warn/unapplySeq-implicit-arg2.scala @@ -1,11 +1,10 @@ object Bar { class Foo def unapplySeq(using f1: Foo)(using f2: Foo)(seqi: Seq[Int])(using Foo): Option[Seq[Int]] = - Some(i1 +: seqi) + Some(i1 +: seqi) // warn given Foo = new Foo val i1: Int = Seq(0) match { case Bar(i) => i case _ => 0 } } - diff --git a/tests/init-global/warn/unapplySeq-implicit-arg3.check b/tests/init-global/warn/unapplySeq-implicit-arg3.check index 59ea56320452..7674298a3665 100644 --- a/tests/init-global/warn/unapplySeq-implicit-arg3.check +++ b/tests/init-global/warn/unapplySeq-implicit-arg3.check @@ -1,5 +1,5 @@ --- Warning: tests/init-global/neg/unapplySeq-implicit-arg3.scala:3:27 -------------------------------------------------- -3 | def m(seq: Seq[Int]) = i1 +: seq +-- Warning: tests/init-global/warn/unapplySeq-implicit-arg3.scala:3:27 ------------------------------------------------- +3 | def m(seq: Seq[Int]) = i1 +: seq // warn | ^^ |Access uninitialized field value i1. Calling trace: |├── object Bar { [ unapplySeq-implicit-arg3.scala:1 ] @@ -10,6 +10,5 @@ |│ ^ |├── Some(f1.m(seqi)) [ unapplySeq-implicit-arg3.scala:6 ] |│ ^^^^^^^^^^ - |└── def m(seq: Seq[Int]) = i1 +: seq [ unapplySeq-implicit-arg3.scala:3 ] + |└── def m(seq: Seq[Int]) = i1 +: seq // warn [ unapplySeq-implicit-arg3.scala:3 ] | ^^ -No warnings can be incurred under -Werror. diff --git a/tests/init-global/warn/unapplySeq-implicit-arg3.scala b/tests/init-global/warn/unapplySeq-implicit-arg3.scala index c941e9b6f65c..ab576ed78149 100644 --- a/tests/init-global/warn/unapplySeq-implicit-arg3.scala +++ b/tests/init-global/warn/unapplySeq-implicit-arg3.scala @@ -1,6 +1,6 @@ object Bar { class Foo { - def m(seq: Seq[Int]) = i1 +: seq + def m(seq: Seq[Int]) = i1 +: seq // warn } def unapplySeq(using f1: Foo)(seqi: Seq[Int])(using Foo): Option[Seq[Int]] = Some(f1.m(seqi)) @@ -10,4 +10,3 @@ object Bar { case _ => 0 } } - From 35b05090238e747bce4f8ebc5ac117523a0997c5 Mon Sep 17 00:00:00 2001 From: Szymon Rodziewicz Date: Tue, 30 Jan 2024 14:33:50 +0100 Subject: [PATCH 5/5] Review changes --- .../dotty/tools/dotc/reporting/Reporter.scala | 4 +- compiler/test-resources/repl/rewrite-messages | 4 +- .../dotty/tools/dotc/CompilationTests.scala | 3 +- tests/neg-custom-args/sourcepath2/hi/A.check | 2 +- tests/neg-macros/i9570.check | 2 +- tests/neg-macros/i9570.scala | 4 +- tests/neg-macros/macro-deprecation.check | 2 +- tests/neg-macros/macro-deprecation.scala | 2 +- tests/neg-scalajs/enumeration-warnings.check | 2 +- tests/neg-scalajs/enumeration-warnings.scala | 2 +- tests/neg/adhoc-extension/B.scala | 2 +- tests/neg/capt-wf.scala | 2 +- .../neg/classtag-typetest/3_1-migration.scala | 2 +- tests/neg/classtag-typetest/3_1.scala | 2 +- tests/neg/i12188/Test.scala | 2 +- tests/neg/i13946/BadPrinter.scala | 2 +- tests/neg/i14386.scala | 2 +- tests/neg/i15474b.check | 5 +- tests/neg/i15474b.scala | 4 +- tests/neg/i16876/Test.scala | 2 +- tests/neg/i17612b.check | 2 +- tests/neg/i17612b/i17612b.scala | 2 +- tests/neg/i17613b.check | 2 +- tests/neg/i4986d.scala | 2 +- tests/neg/i6716.check | 5 +- tests/neg/i6716.scala | 5 +- tests/neg/i7294-a.check | 7 +- tests/neg/i7294-a.scala | 3 +- tests/neg/i7294-b.scala | 3 +- tests/neg/i8681.scala | 2 +- tests/neg/i8711.check | 2 +- tests/neg/i8711.scala | 2 +- tests/neg/i9408b.check | 2 +- tests/neg/i9408b/Test_2.scala | 2 +- tests/neg/impl-conv/B.scala | 2 +- tests/neg/indentLeft.scala | 2 +- tests/neg/indentRight.scala | 2 +- tests/neg/inline-unstable-accessors.check | 99 +++++-------------- tests/neg/inline-unstable-accessors.scala | 32 +++--- tests/neg/looping-givens.scala | 11 --- tests/neg/missing-targetName.scala | 2 +- tests/neg/pureStatement.scala | 2 +- tests/neg/structural-2.scala | 2 +- tests/neg/unchecked-patterns.scala | 2 +- tests/warn/looping-givens.scala | 9 ++ 45 files changed, 109 insertions(+), 149 deletions(-) delete mode 100644 tests/neg/looping-givens.scala create mode 100644 tests/warn/looping-givens.scala diff --git a/compiler/src/dotty/tools/dotc/reporting/Reporter.scala b/compiler/src/dotty/tools/dotc/reporting/Reporter.scala index 2426b569b0d8..22500cbbaa48 100644 --- a/compiler/src/dotty/tools/dotc/reporting/Reporter.scala +++ b/compiler/src/dotty/tools/dotc/reporting/Reporter.scala @@ -209,9 +209,9 @@ abstract class Reporter extends interfaces.ReporterResult { def incomplete(dia: Diagnostic)(using Context): Unit = incompleteHandler(dia, ctx) - def finalizeReporting()(using Context) = + def finalizeReporting()(using Context) = if (hasWarnings && ctx.settings.XfatalWarnings.value) - report(new Error("No warnings can be incurred under -Werror.", NoSourcePosition)) + report(new Error("No warnings can be incurred under -Werror (or -Xfatal-warnings)", NoSourcePosition)) /** Summary of warnings and errors */ def summary: String = { diff --git a/compiler/test-resources/repl/rewrite-messages b/compiler/test-resources/repl/rewrite-messages index 393b87ee272b..d7bcbe5d3a90 100644 --- a/compiler/test-resources/repl/rewrite-messages +++ b/compiler/test-resources/repl/rewrite-messages @@ -4,7 +4,7 @@ scala> import scala.util._ 1 | import scala.util._ | ^ | `_` is no longer supported for a wildcard import; use `*` instead -No warnings can be incurred under -Werror. +No warnings can be incurred under -Werror (or -Xfatal-warnings) 1 warning found 1 error found scala> extension (x: Int) def foo(y: Int) = x + y @@ -15,6 +15,6 @@ scala> 2 foo 4 | ^^^ |Alphanumeric method foo is not declared infix; it should not be used as infix operator. |Instead, use method syntax .foo(...) or backticked identifier `foo`. -No warnings can be incurred under -Werror. +No warnings can be incurred under -Werror (or -Xfatal-warnings) 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 d1ec6eeda0bd..64c2bd3b8807 100644 --- a/compiler/test/dotty/tools/dotc/CompilationTests.scala +++ b/compiler/test/dotty/tools/dotc/CompilationTests.scala @@ -215,9 +215,8 @@ class CompilationTests { // initialization tests @Test def checkInitGlobal: Unit = { implicit val testGroup: TestGroup = TestGroup("checkInitGlobal") - val options = defaultOptions.and("-Ysafe-init-global", "-Xfatal-warnings") 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() + compileFilesInDir("tests/init-global/pos", defaultOptions.and("-Ysafe-init-global", "-Xfatal-warnings"), FileFilter.exclude(TestSources.posInitGlobalScala2LibraryTastyBlacklisted)).checkCompile() } // initialization tests diff --git a/tests/neg-custom-args/sourcepath2/hi/A.check b/tests/neg-custom-args/sourcepath2/hi/A.check index 1fac6b1147ef..6267edaac603 100644 --- a/tests/neg-custom-args/sourcepath2/hi/A.check +++ b/tests/neg-custom-args/sourcepath2/hi/A.check @@ -4,4 +4,4 @@ | 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. +No warnings can be incurred under -Werror (or -Xfatal-warnings) diff --git a/tests/neg-macros/i9570.check b/tests/neg-macros/i9570.check index 16b71d317b7c..3c1f0f644318 100644 --- a/tests/neg-macros/i9570.check +++ b/tests/neg-macros/i9570.check @@ -2,4 +2,4 @@ 15 | case '{HCons(_,$t)} => // warn (in .check file) | ^ | Use of `_` for lambda in quoted pattern. Use explicit lambda instead or use `$_` to match any term. -No warnings can be incurred under -Werror. +No warnings can be incurred under -Werror (or -Xfatal-warnings) diff --git a/tests/neg-macros/i9570.scala b/tests/neg-macros/i9570.scala index 0c67c2d0f8d1..f1bae86fc17a 100644 --- a/tests/neg-macros/i9570.scala +++ b/tests/neg-macros/i9570.scala @@ -20,9 +20,9 @@ object Macros { inline def size(inline expr: HList ): Int = { ${sizeImpl('expr,0)} - } + } } } -// nopos-error No warnings can be incurred under -Werror. \ No newline at end of file +// nopos-error No warnings can be incurred under -Werror (or -Xfatal-warnings) \ No newline at end of file diff --git a/tests/neg-macros/macro-deprecation.check b/tests/neg-macros/macro-deprecation.check index 5ce8a2427127..c3ba52b73c56 100644 --- a/tests/neg-macros/macro-deprecation.check +++ b/tests/neg-macros/macro-deprecation.check @@ -2,4 +2,4 @@ 5 |inline def f = ${ impl } // warn (in .check file) | ^^^^ | method impl is deprecated -No warnings can be incurred under -Werror. +No warnings can be incurred under -Werror (or -Xfatal-warnings) diff --git a/tests/neg-macros/macro-deprecation.scala b/tests/neg-macros/macro-deprecation.scala index 0bbf4d5faa1e..7d44658bef90 100644 --- a/tests/neg-macros/macro-deprecation.scala +++ b/tests/neg-macros/macro-deprecation.scala @@ -5,4 +5,4 @@ import scala.quoted.* inline def f = ${ impl } // warn (in .check file) @deprecated def impl(using Quotes) = '{1} -// nopos-error No warnings can be incurred under -Werror. +// nopos-error No warnings can be incurred under -Werror (or -Xfatal-warnings) diff --git a/tests/neg-scalajs/enumeration-warnings.check b/tests/neg-scalajs/enumeration-warnings.check index 5d791be5928a..d092d545b22b 100644 --- a/tests/neg-scalajs/enumeration-warnings.check +++ b/tests/neg-scalajs/enumeration-warnings.check @@ -58,4 +58,4 @@ | ^^^^^^^^^^^^ | Passing null as name to a constructor of scala.Enumeration.Val requires reflection at run-time. | The resulting program is unlikely to function properly. -No warnings can be incurred under -Werror. +No warnings can be incurred under -Werror (or -Xfatal-warnings) diff --git a/tests/neg-scalajs/enumeration-warnings.scala b/tests/neg-scalajs/enumeration-warnings.scala index 10536fef4ba6..d05c044a32ab 100644 --- a/tests/neg-scalajs/enumeration-warnings.scala +++ b/tests/neg-scalajs/enumeration-warnings.scala @@ -36,4 +36,4 @@ class ExtendsValWithNullName extends Enumeration { protected class Val2 extends Val(1, null) // warn } -// nopos-error: No warnings can be incurred under -Werror. +// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings) diff --git a/tests/neg/adhoc-extension/B.scala b/tests/neg/adhoc-extension/B.scala index efa783f87178..05a243077aaa 100644 --- a/tests/neg/adhoc-extension/B.scala +++ b/tests/neg/adhoc-extension/B.scala @@ -8,4 +8,4 @@ object O { val a = new A {} // warn object E extends A // warn } -// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file +// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings) \ No newline at end of file diff --git a/tests/neg/capt-wf.scala b/tests/neg/capt-wf.scala index 61dde899a585..7521a0e26472 100644 --- a/tests/neg/capt-wf.scala +++ b/tests/neg/capt-wf.scala @@ -35,4 +35,4 @@ def test(c: Cap, other: String): Unit = val y3: String^{ev} = ??? // error cs is empty () -// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file +// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings) \ 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 fb8f3beedc48..f387ccabf7c4 100644 --- a/tests/neg/classtag-typetest/3_1-migration.scala +++ b/tests/neg/classtag-typetest/3_1-migration.scala @@ -6,4 +6,4 @@ import scala.reflect.ClassTag def f3_1m[T: ClassTag](x: Any): Unit = x match case _: T => // warn -// nopos-error: No warnings can be incurred under -Werror. +// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings) diff --git a/tests/neg/classtag-typetest/3_1.scala b/tests/neg/classtag-typetest/3_1.scala index 798489bb90fa..b6c8010364fc 100644 --- a/tests/neg/classtag-typetest/3_1.scala +++ b/tests/neg/classtag-typetest/3_1.scala @@ -6,4 +6,4 @@ import scala.reflect.ClassTag def f3_1[T: ClassTag](x: Any): Unit = x match case _: T => // warn -// nopos-error: No warnings can be incurred under -Werror. +// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings) diff --git a/tests/neg/i12188/Test.scala b/tests/neg/i12188/Test.scala index 9bbbf6431b13..511a4804e5be 100644 --- a/tests/neg/i12188/Test.scala +++ b/tests/neg/i12188/Test.scala @@ -10,4 +10,4 @@ def foo(x: P): Unit = x match // warn case _: PC1 => -// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file +// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings) \ No newline at end of file diff --git a/tests/neg/i13946/BadPrinter.scala b/tests/neg/i13946/BadPrinter.scala index 39e8a921d498..f26ae97c1dfb 100644 --- a/tests/neg/i13946/BadPrinter.scala +++ b/tests/neg/i13946/BadPrinter.scala @@ -4,4 +4,4 @@ import language.future class BadPrinter extends Printer: // warn override def print(s: String): Unit = println("Bad!!!") -// nopos-error: No warnings can be incurred under -Werror. +// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings) diff --git a/tests/neg/i14386.scala b/tests/neg/i14386.scala index d9647da49525..c6d7c0a4d01e 100644 --- a/tests/neg/i14386.scala +++ b/tests/neg/i14386.scala @@ -46,4 +46,4 @@ def braced() = log(level, msg) // warn } end""" -// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file +// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings) \ No newline at end of file diff --git a/tests/neg/i15474b.check b/tests/neg/i15474b.check index 73ef720af7e3..ac894168d51e 100644 --- a/tests/neg/i15474b.check +++ b/tests/neg/i15474b.check @@ -1,5 +1,6 @@ --- Error: tests/neg/i15474b.scala:7:40 --------------------------------------------------------------------------------- -7 | def apply(from: String): Int = from.toInt // error: infinite loop in function body +-- Warning: tests/neg/i15474b.scala:7:40 ------------------------------------------------------------------------------- +7 | def apply(from: String): Int = from.toInt // warn: infinite loop in function body | ^^^^^^^^^^ | Infinite loop in function body | Test1.c.apply(from).toInt +No warnings can be incurred under -Werror (or -Xfatal-warnings) diff --git a/tests/neg/i15474b.scala b/tests/neg/i15474b.scala index 9d496c37ef00..0c04b9880e1c 100644 --- a/tests/neg/i15474b.scala +++ b/tests/neg/i15474b.scala @@ -4,5 +4,5 @@ import scala.language.implicitConversions object Test1: given c: Conversion[ String, Int ] with - def apply(from: String): Int = from.toInt // error: infinite loop in function body - + def apply(from: String): Int = from.toInt // warn: infinite loop in function body +// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings) diff --git a/tests/neg/i16876/Test.scala b/tests/neg/i16876/Test.scala index 71a01128990e..dd7c1c2418ae 100644 --- a/tests/neg/i16876/Test.scala +++ b/tests/neg/i16876/Test.scala @@ -7,4 +7,4 @@ object Foo { private def myMethodFailing(a: Int, b: Int, c: Int) = a + 0 // warn // warn myMethodFailing(1, 2, 3) } -// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file +// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings) \ No newline at end of file diff --git a/tests/neg/i17612b.check b/tests/neg/i17612b.check index ae5b071d6187..681b682b459d 100644 --- a/tests/neg/i17612b.check +++ b/tests/neg/i17612b.check @@ -30,4 +30,4 @@ 41 | class UnderDerived(x: Int, y: Int, z: Int) extends Derived(x, 1, y, z) // warn // warn // warn | ^ | value z in class UnderDerived shadows field z inherited from trait Base -No warnings can be incurred under -Werror. +No warnings can be incurred under -Werror (or -Xfatal-warnings) diff --git a/tests/neg/i17612b/i17612b.scala b/tests/neg/i17612b/i17612b.scala index a1aa1973cea2..62d6ad17ff3d 100644 --- a/tests/neg/i17612b/i17612b.scala +++ b/tests/neg/i17612b/i17612b.scala @@ -42,4 +42,4 @@ object i17612b: def main(args: Array[String]) = val derived = new Derived(1, 1, 1, 1) -// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file +// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings) \ No newline at end of file diff --git a/tests/neg/i17613b.check b/tests/neg/i17613b.check index 15dd2f6451e6..494d218fb366 100644 --- a/tests/neg/i17613b.check +++ b/tests/neg/i17613b.check @@ -58,4 +58,4 @@ 42 | class InnerCl[ImClassR] // warn | ^^^^^^^^ | Type parameter ImClassR for class InnerCl shadows an explicitly renamed type : ImClassR -No warnings can be incurred under -Werror. +No warnings can be incurred under -Werror (or -Xfatal-warnings) diff --git a/tests/neg/i4986d.scala b/tests/neg/i4986d.scala index 73c92822a291..0def343fe847 100644 --- a/tests/neg/i4986d.scala +++ b/tests/neg/i4986d.scala @@ -22,4 +22,4 @@ trait Bar[A] type Barable[A] = { def bar(implicit ev: Bar[A]): Any // ok } -// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file +// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings) \ No newline at end of file diff --git a/tests/neg/i6716.check b/tests/neg/i6716.check index cdf655710452..4684842e73fe 100644 --- a/tests/neg/i6716.check +++ b/tests/neg/i6716.check @@ -1,5 +1,5 @@ --- Error: tests/neg/i6716.scala:12:39 ---------------------------------------------------------------------------------- -12 | given Monad[Bar] = summon[Monad[Foo]] // error +-- Warning: tests/neg/i6716.scala:12:39 -------------------------------------------------------------------------------- +12 | given Monad[Bar] = summon[Monad[Foo]] // warn | ^ | Result of implicit search for Monad[Foo] will change. | Current result Bar.given_Monad_Bar will be no longer eligible @@ -13,3 +13,4 @@ | - rearrange definitions so that Bar.given_Monad_Bar comes earlier, | - use an explicit argument. | This will be an error in Scala 3.5 and later. +No warnings can be incurred under -Werror (or -Xfatal-warnings) diff --git a/tests/neg/i6716.scala b/tests/neg/i6716.scala index bbbd9d6d6cd0..311209fd9006 100644 --- a/tests/neg/i6716.scala +++ b/tests/neg/i6716.scala @@ -9,10 +9,11 @@ object Foo { opaque type Bar = Foo object Bar { - given Monad[Bar] = summon[Monad[Foo]] // error + given Monad[Bar] = summon[Monad[Foo]] // warn } object Test extends App { println(summon[Monad[Foo]].id) println(summon[Monad[Bar]].id) -} \ No newline at end of file +} +// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings) \ No newline at end of file diff --git a/tests/neg/i7294-a.check b/tests/neg/i7294-a.check index 2fe260fcf99a..c33735258ad0 100644 --- a/tests/neg/i7294-a.check +++ b/tests/neg/i7294-a.check @@ -1,5 +1,5 @@ -- [E007] Type Mismatch Error: tests/neg/i7294-a.scala:10:20 ----------------------------------------------------------- -10 | case x: T => x.g(10) // error // error +10 | case x: T => x.g(10) // error | ^^^^^^^ | Found: Any | Required: T @@ -7,8 +7,8 @@ | where: T is a type in given instance f with bounds <: foo.Foo | | longer explanation available when compiling with `-explain` --- Error: tests/neg/i7294-a.scala:10:12 -------------------------------------------------------------------------------- -10 | case x: T => x.g(10) // error // error +-- Warning: tests/neg/i7294-a.scala:10:12 ------------------------------------------------------------------------------ +10 | case x: T => x.g(10) // error | ^ | Result of implicit search for scala.reflect.TypeTest[Nothing, T] will change. | Current result foo.Test.f will be no longer eligible @@ -24,3 +24,4 @@ | This will be an error in Scala 3.5 and later. | | where: T is a type in given instance f with bounds <: foo.Foo +No warnings can be incurred under -Werror (or -Xfatal-warnings) diff --git a/tests/neg/i7294-a.scala b/tests/neg/i7294-a.scala index 3453e88cf741..a5193097e941 100644 --- a/tests/neg/i7294-a.scala +++ b/tests/neg/i7294-a.scala @@ -7,7 +7,8 @@ trait Foo { def g(x: Int): Any } object Test: inline given f[T <: Foo]: T = ??? match { - case x: T => x.g(10) // error // error + case x: T => x.g(10) // error } @main def Test = f +// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings) diff --git a/tests/neg/i7294-b.scala b/tests/neg/i7294-b.scala index 8c6f9328cc20..17cd7f07c3f7 100644 --- a/tests/neg/i7294-b.scala +++ b/tests/neg/i7294-b.scala @@ -5,7 +5,8 @@ package foo trait Foo { def g(x: Any): Any } inline given f[T <: Foo]: T = ??? match { - case x: T => x.g(10) // error // error + case x: T => x.g(10) // error } @main def Test = f +// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings) diff --git a/tests/neg/i8681.scala b/tests/neg/i8681.scala index f7e7066fd2e0..637dd123bd48 100644 --- a/tests/neg/i8681.scala +++ b/tests/neg/i8681.scala @@ -14,4 +14,4 @@ val b = (A(1): A | B) match { case B(_) => "OK" case C(_) => "NOT OK" // error } -// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file +// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings) \ No newline at end of file diff --git a/tests/neg/i8711.check b/tests/neg/i8711.check index 10764e936b5a..245092a6dfd0 100644 --- a/tests/neg/i8711.check +++ b/tests/neg/i8711.check @@ -18,4 +18,4 @@ 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. +No warnings can be incurred under -Werror (or -Xfatal-warnings) diff --git a/tests/neg/i8711.scala b/tests/neg/i8711.scala index 0ae32393a327..18f53447d024 100644 --- a/tests/neg/i8711.scala +++ b/tests/neg/i8711.scala @@ -21,4 +21,4 @@ object Test { } } -// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file +// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings) \ No newline at end of file diff --git a/tests/neg/i9408b.check b/tests/neg/i9408b.check index 4d86f5a0ef0b..15af4294c9bb 100644 --- a/tests/neg/i9408b.check +++ b/tests/neg/i9408b.check @@ -3,4 +3,4 @@ 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. +No warnings can be incurred under -Werror (or -Xfatal-warnings) diff --git a/tests/neg/i9408b/Test_2.scala b/tests/neg/i9408b/Test_2.scala index 11cad10f1e9f..dc5c2bd7b30d 100644 --- a/tests/neg/i9408b/Test_2.scala +++ b/tests/neg/i9408b/Test_2.scala @@ -8,4 +8,4 @@ object Test { val length: Int = "abc" // warn } -// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file +// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings) \ No newline at end of file diff --git a/tests/neg/impl-conv/B.scala b/tests/neg/impl-conv/B.scala index b475c460f318..7ba9fbb92459 100644 --- a/tests/neg/impl-conv/B.scala +++ b/tests/neg/impl-conv/B.scala @@ -10,4 +10,4 @@ object B { val x: Int = "" // ok val y: String = 1 // warn: feature } -// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file +// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings) \ No newline at end of file diff --git a/tests/neg/indentLeft.scala b/tests/neg/indentLeft.scala index 7e1cf8041bc7..22386bd54561 100644 --- a/tests/neg/indentLeft.scala +++ b/tests/neg/indentLeft.scala @@ -1,5 +1,5 @@ //> using options -Xfatal-warnings -// nopos-error: No warnings can be incurred under -Werror. +// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings) object Test { diff --git a/tests/neg/indentRight.scala b/tests/neg/indentRight.scala index 6c43651d67e6..e3359bf238dd 100644 --- a/tests/neg/indentRight.scala +++ b/tests/neg/indentRight.scala @@ -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 +// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings) \ No newline at end of file diff --git a/tests/neg/inline-unstable-accessors.check b/tests/neg/inline-unstable-accessors.check index eb226afc376b..c1984e4cc533 100644 --- a/tests/neg/inline-unstable-accessors.check +++ b/tests/neg/inline-unstable-accessors.check @@ -1,5 +1,5 @@ --- [E192] Compatibility Error: tests/neg/inline-unstable-accessors.scala:10:6 ------------------------------------------ -10 | valBinaryAPI1 + // error +-- [E192] Compatibility Warning: tests/neg/inline-unstable-accessors.scala:10:6 ---------------------------------------- +10 | valBinaryAPI1 + // warn | ^^^^^^^^^^^^^ | Unstable inline accessor foo$A$$inline$valBinaryAPI1 was generated in class A. |-------------------------------------------------------------------------------------------------------------------- @@ -21,8 +21,8 @@ | added to class A: | @publicInBinary private[A] final def foo$A$$inline$valBinaryAPI1: Int = this.valBinaryAPI1 -------------------------------------------------------------------------------------------------------------------- --- [E192] Compatibility Error: tests/neg/inline-unstable-accessors.scala:11:6 ------------------------------------------ -11 | valBinaryAPI2 + // error +-- [E192] Compatibility Warning: tests/neg/inline-unstable-accessors.scala:11:6 ---------------------------------------- +11 | valBinaryAPI2 + // warn | ^^^^^^^^^^^^^ | Unstable inline accessor foo$A$$inline$valBinaryAPI2 was generated in class A. |-------------------------------------------------------------------------------------------------------------------- @@ -44,8 +44,8 @@ | added to class A: | @publicInBinary private[A] def foo$A$$inline$valBinaryAPI2: Int = this.valBinaryAPI2 -------------------------------------------------------------------------------------------------------------------- --- [E192] Compatibility Error: tests/neg/inline-unstable-accessors.scala:15:6 ------------------------------------------ -15 | a.valBinaryAPI2 + // error +-- [E192] Compatibility Warning: tests/neg/inline-unstable-accessors.scala:15:6 ---------------------------------------- +15 | a.valBinaryAPI2 + // warn | ^^^^^^^^^^^^^^^ | Unstable inline accessor inline$valBinaryAPI2$i1 was generated in class B. |-------------------------------------------------------------------------------------------------------------------- @@ -67,8 +67,8 @@ | added to class B: | @publicInBinary private[B] def inline$valBinaryAPI2$i1(x$0: foo.A): Int = x$0.valBinaryAPI2 -------------------------------------------------------------------------------------------------------------------- --- [E192] Compatibility Error: tests/neg/inline-unstable-accessors.scala:23:6 ------------------------------------------ -23 | valBinaryAPI1 + // error +-- [E192] Compatibility Warning: tests/neg/inline-unstable-accessors.scala:23:6 ---------------------------------------- +23 | valBinaryAPI1 + // warn | ^^^^^^^^^^^^^ | Unstable inline accessor inline$valBinaryAPI1 was generated in class C. |-------------------------------------------------------------------------------------------------------------------- @@ -90,8 +90,8 @@ | added to class C: | @publicInBinary private[C] final def inline$valBinaryAPI1: Int = this.valBinaryAPI1 -------------------------------------------------------------------------------------------------------------------- --- [E192] Compatibility Error: tests/neg/inline-unstable-accessors.scala:24:6 ------------------------------------------ -24 | valBinaryAPI2 + // error +-- [E192] Compatibility Warning: tests/neg/inline-unstable-accessors.scala:24:6 ---------------------------------------- +24 | valBinaryAPI2 + // warn | ^^^^^^^^^^^^^ | Unstable inline accessor inline$valBinaryAPI2 was generated in class C. |-------------------------------------------------------------------------------------------------------------------- @@ -113,8 +113,8 @@ | added to class C: | @publicInBinary private[C] def inline$valBinaryAPI2: Int = this.valBinaryAPI2 -------------------------------------------------------------------------------------------------------------------- --- [E192] Compatibility Error: tests/neg/inline-unstable-accessors.scala:28:6 ------------------------------------------ -28 | c.valBinaryAPI2 + // error +-- [E192] Compatibility Warning: tests/neg/inline-unstable-accessors.scala:28:6 ---------------------------------------- +28 | c.valBinaryAPI2 + // warn | ^^^^^^^^^^^^^^^ | Unstable inline accessor inline$valBinaryAPI2$i2 was generated in class D. |-------------------------------------------------------------------------------------------------------------------- @@ -136,8 +136,8 @@ | added to class D: | @publicInBinary private[D] def inline$valBinaryAPI2$i2(x$0: foo.C): Int = x$0.valBinaryAPI2 -------------------------------------------------------------------------------------------------------------------- --- [E192] Compatibility Error: tests/neg/inline-unstable-accessors.scala:36:6 ------------------------------------------ -36 | valBinaryAPI1 + // error +-- [E192] Compatibility Warning: tests/neg/inline-unstable-accessors.scala:36:6 ---------------------------------------- +36 | valBinaryAPI1 + // warn | ^^^^^^^^^^^^^ | Unstable inline accessor inline$valBinaryAPI1 was generated in object E. |-------------------------------------------------------------------------------------------------------------------- @@ -159,8 +159,8 @@ | added to object E: | @publicInBinary private[E] final def inline$valBinaryAPI1: Int = foo.E.valBinaryAPI1 -------------------------------------------------------------------------------------------------------------------- --- [E192] Compatibility Error: tests/neg/inline-unstable-accessors.scala:37:6 ------------------------------------------ -37 | valBinaryAPI2 + // error +-- [E192] Compatibility Warning: tests/neg/inline-unstable-accessors.scala:37:6 ---------------------------------------- +37 | valBinaryAPI2 + // warn | ^^^^^^^^^^^^^ | Unstable inline accessor inline$valBinaryAPI2 was generated in object E. |-------------------------------------------------------------------------------------------------------------------- @@ -182,8 +182,8 @@ | added to object E: | @publicInBinary private[E] def inline$valBinaryAPI2: Int = foo.E.valBinaryAPI2 -------------------------------------------------------------------------------------------------------------------- --- [E192] Compatibility Error: tests/neg/inline-unstable-accessors.scala:41:6 ------------------------------------------ -41 | E.valBinaryAPI2 + // error +-- [E192] Compatibility Warning: tests/neg/inline-unstable-accessors.scala:41:6 ---------------------------------------- +41 | E.valBinaryAPI2 + // warn | ^^^^^^^^^^^^^^^ | Unstable inline accessor inline$valBinaryAPI2$i3 was generated in object F. |-------------------------------------------------------------------------------------------------------------------- @@ -205,8 +205,8 @@ | added to object F: | @publicInBinary private[F] def inline$valBinaryAPI2$i3(x$0: object foo.E): Int = x$0.valBinaryAPI2 -------------------------------------------------------------------------------------------------------------------- --- [E192] Compatibility Error: tests/neg/inline-unstable-accessors.scala:49:6 ------------------------------------------ -49 | valBinaryAPI1 + // error +-- [E192] Compatibility Warning: tests/neg/inline-unstable-accessors.scala:49:6 ---------------------------------------- +49 | valBinaryAPI1 + // warn | ^^^^^^^^^^^^^ | Unstable inline accessor inline$valBinaryAPI1 was generated in package G. |-------------------------------------------------------------------------------------------------------------------- @@ -228,8 +228,8 @@ | added to package G: | @publicInBinary private[G] def inline$valBinaryAPI1: Int = foo.G.valBinaryAPI1 -------------------------------------------------------------------------------------------------------------------- --- [E192] Compatibility Error: tests/neg/inline-unstable-accessors.scala:50:6 ------------------------------------------ -50 | valBinaryAPI2 + // error +-- [E192] Compatibility Warning: tests/neg/inline-unstable-accessors.scala:50:6 ---------------------------------------- +50 | valBinaryAPI2 + // warn | ^^^^^^^^^^^^^ | Unstable inline accessor inline$valBinaryAPI2 was generated in package G. |-------------------------------------------------------------------------------------------------------------------- @@ -251,31 +251,8 @@ | added to package G: | @publicInBinary private[G] def inline$valBinaryAPI2: Int = foo.G.valBinaryAPI2 -------------------------------------------------------------------------------------------------------------------- --- [E192] Compatibility Error: tests/neg/inline-unstable-accessors.scala:54:6 ------------------------------------------ -54 | G.valBinaryAPI2 + // error - | ^^^^^^^^^^^^^^^ - | Unstable inline accessor inline$valBinaryAPI2$i4 was generated in package H. - |-------------------------------------------------------------------------------------------------------------------- - | Explanation (enabled by `-explain`) - |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | Access to non-public value valBinaryAPI2 causes the automatic generation of an accessor. - | This accessor is not stable, its name may change or it may disappear - | if not needed in a future version. - | - | To make sure that the inlined code is binary compatible you must make sure that - | value valBinaryAPI2 is public in the binary API. - | * Option 1: Annotate value valBinaryAPI2 with @publicInBinary - | * Option 2: Make value valBinaryAPI2 public - | - | This change may break binary compatibility if a previous version of this - | library was compiled with generated accessors. Binary compatibility should - | be checked using MiMa. If binary compatibility is broken, you should add the - | old accessor explicitly in the source code. The following code should be - | added to package H: - | @publicInBinary private[H] def inline$valBinaryAPI2$i4(x$0: foo.G): Int = x$0.valBinaryAPI2 - -------------------------------------------------------------------------------------------------------------------- --- [E192] Compatibility Error: tests/neg/inline-unstable-accessors.scala:62:6 ------------------------------------------ -62 | valBinaryAPI1 + // error +-- [E192] Compatibility Warning: tests/neg/inline-unstable-accessors.scala:62:6 ---------------------------------------- +62 | valBinaryAPI1 + // warn | ^^^^^^^^^^^^^ | Unstable inline accessor inline$valBinaryAPI1 was generated in package I. |-------------------------------------------------------------------------------------------------------------------- @@ -297,8 +274,8 @@ | added to package I: | @publicInBinary private[I] def inline$valBinaryAPI1: Int = foo.I.valBinaryAPI1 -------------------------------------------------------------------------------------------------------------------- --- [E192] Compatibility Error: tests/neg/inline-unstable-accessors.scala:63:6 ------------------------------------------ -63 | valBinaryAPI2 + // error +-- [E192] Compatibility Warning: tests/neg/inline-unstable-accessors.scala:63:6 ---------------------------------------- +63 | valBinaryAPI2 + // warn | ^^^^^^^^^^^^^ | Unstable inline accessor inline$valBinaryAPI2 was generated in package I. |-------------------------------------------------------------------------------------------------------------------- @@ -320,26 +297,4 @@ | added to package I: | @publicInBinary private[I] def inline$valBinaryAPI2: Int = foo.I.valBinaryAPI2 -------------------------------------------------------------------------------------------------------------------- --- [E192] Compatibility Error: tests/neg/inline-unstable-accessors.scala:67:6 ------------------------------------------ -67 | I.valBinaryAPI2 + // error - | ^^^^^^^^^^^^^^^ - | Unstable inline accessor inline$valBinaryAPI2$i5 was generated in package J. - |-------------------------------------------------------------------------------------------------------------------- - | Explanation (enabled by `-explain`) - |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | Access to non-public value valBinaryAPI2 causes the automatic generation of an accessor. - | This accessor is not stable, its name may change or it may disappear - | if not needed in a future version. - | - | To make sure that the inlined code is binary compatible you must make sure that - | value valBinaryAPI2 is public in the binary API. - | * Option 1: Annotate value valBinaryAPI2 with @publicInBinary - | * Option 2: Make value valBinaryAPI2 public - | - | This change may break binary compatibility if a previous version of this - | library was compiled with generated accessors. Binary compatibility should - | be checked using MiMa. If binary compatibility is broken, you should add the - | old accessor explicitly in the source code. The following code should be - | added to package J: - | @publicInBinary private[J] def inline$valBinaryAPI2$i5(x$0: foo.I): Int = x$0.valBinaryAPI2 - -------------------------------------------------------------------------------------------------------------------- +No warnings can be incurred under -Werror (or -Xfatal-warnings) diff --git a/tests/neg/inline-unstable-accessors.scala b/tests/neg/inline-unstable-accessors.scala index cf65006daaf8..a7fa75c2c6c9 100644 --- a/tests/neg/inline-unstable-accessors.scala +++ b/tests/neg/inline-unstable-accessors.scala @@ -7,12 +7,12 @@ class A: private[foo] val valBinaryAPI2: Int = 1 @publicInBinary private[foo] val valBinaryAPI3: Int = 1 inline def inlined = - valBinaryAPI1 + // error - valBinaryAPI2 + // error + valBinaryAPI1 + // warn + valBinaryAPI2 + // warn valBinaryAPI3 class B(val a: A): inline def inlined = - a.valBinaryAPI2 + // error + a.valBinaryAPI2 + // warn a.valBinaryAPI3 final class C: @@ -20,12 +20,12 @@ final class C: private[foo] val valBinaryAPI2: Int = 1 @publicInBinary private[foo] val valBinaryAPI3: Int = 1 inline def inlined = - valBinaryAPI1 + // error - valBinaryAPI2 + // error + valBinaryAPI1 + // warn + valBinaryAPI2 + // warn valBinaryAPI3 final class D(val c: C): inline def inlined = - c.valBinaryAPI2 + // error + c.valBinaryAPI2 + // warn c.valBinaryAPI3 object E: @@ -33,12 +33,12 @@ object E: private[foo] val valBinaryAPI2: Int = 1 @publicInBinary private[foo] val valBinaryAPI3: Int = 1 inline def inlined = - valBinaryAPI1 + // error - valBinaryAPI2 + // error + valBinaryAPI1 + // warn + valBinaryAPI2 + // warn valBinaryAPI3 object F: inline def inlined = - E.valBinaryAPI2 + // error + E.valBinaryAPI2 + // warn E.valBinaryAPI3 package object G: @@ -46,12 +46,12 @@ package object G: private[foo] val valBinaryAPI2: Int = 1 @publicInBinary private[foo] val valBinaryAPI3: Int = 1 inline def inlined = - valBinaryAPI1 + // error - valBinaryAPI2 + // error + valBinaryAPI1 + // warn + valBinaryAPI2 + // warn valBinaryAPI3 package object H: inline def inlined = - G.valBinaryAPI2 + // error + // G.valBinaryAPI2 + // FIXME should error (now fails -Ycheck) G.valBinaryAPI3 package I: @@ -59,10 +59,12 @@ package I: private[foo] val valBinaryAPI2: Int = 1 @publicInBinary private[foo] val valBinaryAPI3: Int = 1 inline def inlined = - valBinaryAPI1 + // error - valBinaryAPI2 + // error + valBinaryAPI1 + // warn + valBinaryAPI2 + // warn valBinaryAPI3 package J: inline def inlined = - I.valBinaryAPI2 + // error + // I.valBinaryAPI2 + // FIXME should error (now fails -Ycheck) I.valBinaryAPI3 + +// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings) diff --git a/tests/neg/looping-givens.scala b/tests/neg/looping-givens.scala deleted file mode 100644 index 357a417f0ed9..000000000000 --- a/tests/neg/looping-givens.scala +++ /dev/null @@ -1,11 +0,0 @@ -//> using options -Xfatal-warnings - -class A -class B - -given joint(using a: A, b: B): (A & B) = ??? - -def foo(using a: A, b: B) = - given aa: A = summon // error - given bb: B = summon // error - given ab: (A & B) = summon // error diff --git a/tests/neg/missing-targetName.scala b/tests/neg/missing-targetName.scala index 8c799c4a19dd..32f4646cd5a3 100644 --- a/tests/neg/missing-targetName.scala +++ b/tests/neg/missing-targetName.scala @@ -9,4 +9,4 @@ class & { // error val frozen_& : Int = ??? // warn object some_??? // warn } -// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file +// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings) \ No newline at end of file diff --git a/tests/neg/pureStatement.scala b/tests/neg/pureStatement.scala index 72d39ce2ecf6..09a59f1621db 100644 --- a/tests/neg/pureStatement.scala +++ b/tests/neg/pureStatement.scala @@ -32,4 +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 +// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings) \ No newline at end of file diff --git a/tests/neg/structural-2.scala b/tests/neg/structural-2.scala index 85fac55c08a5..4353467fc821 100644 --- a/tests/neg/structural-2.scala +++ b/tests/neg/structural-2.scala @@ -73,4 +73,4 @@ package p6 { } } -// nopos-error: No warnings can be incurred under -Werror. +// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings) diff --git a/tests/neg/unchecked-patterns.scala b/tests/neg/unchecked-patterns.scala index 7e6c4de76a50..d0e04be687dc 100644 --- a/tests/neg/unchecked-patterns.scala +++ b/tests/neg/unchecked-patterns.scala @@ -25,4 +25,4 @@ object Test { val Pair(t1, t2) = (5, 5) // OK val Triple(u1, u2, u3) = (5, 5, 5) // OK } -// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file +// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings) \ No newline at end of file diff --git a/tests/warn/looping-givens.scala b/tests/warn/looping-givens.scala new file mode 100644 index 000000000000..6b6a32002331 --- /dev/null +++ b/tests/warn/looping-givens.scala @@ -0,0 +1,9 @@ +class A +class B + +given joint(using a: A, b: B): (A & B) = ??? + +def foo(using a: A, b: B) = + given aa: A = summon // warn + given bb: B = summon // warn + given ab: (A & B) = summon // warn