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..22500cbbaa48 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 (or -Xfatal-warnings)", 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..d7bcbe5d3a90 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 (or -Xfatal-warnings) +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 (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 95b5362d77c0..64c2bd3b8807 100644 --- a/compiler/test/dotty/tools/dotc/CompilationTests.scala +++ b/compiler/test/dotty/tools/dotc/CompilationTests.scala @@ -215,10 +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/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() + compileFilesInDir("tests/init-global/pos", defaultOptions.and("-Ysafe-init-global", "-Xfatal-warnings"), FileFilter.exclude(TestSources.posInitGlobalScala2LibraryTastyBlacklisted)).checkCompile() } // initialization tests diff --git a/tests/init-global/neg/i11262.scala b/tests/init-global/neg/i11262.scala deleted file mode 100644 index c1c01f6aad8c..000000000000 --- a/tests/init-global/neg/i11262.scala +++ /dev/null @@ -1,2 +0,0 @@ -object A { val x: String = B.y } // error -object B { val y: String = A.x } // error 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/warn/context-sensitivity.check b/tests/init-global/warn/context-sensitivity.check new file mode 100644 index 000000000000..bc0453b1bc88 --- /dev/null +++ b/tests/init-global/warn/context-sensitivity.check @@ -0,0 +1,10 @@ +-- 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 // warn [ context-sensitivity.scala:9 ] + | ^^^ diff --git a/tests/init-global/neg/context-sensitivity.scala b/tests/init-global/warn/context-sensitivity.scala old mode 100755 new mode 100644 similarity index 89% rename from tests/init-global/neg/context-sensitivity.scala rename to tests/init-global/warn/context-sensitivity.scala index 626fd41bb43f..9150a81619cc --- 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 // error + def foo(): Int = A.m // warn } class Box(var value: Foo) @@ -15,3 +15,4 @@ 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/neg/global-cycle1.check b/tests/init-global/warn/global-cycle1.check similarity index 59% rename from tests/init-global/neg/global-cycle1.check rename to tests/init-global/warn/global-cycle1.check index c68b8b51a419..adee7e47dd54 100644 --- a/tests/init-global/neg/global-cycle1.check +++ b/tests/init-global/warn/global-cycle1.check @@ -1,20 +1,20 @@ --- Error: tests/init-global/neg/global-cycle1.scala:1:7 ---------------------------------------------------------------- -1 |object A { // error +-- 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 { // error [ 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 // error [ global-cycle1.scala:6 ] + | └── val b: Int = A.a // warn [ 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/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 // error [ global-cycle1.scala:6 ] + | └── val b: Int = A.a // warn [ global-cycle1.scala:6 ] | ^^^ diff --git a/tests/init-global/neg/global-cycle1.scala b/tests/init-global/warn/global-cycle1.scala similarity index 50% rename from tests/init-global/neg/global-cycle1.scala rename to tests/init-global/warn/global-cycle1.scala index 592f5a652dc8..e3951f155b76 100644 --- a/tests/init-global/neg/global-cycle1.scala +++ b/tests/init-global/warn/global-cycle1.scala @@ -1,9 +1,9 @@ -object A { // error +object A { // warn val a: Int = B.b } object B { - val b: Int = A.a // error + val b: Int = A.a // warn } @main diff --git a/tests/init-global/warn/global-cycle14.check b/tests/init-global/warn/global-cycle14.check new file mode 100644 index 000000000000..ebdb4667f877 --- /dev/null +++ b/tests/init-global/warn/global-cycle14.check @@ -0,0 +1,20 @@ +-- 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 { // 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 // warn [ global-cycle14.scala:13 ] + | ^ +-- 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 // warn [ global-cycle14.scala:13 ] + | ^^^ diff --git a/tests/init-global/neg/global-cycle14.scala b/tests/init-global/warn/global-cycle14.scala similarity index 69% rename from tests/init-global/neg/global-cycle14.scala rename to tests/init-global/warn/global-cycle14.scala index bcacbebb74fa..696c7ba672f3 100644 --- a/tests/init-global/neg/global-cycle14.scala +++ b/tests/init-global/warn/global-cycle14.scala @@ -5,10 +5,10 @@ object O { val d = Data(3) } -object A { // error +object A { // warn val n: Int = B.m } object B { - val m: Int = A.n // error + val m: Int = A.n // warn } diff --git a/tests/init-global/warn/global-cycle2.check b/tests/init-global/warn/global-cycle2.check new file mode 100644 index 000000000000..37c99b36ac25 --- /dev/null +++ b/tests/init-global/warn/global-cycle2.check @@ -0,0 +1,10 @@ +-- 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 // warn [ global-cycle2.scala:6 ] + | ^^^ diff --git a/tests/init-global/neg/global-cycle2.scala b/tests/init-global/warn/global-cycle2.scala similarity index 57% rename from tests/init-global/neg/global-cycle2.scala rename to tests/init-global/warn/global-cycle2.scala index d86fe09fb0fa..90ca855b00e8 100644 --- a/tests/init-global/neg/global-cycle2.scala +++ b/tests/init-global/warn/global-cycle2.scala @@ -3,5 +3,5 @@ object A { } object B { - def foo(): Int = A.a * 2 // error + 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 new file mode 100644 index 000000000000..d250c3fda5e3 --- /dev/null +++ b/tests/init-global/warn/global-cycle3.check @@ -0,0 +1,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 // warn [ global-cycle3.scala:2 ] + | ^^^ diff --git a/tests/init-global/neg/global-cycle3.scala b/tests/init-global/warn/global-cycle3.scala similarity index 61% rename from tests/init-global/neg/global-cycle3.scala rename to tests/init-global/warn/global-cycle3.scala index 405e007b044a..9d72ac6321fb 100644 --- a/tests/init-global/neg/global-cycle3.scala +++ b/tests/init-global/warn/global-cycle3.scala @@ -1,5 +1,5 @@ class A(x: Int) { - def foo(): Int = B.a + 10 // error + def foo(): Int = B.a + 10 // warn } object B { diff --git a/tests/init-global/warn/global-cycle4.check b/tests/init-global/warn/global-cycle4.check new file mode 100644 index 000000000000..030f62782631 --- /dev/null +++ b/tests/init-global/warn/global-cycle4.check @@ -0,0 +1,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 // warn [ global-cycle4.scala:10 ] + | ^^^ diff --git a/tests/init-global/neg/global-cycle4.scala b/tests/init-global/warn/global-cycle4.scala similarity index 83% rename from tests/init-global/neg/global-cycle4.scala rename to tests/init-global/warn/global-cycle4.scala index 8c1627afeae4..dea2a0b486cf 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 // error + def foo(): Int = O.a + 10 // warn } class D(x: Int) { diff --git a/tests/init-global/warn/global-cycle5.check b/tests/init-global/warn/global-cycle5.check new file mode 100644 index 000000000000..072a80e4530f --- /dev/null +++ b/tests/init-global/warn/global-cycle5.check @@ -0,0 +1,9 @@ +-- 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() // warn [ global-cycle5.scala:10 ] + | ^^^ diff --git a/tests/init-global/neg/global-cycle5.scala b/tests/init-global/warn/global-cycle5.scala old mode 100755 new mode 100644 similarity index 85% rename from tests/init-global/neg/global-cycle5.scala rename to tests/init-global/warn/global-cycle5.scala index 1ba3435d3830..7c3710cb815b --- 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() // error + val b: Int = A.a.foo() // warn } class Y extends X { diff --git a/tests/init-global/warn/global-cycle6.check b/tests/init-global/warn/global-cycle6.check new file mode 100644 index 000000000000..b6454a5d2cce --- /dev/null +++ b/tests/init-global/warn/global-cycle6.check @@ -0,0 +1,28 @@ +-- 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 { // warn [ 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) // warn [ global-cycle6.scala:4 ] + | ^ +-- 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 ] + | │ ^ + | ├── val a = new A.Inner [ global-cycle6.scala:9 ] + | │ ^^^^^^^^^^^ + | ├── class Inner { [ global-cycle6.scala:3 ] + | │ ^ + | └── println(n) // warn [ global-cycle6.scala:4 ] + | ^ diff --git a/tests/init-global/neg/global-cycle6.scala b/tests/init-global/warn/global-cycle6.scala similarity index 79% rename from tests/init-global/neg/global-cycle6.scala rename to tests/init-global/warn/global-cycle6.scala index 36e3ab0b6a94..030e08d37117 100644 --- a/tests/init-global/neg/global-cycle6.scala +++ b/tests/init-global/warn/global-cycle6.scala @@ -1,7 +1,7 @@ -object A { // error +object A { // warn val n: Int = B.m class Inner { - println(n) // error + println(n) // warn } } diff --git a/tests/init-global/warn/global-cycle7.check b/tests/init-global/warn/global-cycle7.check new file mode 100644 index 000000000000..366857885769 --- /dev/null +++ b/tests/init-global/warn/global-cycle7.check @@ -0,0 +1,20 @@ +-- 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 { // 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 // warn [ global-cycle7.scala:6 ] + | ^ +-- 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 // warn [ global-cycle7.scala:6 ] + | ^^^ diff --git a/tests/init-global/neg/global-cycle7.scala b/tests/init-global/warn/global-cycle7.scala similarity index 80% rename from tests/init-global/neg/global-cycle7.scala rename to tests/init-global/warn/global-cycle7.scala index aea75726fbf7..30b74ceb95c4 100644 --- a/tests/init-global/neg/global-cycle7.scala +++ b/tests/init-global/warn/global-cycle7.scala @@ -1,9 +1,9 @@ -object A { // error +object A { // warn val n: Int = B.m } object B { - val m: Int = A.n // error + val m: Int = A.n // warn } abstract class TokensCommon { diff --git a/tests/init-global/warn/global-cycle8.check b/tests/init-global/warn/global-cycle8.check new file mode 100644 index 000000000000..93c9699c653e --- /dev/null +++ b/tests/init-global/warn/global-cycle8.check @@ -0,0 +1,16 @@ +-- 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 { // warn [ 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 ] + | ^ diff --git a/tests/init-global/neg/global-cycle8.scala b/tests/init-global/warn/global-cycle8.scala similarity index 85% rename from tests/init-global/neg/global-cycle8.scala rename to tests/init-global/warn/global-cycle8.scala index 344dc3241395..de4e6620585d 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 { // error +object O { // warn val n: Int = 10 println(P.m) } diff --git a/tests/init-global/warn/global-irrelevance1.check b/tests/init-global/warn/global-irrelevance1.check new file mode 100644 index 000000000000..447ba6b6b29a --- /dev/null +++ b/tests/init-global/warn/global-irrelevance1.check @@ -0,0 +1,9 @@ +-- 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 // warn [ global-irrelevance1.scala:5 ] + | ^^^ diff --git a/tests/init-global/neg/global-irrelevance1.scala b/tests/init-global/warn/global-irrelevance1.scala similarity index 55% rename from tests/init-global/neg/global-irrelevance1.scala rename to tests/init-global/warn/global-irrelevance1.scala index 903d3b14ae18..d19099f287ba 100644 --- a/tests/init-global/neg/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 // error \ No newline at end of file + 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 new file mode 100644 index 000000000000..156b34fa6aa5 --- /dev/null +++ b/tests/init-global/warn/global-irrelevance2.check @@ -0,0 +1,13 @@ +-- 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: + | ├── 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 // warn [ global-irrelevance2.scala:5 ] + | ^^^^^^^^^^^^ diff --git a/tests/init-global/neg/global-irrelevance2.scala b/tests/init-global/warn/global-irrelevance2.scala similarity index 72% rename from tests/init-global/neg/global-irrelevance2.scala rename to tests/init-global/warn/global-irrelevance2.scala index 66b06677b689..9bf7acab4343 100644 --- a/tests/init-global/neg/global-irrelevance2.scala +++ b/tests/init-global/warn/global-irrelevance2.scala @@ -2,7 +2,7 @@ object A: var x = 6 class B(b: Int): - A.x = b * 2 // error + 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 new file mode 100644 index 000000000000..dba945224f97 --- /dev/null +++ b/tests/init-global/warn/global-irrelevance3.check @@ -0,0 +1,11 @@ +-- 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: + |├── object B: [ global-irrelevance3.scala:13 ] + |│ ^ + |├── var y = A.p.g() [ global-irrelevance3.scala:14 ] + |│ ^^^^^^^ + |└── (() => x) // warn [ global-irrelevance3.scala:9 ] + | ^ diff --git a/tests/init-global/neg/global-irrelevance3.scala b/tests/init-global/warn/global-irrelevance3.scala similarity index 87% rename from tests/init-global/neg/global-irrelevance3.scala rename to tests/init-global/warn/global-irrelevance3.scala index 2f36d65d917e..f8db31f14a72 100644 --- a/tests/init-global/neg/global-irrelevance3.scala +++ b/tests/init-global/warn/global-irrelevance3.scala @@ -6,7 +6,7 @@ object A: var x = 6 new Pair( y => x = y, - (() => x) // error + (() => x) // warn ) diff --git a/tests/init-global/warn/global-irrelevance4.check b/tests/init-global/warn/global-irrelevance4.check new file mode 100644 index 000000000000..7253e5b39688 --- /dev/null +++ b/tests/init-global/warn/global-irrelevance4.check @@ -0,0 +1,11 @@ +-- 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: + | ├── object B: [ global-irrelevance4.scala:12 ] + | │ ^ + | ├── A.p.f(10) [ global-irrelevance4.scala:13 ] + | │ ^^^^^^^^^ + | └── (y => x = y), // warn [ global-irrelevance4.scala:8 ] + | ^^^^^^^^^^ diff --git a/tests/init-global/neg/global-irrelevance4.scala b/tests/init-global/warn/global-irrelevance4.scala similarity index 84% rename from tests/init-global/neg/global-irrelevance4.scala rename to tests/init-global/warn/global-irrelevance4.scala index 7a2a778814b2..4ddf3d78e4ae 100644 --- a/tests/init-global/neg/global-irrelevance4.scala +++ b/tests/init-global/warn/global-irrelevance4.scala @@ -5,7 +5,7 @@ object A: def foo(): Pair = var x = 6 new Pair( - (y => x = y), // error + (y => x = y), // warn () => x ) diff --git a/tests/init-global/warn/global-irrelevance5.check b/tests/init-global/warn/global-irrelevance5.check new file mode 100644 index 000000000000..c3581e0b9bbc --- /dev/null +++ b/tests/init-global/warn/global-irrelevance5.check @@ -0,0 +1,9 @@ +-- 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 // warn [ global-irrelevance5.scala:6 ] + | ^^^^^^^^^^ diff --git a/tests/init-global/neg/global-irrelevance5.scala b/tests/init-global/warn/global-irrelevance5.scala similarity index 69% rename from tests/init-global/neg/global-irrelevance5.scala rename to tests/init-global/warn/global-irrelevance5.scala index fd5bde3032aa..f557157ded21 100644 --- a/tests/init-global/neg/global-irrelevance5.scala +++ b/tests/init-global/warn/global-irrelevance5.scala @@ -3,4 +3,4 @@ object A: array(0) = 10 object B: - var y = A.array(0) * 2 // error + 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 new file mode 100644 index 000000000000..3e447a915ba3 --- /dev/null +++ b/tests/init-global/warn/global-irrelevance6.check @@ -0,0 +1,9 @@ +-- 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 // warn [ global-irrelevance6.scala:9 ] + | ^^^^^^^^^^ diff --git a/tests/init-global/neg/global-irrelevance6.scala b/tests/init-global/warn/global-irrelevance6.scala similarity index 78% rename from tests/init-global/neg/global-irrelevance6.scala rename to tests/init-global/warn/global-irrelevance6.scala index 78699b6988b6..43983f05ffac 100644 --- a/tests/init-global/neg/global-irrelevance6.scala +++ b/tests/init-global/warn/global-irrelevance6.scala @@ -6,4 +6,4 @@ 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 // warn diff --git a/tests/init-global/warn/global-irrelevance7.check b/tests/init-global/warn/global-irrelevance7.check new file mode 100644 index 000000000000..c5f0da1a204b --- /dev/null +++ b/tests/init-global/warn/global-irrelevance7.check @@ -0,0 +1,9 @@ +-- 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 // warn [ global-irrelevance7.scala:10 ] + | ^^^^^^^^^^ diff --git a/tests/init-global/neg/global-irrelevance7.scala b/tests/init-global/warn/global-irrelevance7.scala similarity index 80% rename from tests/init-global/neg/global-irrelevance7.scala rename to tests/init-global/warn/global-irrelevance7.scala index 2c860cbc4259..5f92dde9a3f9 100644 --- a/tests/init-global/neg/global-irrelevance7.scala +++ b/tests/init-global/warn/global-irrelevance7.scala @@ -7,4 +7,4 @@ 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 // warn diff --git a/tests/init-global/warn/global-list.check b/tests/init-global/warn/global-list.check new file mode 100644 index 000000000000..f8a57918e411 --- /dev/null +++ b/tests/init-global/warn/global-list.check @@ -0,0 +1,36 @@ +-- 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: // 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) // warn // warn // warn [ global-list.scala:9 ] + | ^ +-- 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) // 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) // 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) // warn // warn // warn [ global-list.scala:9 ] + | ^^^ diff --git a/tests/init-global/neg/global-list.scala b/tests/init-global/warn/global-list.scala old mode 100755 new mode 100644 similarity index 52% rename from tests/init-global/neg/global-list.scala rename to tests/init-global/warn/global-list.scala index cdef6dbf3bbe..8202d03584a9 --- a/tests/init-global/neg/global-list.scala +++ b/tests/init-global/warn/global-list.scala @@ -1,9 +1,9 @@ case class Foo(name: String) -object O: // error +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) // error // error // error \ No newline at end of file + 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 new file mode 100644 index 000000000000..028ad87e6716 --- /dev/null +++ b/tests/init-global/warn/global-local-var.check @@ -0,0 +1,12 @@ +-- 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 ] + | │ ^ + | ├── val a: Int = A(4).foo() [ global-local-var.scala:15 ] + | │ ^^^^^^^^^^ + | ├── def foo(): Int = { [ global-local-var.scala:2 ] + | │ ^ + | └── B.a + 10 + sum // warn [ global-local-var.scala:10 ] + | ^^^ diff --git a/tests/init-global/neg/global-local-var.scala b/tests/init-global/warn/global-local-var.scala similarity index 85% rename from tests/init-global/neg/global-local-var.scala rename to tests/init-global/warn/global-local-var.scala index 6965a42bd37f..384694d7aa15 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 // error + B.a + 10 + sum // warn } } diff --git a/tests/init-global/warn/global-region1.check b/tests/init-global/warn/global-region1.check new file mode 100644 index 000000000000..342de87cfa05 --- /dev/null +++ b/tests/init-global/warn/global-region1.check @@ -0,0 +1,10 @@ +-- 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 } // warn [ global-region1.scala:3 ] + | ^^^ diff --git a/tests/init-global/neg/global-region1.scala b/tests/init-global/warn/global-region1.scala similarity index 76% rename from tests/init-global/neg/global-region1.scala rename to tests/init-global/warn/global-region1.scala index 48473717b5b5..91789507a373 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 } // error +class D(var y: Int) extends B { def foo(): Int = A.m } // warn class Box(var value: B) object A: diff --git a/tests/init-global/warn/i11262.check b/tests/init-global/warn/i11262.check new file mode 100644 index 000000000000..ac80445e9886 --- /dev/null +++ b/tests/init-global/warn/i11262.check @@ -0,0 +1,14 @@ +-- 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 } // warn [ i11262.scala:1 ] + | │ ^ + | └── object B { val y: String = A.x } // warn [ i11262.scala:2 ] + | ^ +-- 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 } // warn [ i11262.scala:2 ] + | ^^^ diff --git a/tests/init-global/warn/i11262.scala b/tests/init-global/warn/i11262.scala new file mode 100644 index 000000000000..896e4db4a0ed --- /dev/null +++ b/tests/init-global/warn/i11262.scala @@ -0,0 +1,2 @@ +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 new file mode 100644 index 000000000000..9f97ea36f7fa --- /dev/null +++ b/tests/init-global/warn/i12544b.check @@ -0,0 +1,20 @@ +-- 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: // warn [ i12544b.scala:5 ] + | │ ^ + | ├── val a: Enum = Case [ i12544b.scala:6 ] + | │ ^^^^ + | ├── object Enum: [ i12544b.scala:4 ] + | │ ^ + | └── val b: Enum = f(nested.a) // warn [ i12544b.scala:8 ] + | ^^^^^^ +-- 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) // warn [ i12544b.scala:8 ] + | ^^^^^^^^ diff --git a/tests/init-global/neg/i12544b.scala b/tests/init-global/warn/i12544b.scala similarity index 62% rename from tests/init-global/neg/i12544b.scala rename to tests/init-global/warn/i12544b.scala index 586b88df04bd..e79e9b400353 100644 --- a/tests/init-global/neg/i12544b.scala +++ b/tests/init-global/warn/i12544b.scala @@ -2,10 +2,10 @@ enum Enum: case Case object Enum: - object nested: // error + object nested: // warn val a: Enum = Case - val b: Enum = f(nested.a) // error + val b: Enum = f(nested.a) // warn def f(e: Enum): Enum = e 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/warn/i9176.check b/tests/init-global/warn/i9176.check new file mode 100644 index 000000000000..05a208d1f8a1 --- /dev/null +++ b/tests/init-global/warn/i9176.check @@ -0,0 +1,8 @@ +-- 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) // warn [ i9176.scala:2 ] + | │ ^ + | └── case object B extends Foo(A) [ i9176.scala:3 ] + | ^ diff --git a/tests/init-global/neg/i9176.scala b/tests/init-global/warn/i9176.scala similarity index 81% rename from tests/init-global/neg/i9176.scala rename to tests/init-global/warn/i9176.scala index c93a16f2f8b1..86b65f6d8c0f 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) // error +case object A extends Foo(B) // warn case object B extends Foo(A) object Test { def main(args: Array[String]): Unit = { 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/init-global/neg/line-spacing.check b/tests/init-global/warn/line-spacing.check similarity index 71% rename from tests/init-global/neg/line-spacing.check rename to tests/init-global/warn/line-spacing.check index 6fa8801bb07b..c38f89ddc69e 100644 --- a/tests/init-global/neg/line-spacing.check +++ b/tests/init-global/warn/line-spacing.check @@ -1,6 +1,6 @@ --- Error: tests/init-global/neg/line-spacing.scala:4:7 ----------------------------------------------------------------- +-- Warning: tests/init-global/warn/line-spacing.scala:4:7 -------------------------------------------------------------- 3 | B -4 | .s.length // error +4 | .s.length // warn | ^ | Access uninitialized field value s. Calling trace: | ├── object B { [ line-spacing.scala:7 ] @@ -9,5 +9,5 @@ | │ ^^^ | ├── def a: Int = [ line-spacing.scala:2 ] | │ ^ - | └── .s.length // error [ line-spacing.scala:4 ] + | └── .s.length // warn [ line-spacing.scala:4 ] | ^ diff --git a/tests/init-global/neg/line-spacing.scala b/tests/init-global/warn/line-spacing.scala similarity index 75% rename from tests/init-global/neg/line-spacing.scala rename to tests/init-global/warn/line-spacing.scala index 42474decb53c..cfea71b2ee59 100644 --- a/tests/init-global/neg/line-spacing.scala +++ b/tests/init-global/warn/line-spacing.scala @@ -1,7 +1,7 @@ object A { def a: Int = B - .s.length // error + .s.length // warn } object B { diff --git a/tests/init-global/warn/mutable-array.check b/tests/init-global/warn/mutable-array.check new file mode 100644 index 000000000000..fb96b33c85a9 --- /dev/null +++ b/tests/init-global/warn/mutable-array.check @@ -0,0 +1,9 @@ +-- 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 // warn [ mutable-array.scala:8 ] + | ^^^^^^^^^ diff --git a/tests/init-global/neg/mutable-array.scala b/tests/init-global/warn/mutable-array.scala similarity index 81% rename from tests/init-global/neg/mutable-array.scala rename to tests/init-global/warn/mutable-array.scala index 3cbc23a5e127..a0ea2ea0f465 100644 --- a/tests/init-global/neg/mutable-array.scala +++ b/tests/init-global/warn/mutable-array.scala @@ -5,4 +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 // error + val x: Int = box.value // warn diff --git a/tests/init-global/warn/mutable-read1.check b/tests/init-global/warn/mutable-read1.check new file mode 100644 index 000000000000..e141ced0c70d --- /dev/null +++ b/tests/init-global/warn/mutable-read1.check @@ -0,0 +1,9 @@ +-- 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 // warn [ mutable-read1.scala:10 ] + | ^^^^^^^^^^ diff --git a/tests/init-global/neg/mutable-read1.scala b/tests/init-global/warn/mutable-read1.scala old mode 100755 new mode 100644 similarity index 82% rename from tests/init-global/neg/mutable-read1.scala rename to tests/init-global/warn/mutable-read1.scala index 507a8b7d74ad..82bcfb3918c7 --- a/tests/init-global/neg/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 // error \ No newline at end of file + 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 new file mode 100644 index 000000000000..906a82ec09a5 --- /dev/null +++ b/tests/init-global/warn/mutable-read2.check @@ -0,0 +1,9 @@ +-- 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 // warn [ mutable-read2.scala:10 ] + | ^^^^^^^^^ diff --git a/tests/init-global/neg/mutable-read2.scala b/tests/init-global/warn/mutable-read2.scala old mode 100755 new mode 100644 similarity index 83% rename from tests/init-global/neg/mutable-read2.scala rename to tests/init-global/warn/mutable-read2.scala index e7653c63d8bb..3337bd3e30bb --- a/tests/init-global/neg/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 // error \ No newline at end of file + 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 new file mode 100644 index 000000000000..754196794a1f --- /dev/null +++ b/tests/init-global/warn/mutable-read3.check @@ -0,0 +1,9 @@ +-- 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 // warn [ mutable-read3.scala:9 ] + | ^^^^^^^^^ diff --git a/tests/init-global/neg/mutable-read3.scala b/tests/init-global/warn/mutable-read3.scala old mode 100755 new mode 100644 similarity index 83% rename from tests/init-global/neg/mutable-read3.scala rename to tests/init-global/warn/mutable-read3.scala index d103e112f372..7f0cbb3664c0 --- a/tests/init-global/neg/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 // error \ No newline at end of file + 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 new file mode 100644 index 000000000000..0ccb8e61549d --- /dev/null +++ b/tests/init-global/warn/mutable-read4.check @@ -0,0 +1,9 @@ +-- 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 // warn [ mutable-read4.scala:10 ] + | ^^^^^^^^^^ diff --git a/tests/init-global/neg/mutable-read4.scala b/tests/init-global/warn/mutable-read4.scala old mode 100755 new mode 100644 similarity index 82% rename from tests/init-global/neg/mutable-read4.scala rename to tests/init-global/warn/mutable-read4.scala index 507a8b7d74ad..82bcfb3918c7 --- a/tests/init-global/neg/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 // error \ No newline at end of file + 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 new file mode 100644 index 000000000000..ffbf1c71fc2c --- /dev/null +++ b/tests/init-global/warn/mutable-read5.check @@ -0,0 +1,11 @@ +-- 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: + |├── 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) // warn [ mutable-read5.scala:4 ] + | ^^^^ diff --git a/tests/init-global/neg/mutable-read5.scala b/tests/init-global/warn/mutable-read5.scala old mode 100755 new mode 100644 similarity index 81% rename from tests/init-global/neg/mutable-read5.scala rename to tests/init-global/warn/mutable-read5.scala index c166295bf9fa..10977cc9cc5c --- a/tests/init-global/neg/mutable-read5.scala +++ b/tests/init-global/warn/mutable-read5.scala @@ -1,7 +1,7 @@ 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) // warn object StdNames: val AnyRef: Names.Name = Names.name("AnyRef") diff --git a/tests/init-global/warn/mutable-read6.check b/tests/init-global/warn/mutable-read6.check new file mode 100644 index 000000000000..92d2f58c3ecc --- /dev/null +++ b/tests/init-global/warn/mutable-read6.check @@ -0,0 +1,11 @@ +-- 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: + |├── object Implicits: [ mutable-read6.scala:12 ] + |│ ^ + |├── val NoMatchingFailure: SearchFailure = SearchFailure(1, NoContext.source) [ mutable-read6.scala:15 ] + |│ ^^^^^^^^^^^^^^^^ + |└── final def source: SourceFile = _source // warn [ mutable-read6.scala:7 ] + | ^^^^^^^ diff --git a/tests/init-global/neg/mutable-read6.scala b/tests/init-global/warn/mutable-read6.scala old mode 100755 new mode 100644 similarity index 87% rename from tests/init-global/neg/mutable-read6.scala rename to tests/init-global/warn/mutable-read6.scala index 8b00eeaf4216..013f7c998221 --- 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 // error + final def source: SourceFile = _source // warn def setSource(source: SourceFile) = { this._source = source } diff --git a/tests/init-global/warn/mutable-read7.check b/tests/init-global/warn/mutable-read7.check new file mode 100644 index 000000000000..244ed1519cdf --- /dev/null +++ b/tests/init-global/warn/mutable-read7.check @@ -0,0 +1,15 @@ +-- 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: + |├── 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) { // warn [ mutable-read7.scala:7 ] + | ^^^^^^^^^^^^^^^^ diff --git a/tests/init-global/neg/mutable-read7.scala b/tests/init-global/warn/mutable-read7.scala old mode 100755 new mode 100644 similarity index 86% rename from tests/init-global/neg/mutable-read7.scala rename to tests/init-global/warn/mutable-read7.scala index ad9d154d74f5..952628d8e09c --- a/tests/init-global/neg/mutable-read7.scala +++ b/tests/init-global/warn/mutable-read7.scala @@ -4,7 +4,7 @@ object Positioned: var nextId: Int = 0 abstract class Positioned: - if (Positioned.debug) { // error + if (Positioned.debug) { // warn println("do debugging") } diff --git a/tests/init-global/warn/mutable-read8.check b/tests/init-global/warn/mutable-read8.check new file mode 100644 index 000000000000..4527a2e5e5d8 --- /dev/null +++ b/tests/init-global/warn/mutable-read8.check @@ -0,0 +1,13 @@ +-- 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: + |├── 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") // warn [ mutable-read8.scala:6 ] + | ^^^^^^^^^^^^^^^ diff --git a/tests/init-global/neg/mutable-read8.scala b/tests/init-global/warn/mutable-read8.scala old mode 100755 new mode 100644 similarity index 73% rename from tests/init-global/neg/mutable-read8.scala rename to tests/init-global/warn/mutable-read8.scala index e830fa65be73..1481cdb0f83c --- a/tests/init-global/neg/mutable-read8.scala +++ b/tests/init-global/warn/mutable-read8.scala @@ -3,7 +3,7 @@ object Stats { } class UncachedGroundType { - if (Stats.monitored) println("record stats") // error + if (Stats.monitored) println("record stats") // warn } class LazyType extends UncachedGroundType diff --git a/tests/init-global/warn/partial-ordering.check b/tests/init-global/warn/partial-ordering.check new file mode 100644 index 000000000000..1f8ace07f6c3 --- /dev/null +++ b/tests/init-global/warn/partial-ordering.check @@ -0,0 +1,12 @@ +-- 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: // warn [ 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 ] + | ^^^^^ diff --git a/tests/init-global/neg/partial-ordering.scala b/tests/init-global/warn/partial-ordering.scala old mode 100755 new mode 100644 similarity index 85% rename from tests/init-global/neg/partial-ordering.scala rename to tests/init-global/warn/partial-ordering.scala index 1bc1b251fb72..1c932014bba1 --- a/tests/init-global/neg/partial-ordering.scala +++ b/tests/init-global/warn/partial-ordering.scala @@ -1,4 +1,4 @@ -object Names: // error +object Names: // warn val ctorString = "" val ctorName: MethodName = MethodName.apply(ctorString) diff --git a/tests/init-global/neg/patmat-unapplySeq.check b/tests/init-global/warn/patmat-unapplySeq.check similarity index 68% rename from tests/init-global/neg/patmat-unapplySeq.check rename to tests/init-global/warn/patmat-unapplySeq.check index 8f7a1f64631b..e46de1d60910 100644 --- a/tests/init-global/neg/patmat-unapplySeq.check +++ b/tests/init-global/warn/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/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,5 +7,5 @@ |│ ^ |├── 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) // warn [ patmat-unapplySeq.scala:8 ] | ^^^^^^^^ diff --git a/tests/init-global/neg/patmat-unapplySeq.scala b/tests/init-global/warn/patmat-unapplySeq.scala similarity index 84% rename from tests/init-global/neg/patmat-unapplySeq.scala rename to tests/init-global/warn/patmat-unapplySeq.scala index 81c853a6e19f..4c87846c8430 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) // error + def apply(i: Int): Box = array(i) // warn def drop(n: Int): Seq[Box] = array.toSeq def toSeq: Seq[Box] = array.toSeq diff --git a/tests/init-global/warn/patmat-unapplySeq2.check b/tests/init-global/warn/patmat-unapplySeq2.check new file mode 100644 index 000000000000..5b5c89122f67 --- /dev/null +++ b/tests/init-global/warn/patmat-unapplySeq2.check @@ -0,0 +1,11 @@ +-- 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: + |├── object B: [ patmat-unapplySeq2.scala:15 ] + |│ ^ + |├── case A(b*) => [ patmat-unapplySeq2.scala:17 ] + |│ ^^^^^ + |└── def apply(i: Int): Box = array(i) // warn [ patmat-unapplySeq2.scala:8 ] + | ^^^^^^^^ diff --git a/tests/init-global/neg/patmat-unapplySeq2.scala b/tests/init-global/warn/patmat-unapplySeq2.scala similarity index 84% rename from tests/init-global/neg/patmat-unapplySeq2.scala rename to tests/init-global/warn/patmat-unapplySeq2.scala index adab9495db49..7ebf435b5508 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) // error + def apply(i: Int): Box = array(i) // warn def drop(n: Int): Seq[Box] = array.toSeq def toSeq: Seq[Box] = array.toSeq diff --git a/tests/init-global/warn/patmat.check b/tests/init-global/warn/patmat.check new file mode 100644 index 000000000000..603aacdc451c --- /dev/null +++ b/tests/init-global/warn/patmat.check @@ -0,0 +1,26 @@ +-- 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: // warn [ 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/warn/patmat.scala:29:9 ------------------------------------------------------------------- +29 | object Inner: // warn + | ^ + | Cyclic initialization: object Inner -> object C -> object Inner. Calling trace: + | ├── object Inner: // warn [ 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 ] + | ^^^^^ diff --git a/tests/init-global/neg/patmat.scala b/tests/init-global/warn/patmat.scala similarity index 89% rename from tests/init-global/neg/patmat.scala rename to tests/init-global/warn/patmat.scala index 126e66e7cf7b..6ac51f948464 100644 --- a/tests/init-global/neg/patmat.scala +++ b/tests/init-global/warn/patmat.scala @@ -1,4 +1,4 @@ -object A: // error +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: // error + object Inner: // warn val b: Int = 10 val foo: () => Int = () => C.a diff --git a/tests/init-global/warn/return.check b/tests/init-global/warn/return.check new file mode 100644 index 000000000000..9f84dae62554 --- /dev/null +++ b/tests/init-global/warn/return.check @@ -0,0 +1,10 @@ +-- 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 // warn [ return.scala:4 ] + | ^^^ diff --git a/tests/init-global/neg/return.scala b/tests/init-global/warn/return.scala old mode 100755 new mode 100644 similarity index 71% rename from tests/init-global/neg/return.scala rename to tests/init-global/warn/return.scala index 5cbf6915fc0e..46f4a6cb4b10 --- 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 // error + return (a: Int) => a + B.n // warn (a: Int) => a * a + x diff --git a/tests/init-global/warn/return2.check b/tests/init-global/warn/return2.check new file mode 100644 index 000000000000..58f43f383e5d --- /dev/null +++ b/tests/init-global/warn/return2.check @@ -0,0 +1,14 @@ +-- 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 // warn [ return2.scala:3 ] + | ^^^ +-- 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 diff --git a/tests/init-global/neg/return2.scala b/tests/init-global/warn/return2.scala old mode 100755 new mode 100644 similarity index 65% rename from tests/init-global/neg/return2.scala rename to tests/init-global/warn/return2.scala index 6a4dec50c2dd..7c9bdc8dbadb --- a/tests/init-global/neg/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 // error + 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() diff --git a/tests/init-global/warn/t5366.check b/tests/init-global/warn/t5366.check new file mode 100644 index 000000000000..31091a8b7460 --- /dev/null +++ b/tests/init-global/warn/t5366.check @@ -0,0 +1,20 @@ +-- 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) // warn [ t5366.scala:3 ] + | │ ^ + | ├── object IdAndMsg { // warn [ t5366.scala:6 ] + | │ ^ + | └── val values = List(ObjA , ObjB) [ t5366.scala:7 ] + | ^^^^ +-- 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 { // warn [ t5366.scala:6 ] + | │ ^ + | ├── val values = List(ObjA , ObjB) [ t5366.scala:7 ] + | │ ^^^^ + | └── case object ObjB extends IdAndMsg(2) [ t5366.scala:4 ] + | ^ diff --git a/tests/init-global/neg/t5366.scala b/tests/init-global/warn/t5366.scala similarity index 69% rename from tests/init-global/neg/t5366.scala rename to tests/init-global/warn/t5366.scala index 854bdfe0544b..be333cbaf183 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) // error +case object ObjA extends IdAndMsg(1) // warn case object ObjB extends IdAndMsg(2) -object IdAndMsg { // error +object IdAndMsg { // warn val values = List(ObjA , ObjB) } diff --git a/tests/init-global/warn/t9115.check b/tests/init-global/warn/t9115.check new file mode 100644 index 000000000000..7d85026eb970 --- /dev/null +++ b/tests/init-global/warn/t9115.check @@ -0,0 +1,20 @@ +-- 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) // warn [ t9115.scala:4 ] + | │ ^^^ + | ├── object D { // warn [ t9115.scala:1 ] + | │ ^ + | └── println(D1) [ t9115.scala:6 ] + | ^^ +-- 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 { // 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 ] + | ^^^ 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 a3020c6939a8..a5062c1aa10b 100644 --- a/tests/init-global/neg/t9115.scala +++ b/tests/init-global/warn/t9115.scala @@ -1,7 +1,7 @@ -object D { // error +object D { // warn 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) // 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 new file mode 100644 index 000000000000..1e8b05d1ffa2 --- /dev/null +++ b/tests/init-global/warn/t9261.check @@ -0,0 +1,8 @@ +-- 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) // warn [ t9261.scala:2 ] + | │ ^^^^ + | └── case object Sell extends OrderType(Buy) [ t9261.scala:3 ] + | ^^^ diff --git a/tests/init-global/neg/t9261.scala b/tests/init-global/warn/t9261.scala similarity index 63% rename from tests/init-global/neg/t9261.scala rename to tests/init-global/warn/t9261.scala index 1e23bedb9b6a..fcb2f3c62901 100644 --- a/tests/init-global/neg/t9261.scala +++ b/tests/init-global/warn/t9261.scala @@ -1,3 +1,3 @@ sealed abstract class OrderType(val reverse: OrderType) -case object Buy extends OrderType(Sell) // error +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 new file mode 100644 index 000000000000..2a2aed6d9a40 --- /dev/null +++ b/tests/init-global/warn/t9312.check @@ -0,0 +1,28 @@ +-- 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 // warn [ t9312.scala:18 ] + | │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ├── trait Child { [ t9312.scala:12 ] + | │ ^ + | ├── val parent = Parent [ t9312.scala:14 ] + | │ ^^^^^^ + | ├── object Parent { // warn [ t9312.scala:11 ] + | │ ^ + | └── final val children = Set(Child1, Child2) [ t9312.scala:21 ] + | ^^^^^^ +-- 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 { // warn [ 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 ] + | ^^^^^^ diff --git a/tests/init-global/neg/t9312.scala b/tests/init-global/warn/t9312.scala similarity index 83% rename from tests/init-global/neg/t9312.scala rename to tests/init-global/warn/t9312.scala index d88093a2f67a..68282ff9e3e6 100644 --- a/tests/init-global/neg/t9312.scala +++ b/tests/init-global/warn/t9312.scala @@ -8,14 +8,14 @@ object DeadLockTest { } - object Parent { // error + object Parent { // warn 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 // 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 new file mode 100644 index 000000000000..2d77b8c1055a --- /dev/null +++ b/tests/init-global/warn/t9360.check @@ -0,0 +1,20 @@ +-- 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) // warn [ t9360.scala:8 ] + | │ ^ + | ├── object Obj { // warn [ t9360.scala:5 ] + | │ ^ + | └── val list = List(AObj, BObj) [ t9360.scala:12 ] + | ^^^^ +-- 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 { // warn [ t9360.scala:5 ] + | │ ^ + | ├── val list = List(AObj, BObj) [ t9360.scala:12 ] + | │ ^^^^ + | └── object BObj extends BaseClass(s) [ t9360.scala:10 ] + | ^ diff --git a/tests/init-global/neg/t9360.scala b/tests/init-global/warn/t9360.scala similarity index 76% rename from tests/init-global/neg/t9360.scala rename to tests/init-global/warn/t9360.scala index 2ec0c740d739..3f5464637457 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 { // error +object Obj { // warn val s: String = "hello" - object AObj extends BaseClass(s) // error + object AObj extends BaseClass(s) // warn object BObj extends BaseClass(s) diff --git a/tests/init-global/warn/unapply-implicit-arg.check b/tests/init-global/warn/unapply-implicit-arg.check new file mode 100644 index 000000000000..37458a878319 --- /dev/null +++ b/tests/init-global/warn/unapply-implicit-arg.check @@ -0,0 +1,8 @@ +-- 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 // warn [ unapply-implicit-arg.scala:11 ] + | ^^ diff --git a/tests/init-global/neg/unapply-implicit-arg.scala b/tests/init-global/warn/unapply-implicit-arg.scala similarity index 88% rename from tests/init-global/neg/unapply-implicit-arg.scala rename to tests/init-global/warn/unapply-implicit-arg.scala index bf41fbbf9412..89c9fe9e2d04 100644 --- a/tests/init-global/neg/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 // error + 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 new file mode 100644 index 000000000000..f04473c64a17 --- /dev/null +++ b/tests/init-global/warn/unapply-implicit-arg2.check @@ -0,0 +1,12 @@ +-- 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)) // warn [ unapply-implicit-arg2.scala:7 ] + | ^^ diff --git a/tests/init-global/neg/unapply-implicit-arg2.scala b/tests/init-global/warn/unapply-implicit-arg2.scala similarity index 78% rename from tests/init-global/neg/unapply-implicit-arg2.scala rename to tests/init-global/warn/unapply-implicit-arg2.scala index c0a16faac377..bec427d4489d 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)) // error + if i == 0 then Some(f1.m1(i1)) else Some(f1.m2(i2)) // warn given Foo = new Foo val i1: Int = 0 diff --git a/tests/init-global/warn/unapply-implicit-arg3.check b/tests/init-global/warn/unapply-implicit-arg3.check new file mode 100644 index 000000000000..18503ac0670b --- /dev/null +++ b/tests/init-global/warn/unapply-implicit-arg3.check @@ -0,0 +1,14 @@ +-- 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 ] + | │ ^ + | ├── 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 // warn [ unapply-implicit-arg3.scala:4 ] + | ^^ diff --git a/tests/init-global/neg/unapply-implicit-arg3.scala b/tests/init-global/warn/unapply-implicit-arg3.scala similarity index 87% rename from tests/init-global/neg/unapply-implicit-arg3.scala rename to tests/init-global/warn/unapply-implicit-arg3.scala index efa348f6cfdb..ae7a7a8315da 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 // error + 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)) diff --git a/tests/init-global/warn/unapplySeq-implicit-arg.check b/tests/init-global/warn/unapplySeq-implicit-arg.check new file mode 100644 index 000000000000..ec08187f058f --- /dev/null +++ b/tests/init-global/warn/unapplySeq-implicit-arg.check @@ -0,0 +1,8 @@ +-- 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 // warn [ unapplySeq-implicit-arg.scala:11 ] + | ^^ diff --git a/tests/init-global/neg/unapplySeq-implicit-arg.scala b/tests/init-global/warn/unapplySeq-implicit-arg.scala similarity index 89% rename from tests/init-global/neg/unapplySeq-implicit-arg.scala rename to tests/init-global/warn/unapplySeq-implicit-arg.scala index e58635a3090f..1b06fadca63f 100644 --- a/tests/init-global/neg/unapplySeq-implicit-arg.scala +++ b/tests/init-global/warn/unapplySeq-implicit-arg.scala @@ -8,7 +8,7 @@ object Bar { given Foo = new Foo val i1: Int = 0 - val i2: Int = Seq(i2) match // error + 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 new file mode 100644 index 000000000000..e75b66495d4b --- /dev/null +++ b/tests/init-global/warn/unapplySeq-implicit-arg2.check @@ -0,0 +1,12 @@ +-- 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 ] + |│ ^ + |├── 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) // warn [ unapplySeq-implicit-arg2.scala:4 ] + | ^^ diff --git a/tests/init-global/neg/unapplySeq-implicit-arg2.scala b/tests/init-global/warn/unapplySeq-implicit-arg2.scala similarity index 87% rename from tests/init-global/neg/unapplySeq-implicit-arg2.scala rename to tests/init-global/warn/unapplySeq-implicit-arg2.scala index 35f5105b84d2..adac49ade28d 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) // error + Some(i1 +: seqi) // warn given Foo = new Foo val i1: Int = Seq(0) match { case Bar(i) => i diff --git a/tests/init-global/warn/unapplySeq-implicit-arg3.check b/tests/init-global/warn/unapplySeq-implicit-arg3.check new file mode 100644 index 000000000000..7674298a3665 --- /dev/null +++ b/tests/init-global/warn/unapplySeq-implicit-arg3.check @@ -0,0 +1,14 @@ +-- 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 ] + |│ ^ + |├── 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 // warn [ unapplySeq-implicit-arg3.scala:3 ] + | ^^ diff --git a/tests/init-global/neg/unapplySeq-implicit-arg3.scala b/tests/init-global/warn/unapplySeq-implicit-arg3.scala similarity index 83% rename from tests/init-global/neg/unapplySeq-implicit-arg3.scala rename to tests/init-global/warn/unapplySeq-implicit-arg3.scala index 2b5cdd327e57..ab576ed78149 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 // error + 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)) diff --git a/tests/neg-custom-args/sourcepath2/hi/A.check b/tests/neg-custom-args/sourcepath2/hi/A.check index 61d4798a34e7..6267edaac603 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 (or -Xfatal-warnings) 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..3c1f0f644318 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 (or -Xfatal-warnings) diff --git a/tests/neg-macros/i9570.scala b/tests/neg-macros/i9570.scala index 0ac78285355c..f1bae86fc17a 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) } @@ -24,3 +24,5 @@ object Macros { } } + +// 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 eaea18315e92..c3ba52b73c56 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 (or -Xfatal-warnings) diff --git a/tests/neg-macros/macro-deprecation.scala b/tests/neg-macros/macro-deprecation.scala index ffa146ef361c..7d44658bef90 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 (or -Xfatal-warnings) diff --git a/tests/neg-scalajs/enumeration-warnings.check b/tests/neg-scalajs/enumeration-warnings.check index b356a150daa5..d092d545b22b 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 (or -Xfatal-warnings) diff --git a/tests/neg-scalajs/enumeration-warnings.scala b/tests/neg-scalajs/enumeration-warnings.scala index b48ffc9500e3..d05c044a32ab 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 (or -Xfatal-warnings) diff --git a/tests/neg/adhoc-extension/B.scala b/tests/neg/adhoc-extension/B.scala index 2343a9bc0060..05a243077aaa 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 (or -Xfatal-warnings) \ No newline at end of file diff --git a/tests/neg/capt-wf.scala b/tests/neg/capt-wf.scala index fbd334726e55..7521a0e26472 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 (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 41e0537a6dc1..f387ccabf7c4 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 (or -Xfatal-warnings) diff --git a/tests/neg/classtag-typetest/3_1.scala b/tests/neg/classtag-typetest/3_1.scala index d9101ff2ae57..b6c8010364fc 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 (or -Xfatal-warnings) diff --git a/tests/neg/i12188/Test.scala b/tests/neg/i12188/Test.scala index 66864438694e..511a4804e5be 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 (or -Xfatal-warnings) \ No newline at end of file diff --git a/tests/neg/i13946/BadPrinter.scala b/tests/neg/i13946/BadPrinter.scala index 46913d2c2805..f26ae97c1dfb 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 (or -Xfatal-warnings) diff --git a/tests/neg/i14386.scala b/tests/neg/i14386.scala index be0b2497ed5f..c6d7c0a4d01e 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 (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 2dd6bfb34421..dd7c1c2418ae 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 (or -Xfatal-warnings) \ No newline at end of file diff --git a/tests/neg/i17612b.check b/tests/neg/i17612b.check index 75e8b7312833..681b682b459d 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 (or -Xfatal-warnings) diff --git a/tests/neg/i17612b/i17612b.scala b/tests/neg/i17612b/i17612b.scala index d16feb240c2a..62d6ad17ff3d 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 (or -Xfatal-warnings) \ No newline at end of file diff --git a/tests/neg/i17613b.check b/tests/neg/i17613b.check index d8cf8618fb27..494d218fb366 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 (or -Xfatal-warnings) 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..0def343fe847 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 (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 4d91509eb0d3..637dd123bd48 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 (or -Xfatal-warnings) \ No newline at end of file diff --git a/tests/neg/i8711.check b/tests/neg/i8711.check index 5dbeeb22460c..245092a6dfd0 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 (or -Xfatal-warnings) diff --git a/tests/neg/i8711.scala b/tests/neg/i8711.scala index 2647e20fe03b..18f53447d024 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 (or -Xfatal-warnings) \ No newline at end of file diff --git a/tests/neg/i9408b.check b/tests/neg/i9408b.check index 5f8a854a9282..15af4294c9bb 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 (or -Xfatal-warnings) diff --git a/tests/neg/i9408b/Test_2.scala b/tests/neg/i9408b/Test_2.scala index 6b3cbbafcb0e..dc5c2bd7b30d 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 (or -Xfatal-warnings) \ 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..7ba9fbb92459 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 (or -Xfatal-warnings) \ No newline at end of file diff --git a/tests/neg/indentLeft.scala b/tests/neg/indentLeft.scala index c4a260583de2..22386bd54561 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 (or -Xfatal-warnings) 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..e3359bf238dd 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 (or -Xfatal-warnings) \ 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/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 b5403ac7cb19..32f4646cd5a3 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 (or -Xfatal-warnings) \ No newline at end of file diff --git a/tests/neg/pureStatement.scala b/tests/neg/pureStatement.scala index 4d2ea1d49b08..09a59f1621db 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 (or -Xfatal-warnings) \ No newline at end of file diff --git a/tests/neg/structural-2.scala b/tests/neg/structural-2.scala index 3613d6073e34..4353467fc821 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 (or -Xfatal-warnings) diff --git a/tests/neg/unchecked-patterns.scala b/tests/neg/unchecked-patterns.scala index db304a2f1875..d0e04be687dc 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 (or -Xfatal-warnings) \ No newline at end of file diff --git a/tests/patmat/i14407.dupe.check b/tests/patmat/i14407.dupe.check index b0605bcd95e5..e6f742314d98 100644 --- a/tests/patmat/i14407.dupe.check +++ b/tests/patmat/i14407.dupe.check @@ -1 +1,2 @@ 6: Match case Unreachable +0: No Kind diff --git a/tests/patmat/i18118.check b/tests/patmat/i18118.check index 8861eb273fb9..f7ad777f5e8c 100644 --- a/tests/patmat/i18118.check +++ b/tests/patmat/i18118.check @@ -2,3 +2,4 @@ 21: Pattern Match 32: Pattern Match 41: Pattern Match +0: No Kind diff --git a/tests/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 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