diff --git a/compiler/src/dotty/tools/dotc/Run.scala b/compiler/src/dotty/tools/dotc/Run.scala index bec1c89d7216..1e801dc5998a 100644 --- a/compiler/src/dotty/tools/dotc/Run.scala +++ b/compiler/src/dotty/tools/dotc/Run.scala @@ -346,6 +346,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint runCtx.withProgressCallback: cb => _progress = Progress(cb, this, fusedPhases.map(_.traversals).sum) runPhases(allPhases = fusedPhases)(using runCtx) + ctx.reporter.finalizeReporting() if (!ctx.reporter.hasErrors) Rewrites.writeBack() suppressions.runFinished(hasErrors = ctx.reporter.hasErrors) diff --git a/compiler/src/dotty/tools/dotc/reporting/Reporter.scala b/compiler/src/dotty/tools/dotc/reporting/Reporter.scala index f567e094e831..5465f4f0dc63 100644 --- a/compiler/src/dotty/tools/dotc/reporting/Reporter.scala +++ b/compiler/src/dotty/tools/dotc/reporting/Reporter.scala @@ -172,19 +172,14 @@ abstract class Reporter extends interfaces.ReporterResult { end issueUnconfigured def issueIfNotSuppressed(dia: Diagnostic)(using Context): Unit = - def toErrorIfFatal(dia: Diagnostic) = dia match - case w: Warning if ctx.settings.silentWarnings.value => dia - case w: ConditionalWarning if w.isSummarizedConditional => dia - case w: Warning if ctx.settings.XfatalWarnings.value => w.toError - case _ => dia def go() = import Action.* dia match case w: Warning => WConf.parsed.action(dia) match case Error => issueUnconfigured(w.toError) - case Warning => issueUnconfigured(toErrorIfFatal(w)) - case Verbose => issueUnconfigured(toErrorIfFatal(w.setVerbose())) + case Warning => issueUnconfigured(w) + case Verbose => issueUnconfigured(w.setVerbose()) case Info => issueUnconfigured(w.toInfo) case Silent => case _ => issueUnconfigured(dia) @@ -214,6 +209,10 @@ abstract class Reporter extends interfaces.ReporterResult { def incomplete(dia: Diagnostic)(using Context): Unit = incompleteHandler(dia, ctx) + def finalizeReporting()(using Context) = + if (hasWarnings && ctx.settings.XfatalWarnings.value) + report(new Error("No warnings can be incurred under -Werror.", NoSourcePosition)) + /** Summary of warnings and errors */ def summary: String = { val b = new mutable.ListBuffer[String] diff --git a/tests/init-global/neg/context-sensitivity.check b/tests/init-global/neg/context-sensitivity.check new file mode 100644 index 000000000000..e5eaad3d2a58 --- /dev/null +++ b/tests/init-global/neg/context-sensitivity.check @@ -0,0 +1,11 @@ +-- Warning: tests/init-global/neg/context-sensitivity.scala:9:21 ------------------------------------------------------- +9 | def foo(): Int = A.m + | ^^^ + | Access uninitialized field value m. Calling trace: + | ├── object A: [ context-sensitivity.scala:14 ] + | │ ^ + | ├── val m: Int = box1.value.foo() [ context-sensitivity.scala:17 ] + | │ ^^^^^^^^^^^^^^^^ + | └── def foo(): Int = A.m [ context-sensitivity.scala:9 ] + | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/context-sensitivity.scala b/tests/init-global/neg/context-sensitivity.scala old mode 100755 new mode 100644 index 626fd41bb43f..7b7477df5773 --- a/tests/init-global/neg/context-sensitivity.scala +++ b/tests/init-global/neg/context-sensitivity.scala @@ -6,7 +6,7 @@ class C(var x: Int) extends Foo { } class D(var y: Int) extends Foo { - def foo(): Int = A.m // error + def foo(): Int = A.m } class Box(var value: Foo) @@ -15,3 +15,5 @@ object A: val box1: Box = new Box(new C(5)) val box2: Box = new Box(new D(10)) val m: Int = box1.value.foo() + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-cycle1.check b/tests/init-global/neg/global-cycle1.check index c68b8b51a419..81859776b06f 100644 --- a/tests/init-global/neg/global-cycle1.check +++ b/tests/init-global/neg/global-cycle1.check @@ -1,20 +1,21 @@ --- Error: tests/init-global/neg/global-cycle1.scala:1:7 ---------------------------------------------------------------- -1 |object A { // error +-- Warning: tests/init-global/neg/global-cycle1.scala:1:7 -------------------------------------------------------------- +1 |object A { | ^ | Cyclic initialization: object A -> object B -> object A. Calling trace: - | ├── object A { // error [ global-cycle1.scala:1 ] + | ├── object A { [ global-cycle1.scala:1 ] | │ ^ | ├── val a: Int = B.b [ global-cycle1.scala:2 ] | │ ^ | ├── object B { [ global-cycle1.scala:5 ] | │ ^ - | └── val b: Int = A.a // error [ global-cycle1.scala:6 ] + | └── val b: Int = A.a [ global-cycle1.scala:6 ] | ^ --- Error: tests/init-global/neg/global-cycle1.scala:6:17 --------------------------------------------------------------- -6 | val b: Int = A.a // error +-- Warning: tests/init-global/neg/global-cycle1.scala:6:17 ------------------------------------------------------------- +6 | val b: Int = A.a | ^^^ | Access uninitialized field value a. Calling trace: | ├── object B { [ global-cycle1.scala:5 ] | │ ^ - | └── val b: Int = A.a // error [ global-cycle1.scala:6 ] + | └── val b: Int = A.a [ global-cycle1.scala:6 ] | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-cycle1.scala b/tests/init-global/neg/global-cycle1.scala index 592f5a652dc8..992d3eacc6f5 100644 --- a/tests/init-global/neg/global-cycle1.scala +++ b/tests/init-global/neg/global-cycle1.scala @@ -1,10 +1,12 @@ -object A { // error +object A { val a: Int = B.b } object B { - val b: Int = A.a // error + val b: Int = A.a } @main def Test = print(A.a) + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-cycle14.check b/tests/init-global/neg/global-cycle14.check new file mode 100644 index 000000000000..d976653c05f0 --- /dev/null +++ b/tests/init-global/neg/global-cycle14.check @@ -0,0 +1,21 @@ +-- Warning: tests/init-global/neg/global-cycle14.scala:8:7 ------------------------------------------------------------- +8 |object A { + | ^ + | Cyclic initialization: object A -> object B -> object A. Calling trace: + | ├── object A { [ global-cycle14.scala:8 ] + | │ ^ + | ├── val n: Int = B.m [ global-cycle14.scala:9 ] + | │ ^ + | ├── object B { [ global-cycle14.scala:12 ] + | │ ^ + | └── val m: Int = A.n [ global-cycle14.scala:13 ] + | ^ +-- Warning: tests/init-global/neg/global-cycle14.scala:13:17 ----------------------------------------------------------- +13 | val m: Int = A.n + | ^^^ + | Access uninitialized field value n. Calling trace: + | ├── object B { [ global-cycle14.scala:12 ] + | │ ^ + | └── val m: Int = A.n [ global-cycle14.scala:13 ] + | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-cycle14.scala b/tests/init-global/neg/global-cycle14.scala index bcacbebb74fa..35a3019a2a64 100644 --- a/tests/init-global/neg/global-cycle14.scala +++ b/tests/init-global/neg/global-cycle14.scala @@ -5,10 +5,12 @@ object O { val d = Data(3) } -object A { // error +object A { val n: Int = B.m } object B { - val m: Int = A.n // error + val m: Int = A.n } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-cycle2.check b/tests/init-global/neg/global-cycle2.check new file mode 100644 index 000000000000..e01fb2f15aea --- /dev/null +++ b/tests/init-global/neg/global-cycle2.check @@ -0,0 +1,11 @@ +-- Warning: tests/init-global/neg/global-cycle2.scala:6:21 ------------------------------------------------------------- +6 | def foo(): Int = A.a * 2 + | ^^^ + | Access uninitialized field value a. Calling trace: + | ├── object A { [ global-cycle2.scala:1 ] + | │ ^ + | ├── val a: Int = B.foo() [ global-cycle2.scala:2 ] + | │ ^^^^^^^ + | └── def foo(): Int = A.a * 2 [ global-cycle2.scala:6 ] + | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-cycle2.scala b/tests/init-global/neg/global-cycle2.scala index d86fe09fb0fa..f3bd33a1c179 100644 --- a/tests/init-global/neg/global-cycle2.scala +++ b/tests/init-global/neg/global-cycle2.scala @@ -3,5 +3,7 @@ object A { } object B { - def foo(): Int = A.a * 2 // error + def foo(): Int = A.a * 2 } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-cycle3.check b/tests/init-global/neg/global-cycle3.check new file mode 100644 index 000000000000..1b3ccd8dd857 --- /dev/null +++ b/tests/init-global/neg/global-cycle3.check @@ -0,0 +1,11 @@ +-- Warning: tests/init-global/neg/global-cycle3.scala:2:21 ------------------------------------------------------------- +2 | def foo(): Int = B.a + 10 + | ^^^ + | Access uninitialized field value a. Calling trace: + | ├── object B { [ global-cycle3.scala:5 ] + | │ ^ + | ├── val a: Int = A(4).foo() [ global-cycle3.scala:6 ] + | │ ^^^^^^^^^^ + | └── def foo(): Int = B.a + 10 [ global-cycle3.scala:2 ] + | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-cycle3.scala b/tests/init-global/neg/global-cycle3.scala index 405e007b044a..5e97ba59c735 100644 --- a/tests/init-global/neg/global-cycle3.scala +++ b/tests/init-global/neg/global-cycle3.scala @@ -1,7 +1,9 @@ class A(x: Int) { - def foo(): Int = B.a + 10 // error + def foo(): Int = B.a + 10 } object B { val a: Int = A(4).foo() } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-cycle4.check b/tests/init-global/neg/global-cycle4.check new file mode 100644 index 000000000000..68a4dcae4b77 --- /dev/null +++ b/tests/init-global/neg/global-cycle4.check @@ -0,0 +1,11 @@ +-- Warning: tests/init-global/neg/global-cycle4.scala:10:21 ------------------------------------------------------------ +10 | def foo(): Int = O.a + 10 + | ^^^ + | Access uninitialized field value a. Calling trace: + | ├── object O { [ global-cycle4.scala:17 ] + | │ ^ + | ├── val a: Int = D(5).bar().foo() [ global-cycle4.scala:18 ] + | │ ^^^^^^^^^^^^^^^^ + | └── def foo(): Int = O.a + 10 [ global-cycle4.scala:10 ] + | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-cycle4.scala b/tests/init-global/neg/global-cycle4.scala index 8c1627afeae4..789d682da3be 100644 --- a/tests/init-global/neg/global-cycle4.scala +++ b/tests/init-global/neg/global-cycle4.scala @@ -7,7 +7,7 @@ class B extends A { } class C extends A { - def foo(): Int = O.a + 10 // error + def foo(): Int = O.a + 10 } class D(x: Int) { @@ -17,3 +17,5 @@ class D(x: Int) { object O { val a: Int = D(5).bar().foo() } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-cycle5.check b/tests/init-global/neg/global-cycle5.check new file mode 100644 index 000000000000..c1d21cb77a45 --- /dev/null +++ b/tests/init-global/neg/global-cycle5.check @@ -0,0 +1,10 @@ +-- Warning: tests/init-global/neg/global-cycle5.scala:10:17 ------------------------------------------------------------ +10 | val b: Int = A.a.foo() + | ^^^ + |Reading mutable state of object A during initialization of object B. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object B { [ global-cycle5.scala:9 ] + |│ ^ + |└── val b: Int = A.a.foo() [ global-cycle5.scala:10 ] + | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-cycle5.scala b/tests/init-global/neg/global-cycle5.scala old mode 100755 new mode 100644 index 1ba3435d3830..281ea9b879d1 --- a/tests/init-global/neg/global-cycle5.scala +++ b/tests/init-global/neg/global-cycle5.scala @@ -7,7 +7,7 @@ object A { } object B { - val b: Int = A.a.foo() // error + val b: Int = A.a.foo() } class Y extends X { @@ -20,4 +20,5 @@ object C { def main = { A.a = new Y(); C -} \ No newline at end of file +} +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-cycle6.check b/tests/init-global/neg/global-cycle6.check new file mode 100644 index 000000000000..47a1c1543773 --- /dev/null +++ b/tests/init-global/neg/global-cycle6.check @@ -0,0 +1,29 @@ +-- Warning: tests/init-global/neg/global-cycle6.scala:1:7 -------------------------------------------------------------- +1 |object A { + | ^ + | Cyclic initialization: object A -> object B -> object A. Calling trace: + | ├── object A { [ global-cycle6.scala:1 ] + | │ ^ + | ├── val n: Int = B.m [ global-cycle6.scala:2 ] + | │ ^ + | ├── object B { [ global-cycle6.scala:8 ] + | │ ^ + | ├── val a = new A.Inner [ global-cycle6.scala:9 ] + | │ ^^^^^^^^^^^ + | ├── class Inner { [ global-cycle6.scala:3 ] + | │ ^ + | └── println(n) [ global-cycle6.scala:4 ] + | ^ +-- Warning: tests/init-global/neg/global-cycle6.scala:4:12 ------------------------------------------------------------- +4 | println(n) + | ^ + | Access uninitialized field value n. Calling trace: + | ├── object B { [ global-cycle6.scala:8 ] + | │ ^ + | ├── val a = new A.Inner [ global-cycle6.scala:9 ] + | │ ^^^^^^^^^^^ + | ├── class Inner { [ global-cycle6.scala:3 ] + | │ ^ + | └── println(n) [ global-cycle6.scala:4 ] + | ^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-cycle6.scala b/tests/init-global/neg/global-cycle6.scala index 36e3ab0b6a94..88adc536b307 100644 --- a/tests/init-global/neg/global-cycle6.scala +++ b/tests/init-global/neg/global-cycle6.scala @@ -1,7 +1,7 @@ -object A { // error +object A { val n: Int = B.m class Inner { - println(n) // error + println(n) } } @@ -22,4 +22,5 @@ object O { val a = new A.Inner val m: Int = 10 } -} \ No newline at end of file +} +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-cycle7.check b/tests/init-global/neg/global-cycle7.check new file mode 100644 index 000000000000..96a63b77b73e --- /dev/null +++ b/tests/init-global/neg/global-cycle7.check @@ -0,0 +1,21 @@ +-- Warning: tests/init-global/neg/global-cycle7.scala:1:7 -------------------------------------------------------------- +1 |object A { + | ^ + | Cyclic initialization: object A -> object B -> object A. Calling trace: + | ├── object A { [ global-cycle7.scala:1 ] + | │ ^ + | ├── val n: Int = B.m [ global-cycle7.scala:2 ] + | │ ^ + | ├── object B { [ global-cycle7.scala:5 ] + | │ ^ + | └── val m: Int = A.n [ global-cycle7.scala:6 ] + | ^ +-- Warning: tests/init-global/neg/global-cycle7.scala:6:17 ------------------------------------------------------------- +6 | val m: Int = A.n + | ^^^ + | Access uninitialized field value n. Calling trace: + | ├── object B { [ global-cycle7.scala:5 ] + | │ ^ + | └── val m: Int = A.n [ global-cycle7.scala:6 ] + | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-cycle7.scala b/tests/init-global/neg/global-cycle7.scala index aea75726fbf7..b8084984aeec 100644 --- a/tests/init-global/neg/global-cycle7.scala +++ b/tests/init-global/neg/global-cycle7.scala @@ -1,9 +1,9 @@ -object A { // error +object A { val n: Int = B.m } object B { - val m: Int = A.n // error + val m: Int = A.n } abstract class TokensCommon { @@ -16,3 +16,5 @@ object JavaTokens extends TokensCommon { final def maxToken: Int = DOUBLE final val DOUBLE = 188 } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-cycle8.check b/tests/init-global/neg/global-cycle8.check new file mode 100644 index 000000000000..6dc544fe8e7c --- /dev/null +++ b/tests/init-global/neg/global-cycle8.check @@ -0,0 +1,17 @@ +-- Warning: tests/init-global/neg/global-cycle8.scala:9:7 -------------------------------------------------------------- +9 |object O { + | ^ + | Cyclic initialization: object O -> object P -> object O. Calling trace: + | ├── object O { [ global-cycle8.scala:9 ] + | │ ^ + | ├── println(P.m) [ global-cycle8.scala:11 ] + | │ ^ + | ├── object P { [ global-cycle8.scala:14 ] + | │ ^ + | ├── val m = Q.bar(new B) [ global-cycle8.scala:15 ] + | │ ^^^^^^^^^^^^ + | ├── def bar(b: B) = b.a.foo() [ global-cycle8.scala:19 ] + | │ ^^^^^^^^^ + | └── def foo() = println(O.n) [ global-cycle8.scala:2 ] + | ^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-cycle8.scala b/tests/init-global/neg/global-cycle8.scala index 344dc3241395..91290da30353 100644 --- a/tests/init-global/neg/global-cycle8.scala +++ b/tests/init-global/neg/global-cycle8.scala @@ -6,7 +6,7 @@ class B { val a = new A } -object O { // error +object O { val n: Int = 10 println(P.m) } @@ -18,3 +18,5 @@ object P { object Q { def bar(b: B) = b.a.foo() } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-irrelevance1.check b/tests/init-global/neg/global-irrelevance1.check new file mode 100644 index 000000000000..799d80ec9623 --- /dev/null +++ b/tests/init-global/neg/global-irrelevance1.check @@ -0,0 +1,10 @@ +-- Warning: tests/init-global/neg/global-irrelevance1.scala:5:12 ------------------------------------------------------- +5 | var y = A.x * 2 + | ^^^ + |Reading mutable state of object A during initialization of object B. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object B: [ global-irrelevance1.scala:4 ] + |│ ^ + |└── var y = A.x * 2 [ global-irrelevance1.scala:5 ] + | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-irrelevance1.scala b/tests/init-global/neg/global-irrelevance1.scala index 903d3b14ae18..2eb5511001e2 100644 --- a/tests/init-global/neg/global-irrelevance1.scala +++ b/tests/init-global/neg/global-irrelevance1.scala @@ -2,4 +2,5 @@ object A: var x = 6 object B: - var y = A.x * 2 // error \ No newline at end of file + var y = A.x * 2 +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-irrelevance2.check b/tests/init-global/neg/global-irrelevance2.check new file mode 100644 index 000000000000..56263b936308 --- /dev/null +++ b/tests/init-global/neg/global-irrelevance2.check @@ -0,0 +1,14 @@ +-- Warning: tests/init-global/neg/global-irrelevance2.scala:5:6 -------------------------------------------------------- +5 | A.x = b * 2 + | ^^^^^^^^^^^^ + | Mutating object A during initialization of object B. + | Mutating other static objects during the initialization of one static object is forbidden. Calling trace: + | ├── object B: [ global-irrelevance2.scala:7 ] + | │ ^ + | ├── new B(10) [ global-irrelevance2.scala:8 ] + | │ ^^^^^^^^^ + | ├── class B(b: Int): [ global-irrelevance2.scala:4 ] + | │ ^ + | └── A.x = b * 2 [ global-irrelevance2.scala:5 ] + | ^^^^^^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-irrelevance2.scala b/tests/init-global/neg/global-irrelevance2.scala index 66b06677b689..8804eed6cc52 100644 --- a/tests/init-global/neg/global-irrelevance2.scala +++ b/tests/init-global/neg/global-irrelevance2.scala @@ -2,7 +2,9 @@ object A: var x = 6 class B(b: Int): - A.x = b * 2 // error + A.x = b * 2 object B: new B(10) + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-irrelevance3.check b/tests/init-global/neg/global-irrelevance3.check new file mode 100644 index 000000000000..7d7f9dbfb1fc --- /dev/null +++ b/tests/init-global/neg/global-irrelevance3.check @@ -0,0 +1,12 @@ +-- Warning: tests/init-global/neg/global-irrelevance3.scala:9:13 ------------------------------------------------------- +9 | (() => x) + | ^ + |Reading mutable state of object A during initialization of object B. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object B: [ global-irrelevance3.scala:13 ] + |│ ^ + |├── var y = A.p.g() [ global-irrelevance3.scala:14 ] + |│ ^^^^^^^ + |└── (() => x) [ global-irrelevance3.scala:9 ] + | ^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-irrelevance3.scala b/tests/init-global/neg/global-irrelevance3.scala index 2f36d65d917e..4b53c0335314 100644 --- a/tests/init-global/neg/global-irrelevance3.scala +++ b/tests/init-global/neg/global-irrelevance3.scala @@ -6,9 +6,11 @@ object A: var x = 6 new Pair( y => x = y, - (() => x) // error + (() => x) ) object B: var y = A.p.g() + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-irrelevance4.check b/tests/init-global/neg/global-irrelevance4.check new file mode 100644 index 000000000000..ebabde96294d --- /dev/null +++ b/tests/init-global/neg/global-irrelevance4.check @@ -0,0 +1,12 @@ +-- Warning: tests/init-global/neg/global-irrelevance4.scala:8:9 -------------------------------------------------------- +8 | (y => x = y), + | ^^^^^^^^^^ + | Mutating object A during initialization of object B. + | Mutating other static objects during the initialization of one static object is forbidden. Calling trace: + | ├── object B: [ global-irrelevance4.scala:12 ] + | │ ^ + | ├── A.p.f(10) [ global-irrelevance4.scala:13 ] + | │ ^^^^^^^^^ + | └── (y => x = y), [ global-irrelevance4.scala:8 ] + | ^^^^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-irrelevance4.scala b/tests/init-global/neg/global-irrelevance4.scala index 7a2a778814b2..caf7f2bb6466 100644 --- a/tests/init-global/neg/global-irrelevance4.scala +++ b/tests/init-global/neg/global-irrelevance4.scala @@ -5,9 +5,11 @@ object A: def foo(): Pair = var x = 6 new Pair( - (y => x = y), // error + (y => x = y), () => x ) object B: A.p.f(10) + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-irrelevance5.check b/tests/init-global/neg/global-irrelevance5.check new file mode 100644 index 000000000000..7d472621821c --- /dev/null +++ b/tests/init-global/neg/global-irrelevance5.check @@ -0,0 +1,10 @@ +-- Warning: tests/init-global/neg/global-irrelevance5.scala:6:17 ------------------------------------------------------- +6 | var y = A.array(0) * 2 + | ^^^^^^^^^^ + |Reading mutable state of object A during initialization of object B. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object B: [ global-irrelevance5.scala:5 ] + |│ ^ + |└── var y = A.array(0) * 2 [ global-irrelevance5.scala:6 ] + | ^^^^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-irrelevance5.scala b/tests/init-global/neg/global-irrelevance5.scala index fd5bde3032aa..a1cff0aeb802 100644 --- a/tests/init-global/neg/global-irrelevance5.scala +++ b/tests/init-global/neg/global-irrelevance5.scala @@ -3,4 +3,6 @@ object A: array(0) = 10 object B: - var y = A.array(0) * 2 // error + var y = A.array(0) * 2 + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-irrelevance6.check b/tests/init-global/neg/global-irrelevance6.check new file mode 100644 index 000000000000..52df6bd253e2 --- /dev/null +++ b/tests/init-global/neg/global-irrelevance6.check @@ -0,0 +1,10 @@ +-- Warning: tests/init-global/neg/global-irrelevance6.scala:9:17 ------------------------------------------------------- +9 | var y = A.array(0).foo() * 2 + | ^^^^^^^^^^ + |Reading mutable state of object A during initialization of object B. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object B: [ global-irrelevance6.scala:8 ] + |│ ^ + |└── var y = A.array(0).foo() * 2 [ global-irrelevance6.scala:9 ] + | ^^^^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-irrelevance6.scala b/tests/init-global/neg/global-irrelevance6.scala index 78699b6988b6..a16849a81934 100644 --- a/tests/init-global/neg/global-irrelevance6.scala +++ b/tests/init-global/neg/global-irrelevance6.scala @@ -6,4 +6,6 @@ object A: val n = array(0).foo() // ok, no crash object B: - var y = A.array(0).foo() * 2 // error + var y = A.array(0).foo() * 2 + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-irrelevance7.check b/tests/init-global/neg/global-irrelevance7.check new file mode 100644 index 000000000000..3178c21cbca5 --- /dev/null +++ b/tests/init-global/neg/global-irrelevance7.check @@ -0,0 +1,10 @@ +-- Warning: tests/init-global/neg/global-irrelevance7.scala:10:17 ------------------------------------------------------ +10 | var y = A.array(0).foo() * 2 + | ^^^^^^^^^^ + |Reading mutable state of object A during initialization of object B. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object B: [ global-irrelevance7.scala:9 ] + |│ ^ + |└── var y = A.array(0).foo() * 2 [ global-irrelevance7.scala:10 ] + | ^^^^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-irrelevance7.scala b/tests/init-global/neg/global-irrelevance7.scala index 2c860cbc4259..f679c9cc60b7 100644 --- a/tests/init-global/neg/global-irrelevance7.scala +++ b/tests/init-global/neg/global-irrelevance7.scala @@ -7,4 +7,6 @@ object A: val n = array(0).foo() // ok object B: - var y = A.array(0).foo() * 2 // error + var y = A.array(0).foo() * 2 + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-list.check b/tests/init-global/neg/global-list.check new file mode 100644 index 000000000000..4d4bc3d7e8ca --- /dev/null +++ b/tests/init-global/neg/global-list.check @@ -0,0 +1,37 @@ +-- Warning: tests/init-global/neg/global-list.scala:3:7 ---------------------------------------------------------------- +3 |object O: + | ^ + | Cyclic initialization: object O -> object Foo -> object O. Calling trace: + | ├── object O: [ global-list.scala:3 ] + | │ ^ + | ├── val a = Foo("Apple") [ global-list.scala:4 ] + | │ ^^^ + | ├── object Foo: [ global-list.scala:8 ] + | │ ^ + | └── val all: List[Foo] = List(O.a, O.b, O.c) [ global-list.scala:9 ] + | ^ +-- Warning: tests/init-global/neg/global-list.scala:9:30 --------------------------------------------------------------- +9 | val all: List[Foo] = List(O.a, O.b, O.c) + | ^^^ + | Access uninitialized field value a. Calling trace: + | ├── object Foo: [ global-list.scala:8 ] + | │ ^ + | └── val all: List[Foo] = List(O.a, O.b, O.c) [ global-list.scala:9 ] + | ^^^ +-- Warning: tests/init-global/neg/global-list.scala:9:35 --------------------------------------------------------------- +9 | val all: List[Foo] = List(O.a, O.b, O.c) + | ^^^ + | Access uninitialized field value b. Calling trace: + | ├── object Foo: [ global-list.scala:8 ] + | │ ^ + | └── val all: List[Foo] = List(O.a, O.b, O.c) [ global-list.scala:9 ] + | ^^^ +-- Warning: tests/init-global/neg/global-list.scala:9:40 --------------------------------------------------------------- +9 | val all: List[Foo] = List(O.a, O.b, O.c) + | ^^^ + | Access uninitialized field value c. Calling trace: + | ├── object Foo: [ global-list.scala:8 ] + | │ ^ + | └── val all: List[Foo] = List(O.a, O.b, O.c) [ global-list.scala:9 ] + | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-list.scala b/tests/init-global/neg/global-list.scala old mode 100755 new mode 100644 index cdef6dbf3bbe..e9fed153f78f --- a/tests/init-global/neg/global-list.scala +++ b/tests/init-global/neg/global-list.scala @@ -1,9 +1,10 @@ case class Foo(name: String) -object O: // error +object O: val a = Foo("Apple") val b = Foo("Banana") val c = Foo("Cherry") object Foo: - val all: List[Foo] = List(O.a, O.b, O.c) // error // error // error \ No newline at end of file + val all: List[Foo] = List(O.a, O.b, O.c) +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-local-var.check b/tests/init-global/neg/global-local-var.check new file mode 100644 index 000000000000..bbedc06dce3d --- /dev/null +++ b/tests/init-global/neg/global-local-var.check @@ -0,0 +1,13 @@ +-- Warning: tests/init-global/neg/global-local-var.scala:10:6 ---------------------------------------------------------- +10 | B.a + 10 + sum + | ^^^ + | Access uninitialized field value a. Calling trace: + | ├── object B { [ global-local-var.scala:14 ] + | │ ^ + | ├── val a: Int = A(4).foo() [ global-local-var.scala:15 ] + | │ ^^^^^^^^^^ + | ├── def foo(): Int = { [ global-local-var.scala:2 ] + | │ ^ + | └── B.a + 10 + sum [ global-local-var.scala:10 ] + | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-local-var.scala b/tests/init-global/neg/global-local-var.scala index 6965a42bd37f..9db071de5ae8 100644 --- a/tests/init-global/neg/global-local-var.scala +++ b/tests/init-global/neg/global-local-var.scala @@ -7,10 +7,12 @@ class A(x: Int) { sum += i i += 1 - B.a + 10 + sum // error + B.a + 10 + sum } } object B { val a: Int = A(4).foo() } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-region1.check b/tests/init-global/neg/global-region1.check new file mode 100644 index 000000000000..b3b7e2a3b7ca --- /dev/null +++ b/tests/init-global/neg/global-region1.check @@ -0,0 +1,11 @@ +-- Warning: tests/init-global/neg/global-region1.scala:3:51 ------------------------------------------------------------ +3 |class D(var y: Int) extends B { def foo(): Int = A.m } + | ^^^ + | Access uninitialized field value m. Calling trace: + | ├── object A: [ global-region1.scala:6 ] + | │ ^ + | ├── val m: Int = box1.value.foo() [ global-region1.scala:9 ] + | │ ^^^^^^^^^^^^^^^^ + | └── class D(var y: Int) extends B { def foo(): Int = A.m } [ global-region1.scala:3 ] + | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-region1.scala b/tests/init-global/neg/global-region1.scala index 48473717b5b5..f47e10a06424 100644 --- a/tests/init-global/neg/global-region1.scala +++ b/tests/init-global/neg/global-region1.scala @@ -1,9 +1,11 @@ trait B { def foo(): Int } class C(var x: Int) extends B { def foo(): Int = 20 } -class D(var y: Int) extends B { def foo(): Int = A.m } // error +class D(var y: Int) extends B { def foo(): Int = A.m } class Box(var value: B) object A: val box1: Box = new Box(new C(5)) val box2: Box = new Box(new D(10)) val m: Int = box1.value.foo() + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/i11262.check b/tests/init-global/neg/i11262.check new file mode 100644 index 000000000000..643a70838167 --- /dev/null +++ b/tests/init-global/neg/i11262.check @@ -0,0 +1,15 @@ +-- Warning: tests/init-global/neg/i11262.scala:1:7 --------------------------------------------------------------------- +1 |object A { val x: String = B.y } + | ^ + | Cyclic initialization: object A -> object B -> object A. Calling trace: + | ├── object A { val x: String = B.y } [ i11262.scala:1 ] + | │ ^ + | └── object B { val y: String = A.x } [ i11262.scala:2 ] + | ^ +-- Warning: tests/init-global/neg/i11262.scala:2:29 -------------------------------------------------------------------- +2 |object B { val y: String = A.x } + | ^^^ + | Access uninitialized field value x. Calling trace: + | └── object B { val y: String = A.x } [ i11262.scala:2 ] + | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/i11262.scala b/tests/init-global/neg/i11262.scala index c1c01f6aad8c..befc9ca0834d 100644 --- a/tests/init-global/neg/i11262.scala +++ b/tests/init-global/neg/i11262.scala @@ -1,2 +1,4 @@ -object A { val x: String = B.y } // error -object B { val y: String = A.x } // error +object A { val x: String = B.y } +object B { val y: String = A.x } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/i12544b.check b/tests/init-global/neg/i12544b.check new file mode 100644 index 000000000000..7680b62d0b7b --- /dev/null +++ b/tests/init-global/neg/i12544b.check @@ -0,0 +1,21 @@ +-- Warning: tests/init-global/neg/i12544b.scala:5:9 -------------------------------------------------------------------- +5 | object nested: + | ^ + | Cyclic initialization: object nested -> object Enum -> object nested. Calling trace: + | ├── object nested: [ i12544b.scala:5 ] + | │ ^ + | ├── val a: Enum = Case [ i12544b.scala:6 ] + | │ ^^^^ + | ├── object Enum: [ i12544b.scala:4 ] + | │ ^ + | └── val b: Enum = f(nested.a) [ i12544b.scala:8 ] + | ^^^^^^ +-- Warning: tests/init-global/neg/i12544b.scala:8:25 ------------------------------------------------------------------- +8 | val b: Enum = f(nested.a) + | ^^^^^^^^ + | Access uninitialized field value a. Calling trace: + | ├── object Enum: [ i12544b.scala:4 ] + | │ ^ + | └── val b: Enum = f(nested.a) [ i12544b.scala:8 ] + | ^^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/i12544b.scala b/tests/init-global/neg/i12544b.scala index 586b88df04bd..759829e3bd75 100644 --- a/tests/init-global/neg/i12544b.scala +++ b/tests/init-global/neg/i12544b.scala @@ -2,11 +2,13 @@ enum Enum: case Case object Enum: - object nested: // error + object nested: val a: Enum = Case - val b: Enum = f(nested.a) // error + val b: Enum = f(nested.a) def f(e: Enum): Enum = e @main def main(): Unit = println(Enum.b) + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/i9176.check b/tests/init-global/neg/i9176.check new file mode 100644 index 000000000000..a26b66081d75 --- /dev/null +++ b/tests/init-global/neg/i9176.check @@ -0,0 +1,9 @@ +-- Warning: tests/init-global/neg/i9176.scala:2:12 --------------------------------------------------------------------- +2 |case object A extends Foo(B) + | ^ + | Cyclic initialization: object A -> object B -> object A. Calling trace: + | ├── case object A extends Foo(B) [ i9176.scala:2 ] + | │ ^ + | └── case object B extends Foo(A) [ i9176.scala:3 ] + | ^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/i9176.scala b/tests/init-global/neg/i9176.scala index c93a16f2f8b1..fe1c5388029e 100644 --- a/tests/init-global/neg/i9176.scala +++ b/tests/init-global/neg/i9176.scala @@ -1,5 +1,5 @@ class Foo(val opposite: Foo) -case object A extends Foo(B) // error +case object A extends Foo(B) case object B extends Foo(A) object Test { def main(args: Array[String]): Unit = { @@ -7,3 +7,5 @@ object Test { println(B.opposite) } } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/line-spacing.check b/tests/init-global/neg/line-spacing.check index 6fa8801bb07b..66f695d62ca5 100644 --- a/tests/init-global/neg/line-spacing.check +++ b/tests/init-global/neg/line-spacing.check @@ -1,6 +1,6 @@ --- Error: tests/init-global/neg/line-spacing.scala:4:7 ----------------------------------------------------------------- +-- Warning: tests/init-global/neg/line-spacing.scala:4:7 --------------------------------------------------------------- 3 | B -4 | .s.length // error +4 | .s.length | ^ | Access uninitialized field value s. Calling trace: | ├── object B { [ line-spacing.scala:7 ] @@ -9,5 +9,6 @@ | │ ^^^ | ├── def a: Int = [ line-spacing.scala:2 ] | │ ^ - | └── .s.length // error [ line-spacing.scala:4 ] + | └── .s.length [ line-spacing.scala:4 ] | ^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/line-spacing.scala b/tests/init-global/neg/line-spacing.scala index 42474decb53c..7855e82954b8 100644 --- a/tests/init-global/neg/line-spacing.scala +++ b/tests/init-global/neg/line-spacing.scala @@ -1,9 +1,11 @@ object A { def a: Int = B - .s.length // error + .s.length } object B { val s: String = s"${A.a}a" } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/mutable-array.check b/tests/init-global/neg/mutable-array.check new file mode 100644 index 000000000000..9a877be4eff4 --- /dev/null +++ b/tests/init-global/neg/mutable-array.check @@ -0,0 +1,10 @@ +-- Warning: tests/init-global/neg/mutable-array.scala:8:19 ------------------------------------------------------------- +8 | val x: Int = box.value + | ^^^^^^^^^ + |Reading mutable state of object A during initialization of object B. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object B: [ mutable-array.scala:5 ] + |│ ^ + |└── val x: Int = box.value [ mutable-array.scala:8 ] + | ^^^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/mutable-array.scala b/tests/init-global/neg/mutable-array.scala index 3cbc23a5e127..4fea9a813423 100644 --- a/tests/init-global/neg/mutable-array.scala +++ b/tests/init-global/neg/mutable-array.scala @@ -5,4 +5,6 @@ object A: object B: val boxes: Array[A.Box] = Array(A.box) val box: A.Box = boxes(0) - val x: Int = box.value // error + val x: Int = box.value + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/mutable-read1.check b/tests/init-global/neg/mutable-read1.check new file mode 100644 index 000000000000..4e446490d7e5 --- /dev/null +++ b/tests/init-global/neg/mutable-read1.check @@ -0,0 +1,10 @@ +-- Warning: tests/init-global/neg/mutable-read1.scala:10:20 ------------------------------------------------------------ +10 | val n: Int = boxA.value + | ^^^^^^^^^^ + |Reading mutable state of object A during initialization of object B. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object B: [ mutable-read1.scala:6 ] + |│ ^ + |└── val n: Int = boxA.value [ mutable-read1.scala:10 ] + | ^^^^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/mutable-read1.scala b/tests/init-global/neg/mutable-read1.scala old mode 100755 new mode 100644 index 507a8b7d74ad..78aa0e1c4ff3 --- a/tests/init-global/neg/mutable-read1.scala +++ b/tests/init-global/neg/mutable-read1.scala @@ -7,4 +7,5 @@ object B: val boxB: Box = new Box(5) val boxA: Box = A.box val m: Int = boxB.value - val n: Int = boxA.value // error \ No newline at end of file + val n: Int = boxA.value +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/mutable-read2.check b/tests/init-global/neg/mutable-read2.check new file mode 100644 index 000000000000..24c3c0ef3789 --- /dev/null +++ b/tests/init-global/neg/mutable-read2.check @@ -0,0 +1,10 @@ +-- Warning: tests/init-global/neg/mutable-read2.scala:10:19 ------------------------------------------------------------ +10 | val b: Int = box.value + | ^^^^^^^^^ + |Reading mutable state of object A during initialization of object B. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object B: [ mutable-read2.scala:7 ] + |│ ^ + |└── val b: Int = box.value [ mutable-read2.scala:10 ] + | ^^^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/mutable-read2.scala b/tests/init-global/neg/mutable-read2.scala old mode 100755 new mode 100644 index e7653c63d8bb..d223de11d801 --- a/tests/init-global/neg/mutable-read2.scala +++ b/tests/init-global/neg/mutable-read2.scala @@ -7,4 +7,5 @@ object A: object B: val box: A.Box = A.box val a: Int = box.initial - val b: Int = box.value // error \ No newline at end of file + val b: Int = box.value +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/mutable-read3.check b/tests/init-global/neg/mutable-read3.check new file mode 100644 index 000000000000..e0eeb62cee63 --- /dev/null +++ b/tests/init-global/neg/mutable-read3.check @@ -0,0 +1,10 @@ +-- Warning: tests/init-global/neg/mutable-read3.scala:9:19 ------------------------------------------------------------- +9 | val x: Int = box.value + | ^^^^^^^^^ + |Reading mutable state of object A during initialization of object B. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object B: [ mutable-read3.scala:5 ] + |│ ^ + |└── val x: Int = box.value [ mutable-read3.scala:9 ] + | ^^^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/mutable-read3.scala b/tests/init-global/neg/mutable-read3.scala old mode 100755 new mode 100644 index d103e112f372..d5cf067f7609 --- a/tests/init-global/neg/mutable-read3.scala +++ b/tests/init-global/neg/mutable-read3.scala @@ -6,4 +6,5 @@ object B: val boxes: Array[A.Box] = new Array(1) boxes(0) = A.box val box: A.Box = boxes(0) - val x: Int = box.value // error \ No newline at end of file + val x: Int = box.value +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/mutable-read4.check b/tests/init-global/neg/mutable-read4.check new file mode 100644 index 000000000000..81f3a68e0f8b --- /dev/null +++ b/tests/init-global/neg/mutable-read4.check @@ -0,0 +1,10 @@ +-- Warning: tests/init-global/neg/mutable-read4.scala:10:20 ------------------------------------------------------------ +10 | val n: Int = boxA.value + | ^^^^^^^^^^ + |Reading mutable state of object A during initialization of object B. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object B: [ mutable-read4.scala:6 ] + |│ ^ + |└── val n: Int = boxA.value [ mutable-read4.scala:10 ] + | ^^^^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/mutable-read4.scala b/tests/init-global/neg/mutable-read4.scala old mode 100755 new mode 100644 index 507a8b7d74ad..78aa0e1c4ff3 --- a/tests/init-global/neg/mutable-read4.scala +++ b/tests/init-global/neg/mutable-read4.scala @@ -7,4 +7,5 @@ object B: val boxB: Box = new Box(5) val boxA: Box = A.box val m: Int = boxB.value - val n: Int = boxA.value // error \ No newline at end of file + val n: Int = boxA.value +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/mutable-read5.check b/tests/init-global/neg/mutable-read5.check new file mode 100644 index 000000000000..0fa788588d97 --- /dev/null +++ b/tests/init-global/neg/mutable-read5.check @@ -0,0 +1,12 @@ +-- Warning: tests/init-global/neg/mutable-read5.scala:4:38 ------------------------------------------------------------- +4 | def name(s: String): Name = Name(0, chrs.length) + | ^^^^ + |Reading mutable state of object Names during initialization of object StdNames. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object StdNames: [ mutable-read5.scala:6 ] + |│ ^ + |├── val AnyRef: Names.Name = Names.name("AnyRef") [ mutable-read5.scala:7 ] + |│ ^^^^^^^^^^^^^^^^^^^^ + |└── def name(s: String): Name = Name(0, chrs.length) [ mutable-read5.scala:4 ] + | ^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/mutable-read5.scala b/tests/init-global/neg/mutable-read5.scala old mode 100755 new mode 100644 index c166295bf9fa..884f027c970e --- a/tests/init-global/neg/mutable-read5.scala +++ b/tests/init-global/neg/mutable-read5.scala @@ -1,9 +1,10 @@ object Names: class Name(val start: Int, val length: Int) var chrs: Array[Char] = new Array[Char](0x20000) - def name(s: String): Name = Name(0, chrs.length) // error + def name(s: String): Name = Name(0, chrs.length) object StdNames: val AnyRef: Names.Name = Names.name("AnyRef") val Array: Names.Name = Names.name("Array") - val List: Names.Name = Names.name("List") \ No newline at end of file + val List: Names.Name = Names.name("List") +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/mutable-read6.check b/tests/init-global/neg/mutable-read6.check new file mode 100644 index 000000000000..a43e62bafae0 --- /dev/null +++ b/tests/init-global/neg/mutable-read6.check @@ -0,0 +1,12 @@ +-- Warning: tests/init-global/neg/mutable-read6.scala:7:35 ------------------------------------------------------------- +7 | final def source: SourceFile = _source + | ^^^^^^^ + |Reading mutable state of object Contexts during initialization of object Implicits. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object Implicits: [ mutable-read6.scala:12 ] + |│ ^ + |├── val NoMatchingFailure: SearchFailure = SearchFailure(1, NoContext.source) [ mutable-read6.scala:15 ] + |│ ^^^^^^^^^^^^^^^^ + |└── final def source: SourceFile = _source [ mutable-read6.scala:7 ] + | ^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/mutable-read6.scala b/tests/init-global/neg/mutable-read6.scala old mode 100755 new mode 100644 index 8b00eeaf4216..ce6034769f60 --- a/tests/init-global/neg/mutable-read6.scala +++ b/tests/init-global/neg/mutable-read6.scala @@ -4,7 +4,7 @@ object Contexts: val NoContext: Context = new Context class Context: private var _source: SourceFile = null - final def source: SourceFile = _source // error + final def source: SourceFile = _source def setSource(source: SourceFile) = { this._source = source } @@ -12,4 +12,5 @@ object Contexts: object Implicits: import Contexts.* case class SearchFailure(tag: Int, source: SourceFile) - val NoMatchingFailure: SearchFailure = SearchFailure(1, NoContext.source) \ No newline at end of file + val NoMatchingFailure: SearchFailure = SearchFailure(1, NoContext.source) +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/mutable-read7.check b/tests/init-global/neg/mutable-read7.check new file mode 100644 index 000000000000..5198721ebf40 --- /dev/null +++ b/tests/init-global/neg/mutable-read7.check @@ -0,0 +1,16 @@ +-- Warning: tests/init-global/neg/mutable-read7.scala:7:17 ------------------------------------------------------------- +7 | if (Positioned.debug) { + | ^^^^^^^^^^^^^^^^ + |Reading mutable state of object Positioned during initialization of object Trees. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object Trees: [ mutable-read7.scala:11 ] + |│ ^ + |├── val emptyTree = new Tree [ mutable-read7.scala:13 ] + |│ ^^^^^^^^ + |├── class Tree extends Positioned [ mutable-read7.scala:12 ] + |│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + |├── abstract class Positioned: [ mutable-read7.scala:6 ] + |│ ^ + |└── if (Positioned.debug) { [ mutable-read7.scala:7 ] + | ^^^^^^^^^^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/mutable-read7.scala b/tests/init-global/neg/mutable-read7.scala old mode 100755 new mode 100644 index ad9d154d74f5..b840bdc11a5d --- a/tests/init-global/neg/mutable-read7.scala +++ b/tests/init-global/neg/mutable-read7.scala @@ -4,10 +4,11 @@ object Positioned: var nextId: Int = 0 abstract class Positioned: - if (Positioned.debug) { // error + if (Positioned.debug) { println("do debugging") } object Trees: class Tree extends Positioned - val emptyTree = new Tree \ No newline at end of file + val emptyTree = new Tree +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/mutable-read8.check b/tests/init-global/neg/mutable-read8.check new file mode 100644 index 000000000000..030208a605dd --- /dev/null +++ b/tests/init-global/neg/mutable-read8.check @@ -0,0 +1,14 @@ +-- Warning: tests/init-global/neg/mutable-read8.scala:6:12 ------------------------------------------------------------- +6 | if (Stats.monitored) println("record stats") + | ^^^^^^^^^^^^^^^ + |Reading mutable state of object Stats during initialization of object NoCompleter. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object NoCompleter extends LazyType [ mutable-read8.scala:11 ] + |│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + |├── class LazyType extends UncachedGroundType [ mutable-read8.scala:9 ] + |│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + |├── class UncachedGroundType { [ mutable-read8.scala:5 ] + |│ ^ + |└── if (Stats.monitored) println("record stats") [ mutable-read8.scala:6 ] + | ^^^^^^^^^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/mutable-read8.scala b/tests/init-global/neg/mutable-read8.scala old mode 100755 new mode 100644 index e830fa65be73..0e84fe534b26 --- a/tests/init-global/neg/mutable-read8.scala +++ b/tests/init-global/neg/mutable-read8.scala @@ -3,9 +3,10 @@ object Stats { } class UncachedGroundType { - if (Stats.monitored) println("record stats") // error + if (Stats.monitored) println("record stats") } class LazyType extends UncachedGroundType -object NoCompleter extends LazyType \ No newline at end of file +object NoCompleter extends LazyType +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/partial-ordering.check b/tests/init-global/neg/partial-ordering.check new file mode 100644 index 000000000000..d7a71995dd4c --- /dev/null +++ b/tests/init-global/neg/partial-ordering.check @@ -0,0 +1,13 @@ +-- Warning: tests/init-global/neg/partial-ordering.scala:1:7 ----------------------------------------------------------- +1 |object Names: + | ^ + | Cyclic initialization: object Names -> object MethodName -> object Names. Calling trace: + | ├── object Names: [ partial-ordering.scala:1 ] + | │ ^ + | ├── val ctorName: MethodName = MethodName.apply(ctorString) [ partial-ordering.scala:3 ] + | │ ^^^^^^^^^^ + | ├── object MethodName: [ partial-ordering.scala:6 ] + | │ ^ + | └── val ctor: MethodName = new MethodName(Names.ctorString) [ partial-ordering.scala:7 ] + | ^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/partial-ordering.scala b/tests/init-global/neg/partial-ordering.scala old mode 100755 new mode 100644 index 1bc1b251fb72..7cc1333706a9 --- a/tests/init-global/neg/partial-ordering.scala +++ b/tests/init-global/neg/partial-ordering.scala @@ -1,8 +1,9 @@ -object Names: // error +object Names: val ctorString = "" val ctorName: MethodName = MethodName.apply(ctorString) class MethodName(encoded: String) object MethodName: val ctor: MethodName = new MethodName(Names.ctorString) - def apply(name: String): MethodName = new MethodName(name) \ No newline at end of file + def apply(name: String): MethodName = new MethodName(name) +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/patmat-unapplySeq.check b/tests/init-global/neg/patmat-unapplySeq.check index 8f7a1f64631b..8131e730b8b2 100644 --- a/tests/init-global/neg/patmat-unapplySeq.check +++ b/tests/init-global/neg/patmat-unapplySeq.check @@ -1,5 +1,5 @@ --- Error: tests/init-global/neg/patmat-unapplySeq.scala:8:32 ----------------------------------------------------------- -8 | def apply(i: Int): Box = array(i) // error +-- Warning: tests/init-global/neg/patmat-unapplySeq.scala:8:32 --------------------------------------------------------- +8 | def apply(i: Int): Box = array(i) | ^^^^^^^^ |Reading mutable state of object A during initialization of object B. |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: @@ -7,5 +7,6 @@ |│ ^ |├── case A(b) => [ patmat-unapplySeq.scala:17 ] |│ ^^^^ - |└── def apply(i: Int): Box = array(i) // error [ patmat-unapplySeq.scala:8 ] + |└── def apply(i: Int): Box = array(i) [ patmat-unapplySeq.scala:8 ] | ^^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/patmat-unapplySeq.scala b/tests/init-global/neg/patmat-unapplySeq.scala index 81c853a6e19f..3f0f1c60c801 100644 --- a/tests/init-global/neg/patmat-unapplySeq.scala +++ b/tests/init-global/neg/patmat-unapplySeq.scala @@ -5,7 +5,7 @@ object A: array(0) = new Box(10) def length: Int = array.length - def apply(i: Int): Box = array(i) // error + def apply(i: Int): Box = array(i) def drop(n: Int): Seq[Box] = array.toSeq def toSeq: Seq[Box] = array.toSeq @@ -15,3 +15,5 @@ object A: object B: A.array match case A(b) => + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/patmat-unapplySeq2.check b/tests/init-global/neg/patmat-unapplySeq2.check new file mode 100644 index 000000000000..57a67452c10f --- /dev/null +++ b/tests/init-global/neg/patmat-unapplySeq2.check @@ -0,0 +1,12 @@ +-- Warning: tests/init-global/neg/patmat-unapplySeq2.scala:8:32 -------------------------------------------------------- +8 | def apply(i: Int): Box = array(i) + | ^^^^^^^^ + |Reading mutable state of object A during initialization of object B. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object B: [ patmat-unapplySeq2.scala:15 ] + |│ ^ + |├── case A(b*) => [ patmat-unapplySeq2.scala:17 ] + |│ ^^^^^ + |└── def apply(i: Int): Box = array(i) [ patmat-unapplySeq2.scala:8 ] + | ^^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/patmat-unapplySeq2.scala b/tests/init-global/neg/patmat-unapplySeq2.scala index adab9495db49..c890a09efd2e 100644 --- a/tests/init-global/neg/patmat-unapplySeq2.scala +++ b/tests/init-global/neg/patmat-unapplySeq2.scala @@ -5,7 +5,7 @@ object A: array(0) = new Box(10) def length: Int = array.length - def apply(i: Int): Box = array(i) // error + def apply(i: Int): Box = array(i) def drop(n: Int): Seq[Box] = array.toSeq def toSeq: Seq[Box] = array.toSeq @@ -15,3 +15,5 @@ object A: object B: A.array match case A(b*) => + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/patmat.check b/tests/init-global/neg/patmat.check new file mode 100644 index 000000000000..e05d144db7ce --- /dev/null +++ b/tests/init-global/neg/patmat.check @@ -0,0 +1,27 @@ +-- Warning: tests/init-global/neg/patmat.scala:1:7 --------------------------------------------------------------------- +1 |object A: + | ^ + | Cyclic initialization: object A -> object B -> object A. Calling trace: + | ├── object A: [ patmat.scala:1 ] + | │ ^ + | ├── case Some(x) => println(x * 2 + B.a.size) [ patmat.scala:4 ] + | │ ^ + | ├── object B: [ patmat.scala:7 ] + | │ ^ + | └── if A.a.isEmpty then println(xs.size) [ patmat.scala:12 ] + | ^ +-- Warning: tests/init-global/neg/patmat.scala:29:9 -------------------------------------------------------------------- +29 | object Inner: + | ^ + | Cyclic initialization: object Inner -> object C -> object Inner. Calling trace: + | ├── object Inner: [ patmat.scala:29 ] + | │ ^ + | ├── case Box(f) => f() [ patmat.scala:35 ] + | │ ^^^ + | ├── val foo: () => Int = () => C.a [ patmat.scala:32 ] + | │ ^ + | ├── object C: [ patmat.scala:18 ] + | │ ^ + | └── val a: Int = Inner.b [ patmat.scala:27 ] + | ^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/patmat.scala b/tests/init-global/neg/patmat.scala index 126e66e7cf7b..05f6ea0cdbac 100644 --- a/tests/init-global/neg/patmat.scala +++ b/tests/init-global/neg/patmat.scala @@ -1,4 +1,4 @@ -object A: // error +object A: val a: Option[Int] = Some(3) a match case Some(x) => println(x * 2 + B.a.size) @@ -26,7 +26,7 @@ object C: val a: Int = Inner.b - object Inner: // error + object Inner: val b: Int = 10 val foo: () => Int = () => C.a @@ -34,3 +34,5 @@ object C: (Box(foo): Box[() => Int] | Holder[Int]) match case Box(f) => f() case Holder(x) => x + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/return.check b/tests/init-global/neg/return.check new file mode 100644 index 000000000000..a420b2bab4c3 --- /dev/null +++ b/tests/init-global/neg/return.check @@ -0,0 +1,11 @@ +-- Warning: tests/init-global/neg/return.scala:4:31 -------------------------------------------------------------------- +4 | return (a: Int) => a + B.n + | ^^^ + | Access uninitialized field value n. Calling trace: + | ├── object B: [ return.scala:8 ] + | │ ^ + | ├── val n = A.foo(-10)(20) [ return.scala:9 ] + | │ ^^^^^^^^^^^^^^ + | └── return (a: Int) => a + B.n [ return.scala:4 ] + | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/return.scala b/tests/init-global/neg/return.scala old mode 100755 new mode 100644 index 5cbf6915fc0e..442b0f200f45 --- a/tests/init-global/neg/return.scala +++ b/tests/init-global/neg/return.scala @@ -1,10 +1,12 @@ object A: def foo(x: Int): Int => Int = if x <= 0 then - return (a: Int) => a + B.n // error + return (a: Int) => a + B.n (a: Int) => a * a + x object B: val n = A.foo(-10)(20) + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/return2.check b/tests/init-global/neg/return2.check new file mode 100644 index 000000000000..e0d9a6e33b14 --- /dev/null +++ b/tests/init-global/neg/return2.check @@ -0,0 +1,15 @@ +-- Warning: tests/init-global/neg/return2.scala:3:30 ------------------------------------------------------------------- +3 | val f = (a: Int) => a + B.n + | ^^^ + | Access uninitialized field value n. Calling trace: + | ├── object B: [ return2.scala:12 ] + | │ ^ + | ├── val n = A.foo(-10)(20) [ return2.scala:13 ] + | │ ^^^^^^^^^^^^^^ + | └── val f = (a: Int) => a + B.n [ return2.scala:3 ] + | ^^^ +-- Warning: tests/init-global/neg/return2.scala:6:18 ------------------------------------------------------------------- +6 | val g = () => return f + | ^^^^^^^^ + | Non local returns are no longer supported; use `boundary` and `boundary.break` in `scala.util` instead +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/return2.scala b/tests/init-global/neg/return2.scala old mode 100755 new mode 100644 index 6a4dec50c2dd..3c93fe9120c6 --- a/tests/init-global/neg/return2.scala +++ b/tests/init-global/neg/return2.scala @@ -1,6 +1,6 @@ object A: def foo(x: Int): Int => Int = - val f = (a: Int) => a + B.n // error + val f = (a: Int) => a + B.n var i = 0 val g = () => return f @@ -11,3 +11,5 @@ object A: object B: val n = A.foo(-10)(20) + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/t5366.check b/tests/init-global/neg/t5366.check new file mode 100644 index 000000000000..3aeda68fd96f --- /dev/null +++ b/tests/init-global/neg/t5366.check @@ -0,0 +1,21 @@ +-- Warning: tests/init-global/neg/t5366.scala:3:12 --------------------------------------------------------------------- +3 |case object ObjA extends IdAndMsg(1) + | ^ + | Cyclic initialization: object ObjA -> object IdAndMsg -> object ObjA. Calling trace: + | ├── case object ObjA extends IdAndMsg(1) [ t5366.scala:3 ] + | │ ^ + | ├── object IdAndMsg { [ t5366.scala:6 ] + | │ ^ + | └── val values = List(ObjA , ObjB) [ t5366.scala:7 ] + | ^^^^ +-- Warning: tests/init-global/neg/t5366.scala:6:7 ---------------------------------------------------------------------- +6 |object IdAndMsg { + | ^ + | Cyclic initialization: object IdAndMsg -> object ObjB -> object IdAndMsg. Calling trace: + | ├── object IdAndMsg { [ t5366.scala:6 ] + | │ ^ + | ├── val values = List(ObjA , ObjB) [ t5366.scala:7 ] + | │ ^^^^ + | └── case object ObjB extends IdAndMsg(2) [ t5366.scala:4 ] + | ^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/t5366.scala b/tests/init-global/neg/t5366.scala index 854bdfe0544b..2283b79bfb8f 100644 --- a/tests/init-global/neg/t5366.scala +++ b/tests/init-global/neg/t5366.scala @@ -1,9 +1,9 @@ class IdAndMsg(val id: Int, val msg: String = "") -case object ObjA extends IdAndMsg(1) // error +case object ObjA extends IdAndMsg(1) case object ObjB extends IdAndMsg(2) -object IdAndMsg { // error +object IdAndMsg { val values = List(ObjA , ObjB) } @@ -12,4 +12,5 @@ object Test { ObjA println(IdAndMsg.values) } -} \ No newline at end of file +} +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/t9115.check b/tests/init-global/neg/t9115.check new file mode 100644 index 000000000000..a55c2eb151a1 --- /dev/null +++ b/tests/init-global/neg/t9115.check @@ -0,0 +1,21 @@ +-- Warning: tests/init-global/neg/t9115.scala:4:14 --------------------------------------------------------------------- +4 | case object D1 extends Z(aaa) + | ^ + | Cyclic initialization: object D1 -> object D -> object D1. Calling trace: + | ├── case object D1 extends Z(aaa) [ t9115.scala:4 ] + | │ ^^^ + | ├── object D { [ t9115.scala:1 ] + | │ ^ + | └── println(D1) [ t9115.scala:6 ] + | ^^ +-- Warning: tests/init-global/neg/t9115.scala:1:7 ---------------------------------------------------------------------- +1 |object D { + | ^ + | Cyclic initialization: object D -> object D2 -> object D. Calling trace: + | ├── object D { [ t9115.scala:1 ] + | │ ^ + | ├── println(D2) [ t9115.scala:7 ] + | │ ^^ + | └── case object D2 extends Z(aaa) // 'null' when calling D.D2 first time [ t9115.scala:5 ] + | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/t9115.scala b/tests/init-global/neg/t9115.scala index a3020c6939a8..aa9573554260 100644 --- a/tests/init-global/neg/t9115.scala +++ b/tests/init-global/neg/t9115.scala @@ -1,8 +1,10 @@ -object D { // error +object D { def aaa = 1 //that’s the reason class Z (depends: Any) - case object D1 extends Z(aaa) // 'null' when calling D.D1 first time // error + case object D1 extends Z(aaa) case object D2 extends Z(aaa) // 'null' when calling D.D2 first time println(D1) println(D2) } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/t9261.check b/tests/init-global/neg/t9261.check new file mode 100644 index 000000000000..dbda32347e74 --- /dev/null +++ b/tests/init-global/neg/t9261.check @@ -0,0 +1,9 @@ +-- Warning: tests/init-global/neg/t9261.scala:2:12 --------------------------------------------------------------------- +2 |case object Buy extends OrderType(Sell) + | ^ + | Cyclic initialization: object Buy -> object Sell -> object Buy. Calling trace: + | ├── case object Buy extends OrderType(Sell) [ t9261.scala:2 ] + | │ ^^^^ + | └── case object Sell extends OrderType(Buy) [ t9261.scala:3 ] + | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/t9261.scala b/tests/init-global/neg/t9261.scala index 1e23bedb9b6a..9eb7f255492c 100644 --- a/tests/init-global/neg/t9261.scala +++ b/tests/init-global/neg/t9261.scala @@ -1,3 +1,5 @@ sealed abstract class OrderType(val reverse: OrderType) -case object Buy extends OrderType(Sell) // error +case object Buy extends OrderType(Sell) case object Sell extends OrderType(Buy) + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/t9312.check b/tests/init-global/neg/t9312.check new file mode 100644 index 000000000000..d6f1b00b1a09 --- /dev/null +++ b/tests/init-global/neg/t9312.check @@ -0,0 +1,29 @@ +-- Warning: tests/init-global/neg/t9312.scala:18:11 -------------------------------------------------------------------- +18 | object Child1 extends Child + | ^ + | Cyclic initialization: object Child1 -> object Parent -> object Child1. Calling trace: + | ├── object Child1 extends Child [ t9312.scala:18 ] + | │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ├── trait Child { [ t9312.scala:12 ] + | │ ^ + | ├── val parent = Parent [ t9312.scala:14 ] + | │ ^^^^^^ + | ├── object Parent { [ t9312.scala:11 ] + | │ ^ + | └── final val children = Set(Child1, Child2) [ t9312.scala:21 ] + | ^^^^^^ +-- Warning: tests/init-global/neg/t9312.scala:11:9 --------------------------------------------------------------------- +11 | object Parent { + | ^ + | Cyclic initialization: object Parent -> object Child2 -> object Parent. Calling trace: + | ├── object Parent { [ t9312.scala:11 ] + | │ ^ + | ├── final val children = Set(Child1, Child2) [ t9312.scala:21 ] + | │ ^^^^^^ + | ├── object Child2 extends Child [ t9312.scala:19 ] + | │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ├── trait Child { [ t9312.scala:12 ] + | │ ^ + | └── val parent = Parent [ t9312.scala:14 ] + | ^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/t9312.scala b/tests/init-global/neg/t9312.scala index d88093a2f67a..7dc9af580162 100644 --- a/tests/init-global/neg/t9312.scala +++ b/tests/init-global/neg/t9312.scala @@ -8,16 +8,18 @@ object DeadLockTest { } - object Parent { // error + object Parent { trait Child { Thread.sleep(2000) // ensure concurrent behavior val parent = Parent def siblings = parent.children - this } - object Child1 extends Child // error + object Child1 extends Child object Child2 extends Child final val children = Set(Child1, Child2) } } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/t9360.check b/tests/init-global/neg/t9360.check new file mode 100644 index 000000000000..23ceea224a10 --- /dev/null +++ b/tests/init-global/neg/t9360.check @@ -0,0 +1,21 @@ +-- Warning: tests/init-global/neg/t9360.scala:8:9 ---------------------------------------------------------------------- +8 | object AObj extends BaseClass(s) + | ^ + | Cyclic initialization: object AObj -> object Obj -> object AObj. Calling trace: + | ├── object AObj extends BaseClass(s) [ t9360.scala:8 ] + | │ ^ + | ├── object Obj { [ t9360.scala:5 ] + | │ ^ + | └── val list = List(AObj, BObj) [ t9360.scala:12 ] + | ^^^^ +-- Warning: tests/init-global/neg/t9360.scala:5:7 ---------------------------------------------------------------------- +5 |object Obj { + | ^ + | Cyclic initialization: object Obj -> object BObj -> object Obj. Calling trace: + | ├── object Obj { [ t9360.scala:5 ] + | │ ^ + | ├── val list = List(AObj, BObj) [ t9360.scala:12 ] + | │ ^^^^ + | └── object BObj extends BaseClass(s) [ t9360.scala:10 ] + | ^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/t9360.scala b/tests/init-global/neg/t9360.scala index 2ec0c740d739..0fca843cd01d 100644 --- a/tests/init-global/neg/t9360.scala +++ b/tests/init-global/neg/t9360.scala @@ -2,10 +2,10 @@ class BaseClass(s: String) { def print: Unit = () } -object Obj { // error +object Obj { val s: String = "hello" - object AObj extends BaseClass(s) // error + object AObj extends BaseClass(s) object BObj extends BaseClass(s) @@ -23,3 +23,5 @@ object ObjectInit { Obj.print } } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/unapply-implicit-arg.check b/tests/init-global/neg/unapply-implicit-arg.check new file mode 100644 index 000000000000..4e45d79e7e14 --- /dev/null +++ b/tests/init-global/neg/unapply-implicit-arg.check @@ -0,0 +1,9 @@ +-- Warning: tests/init-global/neg/unapply-implicit-arg.scala:11:16 ----------------------------------------------------- +11 | val i2: Int = i2 match + | ^^ + | Access uninitialized field value i2. Calling trace: + | ├── object Bar { [ unapply-implicit-arg.scala:1 ] + | │ ^ + | └── val i2: Int = i2 match [ unapply-implicit-arg.scala:11 ] + | ^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/unapply-implicit-arg.scala b/tests/init-global/neg/unapply-implicit-arg.scala index bf41fbbf9412..dd8d03821d0a 100644 --- a/tests/init-global/neg/unapply-implicit-arg.scala +++ b/tests/init-global/neg/unapply-implicit-arg.scala @@ -8,7 +8,8 @@ object Bar { given Foo = new Foo val i1: Int = 0 - val i2: Int = i2 match // error + val i2: Int = i2 match case Bar(i) => i case _ => 0 -} \ No newline at end of file +} +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/unapply-implicit-arg2.check b/tests/init-global/neg/unapply-implicit-arg2.check new file mode 100644 index 000000000000..ec317d59f1bd --- /dev/null +++ b/tests/init-global/neg/unapply-implicit-arg2.check @@ -0,0 +1,13 @@ +-- Warning: tests/init-global/neg/unapply-implicit-arg2.scala:7:51 ----------------------------------------------------- +7 | if i == 0 then Some(f1.m1(i1)) else Some(f1.m2(i2)) + | ^^ + | Access uninitialized field value i2. Calling trace: + | ├── object Bar { [ unapply-implicit-arg2.scala:1 ] + | │ ^ + | ├── case Bar(i) => i [ unapply-implicit-arg2.scala:12 ] + | │ ^^^^^^ + | ├── def unapply(using f1: Foo)(i: Int): Option[Int] = [ unapply-implicit-arg2.scala:6 ] + | │ ^ + | └── if i == 0 then Some(f1.m1(i1)) else Some(f1.m2(i2)) [ unapply-implicit-arg2.scala:7 ] + | ^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/unapply-implicit-arg2.scala b/tests/init-global/neg/unapply-implicit-arg2.scala index c0a16faac377..b180e5eee495 100644 --- a/tests/init-global/neg/unapply-implicit-arg2.scala +++ b/tests/init-global/neg/unapply-implicit-arg2.scala @@ -4,7 +4,7 @@ object Bar { def m2(i: Int) = i+2 } def unapply(using f1: Foo)(i: Int): Option[Int] = - if i == 0 then Some(f1.m1(i1)) else Some(f1.m2(i2)) // error + if i == 0 then Some(f1.m1(i1)) else Some(f1.m2(i2)) given Foo = new Foo val i1: Int = 0 @@ -12,3 +12,5 @@ object Bar { case Bar(i) => i case _ => 0 } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/unapply-implicit-arg3.check b/tests/init-global/neg/unapply-implicit-arg3.check new file mode 100644 index 000000000000..3bb9c0ad2930 --- /dev/null +++ b/tests/init-global/neg/unapply-implicit-arg3.check @@ -0,0 +1,15 @@ +-- Warning: tests/init-global/neg/unapply-implicit-arg3.scala:4:25 ----------------------------------------------------- +4 | def m2(i: Int) = i + i2 + | ^^ + | Access uninitialized field value i2. Calling trace: + | ├── object Bar { [ unapply-implicit-arg3.scala:1 ] + | │ ^ + | ├── case Bar(i) => i [ unapply-implicit-arg3.scala:12 ] + | │ ^^^^^^ + | ├── def unapply(using f1: Foo)(i: Int): Option[Int] = [ unapply-implicit-arg3.scala:6 ] + | │ ^ + | ├── if i == 0 then Some(f1.m1(i)) else Some(f1.m2(i)) [ unapply-implicit-arg3.scala:7 ] + | │ ^^^^^^^^ + | └── def m2(i: Int) = i + i2 [ unapply-implicit-arg3.scala:4 ] + | ^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/unapply-implicit-arg3.scala b/tests/init-global/neg/unapply-implicit-arg3.scala index efa348f6cfdb..3bf923eeeb4e 100644 --- a/tests/init-global/neg/unapply-implicit-arg3.scala +++ b/tests/init-global/neg/unapply-implicit-arg3.scala @@ -1,7 +1,7 @@ object Bar { class Foo { def m1(i: Int) = i + i1 - def m2(i: Int) = i + i2 // error + def m2(i: Int) = i + i2 } def unapply(using f1: Foo)(i: Int): Option[Int] = if i == 0 then Some(f1.m1(i)) else Some(f1.m2(i)) @@ -12,3 +12,5 @@ object Bar { case Bar(i) => i case _ => 0 } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/unapplySeq-implicit-arg.check b/tests/init-global/neg/unapplySeq-implicit-arg.check new file mode 100644 index 000000000000..d021cd1f5d94 --- /dev/null +++ b/tests/init-global/neg/unapplySeq-implicit-arg.check @@ -0,0 +1,9 @@ +-- Warning: tests/init-global/neg/unapplySeq-implicit-arg.scala:11:20 -------------------------------------------------- +11 | val i2: Int = Seq(i2) match + | ^^ + | Access uninitialized field value i2. Calling trace: + | ├── object Bar { [ unapplySeq-implicit-arg.scala:1 ] + | │ ^ + | └── val i2: Int = Seq(i2) match [ unapplySeq-implicit-arg.scala:11 ] + | ^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/unapplySeq-implicit-arg.scala b/tests/init-global/neg/unapplySeq-implicit-arg.scala index e58635a3090f..1ec3ab6fa79a 100644 --- a/tests/init-global/neg/unapplySeq-implicit-arg.scala +++ b/tests/init-global/neg/unapplySeq-implicit-arg.scala @@ -8,7 +8,9 @@ object Bar { given Foo = new Foo val i1: Int = 0 - val i2: Int = Seq(i2) match // error + val i2: Int = Seq(i2) match case Bar(i) => i case _ => 0 } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/unapplySeq-implicit-arg2.check b/tests/init-global/neg/unapplySeq-implicit-arg2.check new file mode 100644 index 000000000000..2e5164d7b405 --- /dev/null +++ b/tests/init-global/neg/unapplySeq-implicit-arg2.check @@ -0,0 +1,13 @@ +-- Warning: tests/init-global/neg/unapplySeq-implicit-arg2.scala:4:9 --------------------------------------------------- +4 | Some(i1 +: seqi) + | ^^ + |Access uninitialized field value i1. Calling trace: + |├── object Bar { [ unapplySeq-implicit-arg2.scala:1 ] + |│ ^ + |├── case Bar(i) => i [ unapplySeq-implicit-arg2.scala:7 ] + |│ ^^^^^^ + |├── def unapplySeq(using f1: Foo)(using f2: Foo)(seqi: Seq[Int])(using Foo): Option[Seq[Int]] = [ unapplySeq-implicit-arg2.scala:3 ] + |│ ^ + |└── Some(i1 +: seqi) [ unapplySeq-implicit-arg2.scala:4 ] + | ^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/unapplySeq-implicit-arg2.scala b/tests/init-global/neg/unapplySeq-implicit-arg2.scala index 35f5105b84d2..7a48651a3a7a 100644 --- a/tests/init-global/neg/unapplySeq-implicit-arg2.scala +++ b/tests/init-global/neg/unapplySeq-implicit-arg2.scala @@ -1,10 +1,12 @@ object Bar { class Foo def unapplySeq(using f1: Foo)(using f2: Foo)(seqi: Seq[Int])(using Foo): Option[Seq[Int]] = - Some(i1 +: seqi) // error + Some(i1 +: seqi) given Foo = new Foo val i1: Int = Seq(0) match { case Bar(i) => i case _ => 0 } } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/unapplySeq-implicit-arg3.check b/tests/init-global/neg/unapplySeq-implicit-arg3.check new file mode 100644 index 000000000000..59ea56320452 --- /dev/null +++ b/tests/init-global/neg/unapplySeq-implicit-arg3.check @@ -0,0 +1,15 @@ +-- Warning: tests/init-global/neg/unapplySeq-implicit-arg3.scala:3:27 -------------------------------------------------- +3 | def m(seq: Seq[Int]) = i1 +: seq + | ^^ + |Access uninitialized field value i1. Calling trace: + |├── object Bar { [ unapplySeq-implicit-arg3.scala:1 ] + |│ ^ + |├── case Bar(i, _) => i [ unapplySeq-implicit-arg3.scala:9 ] + |│ ^^^^^^^^^ + |├── def unapplySeq(using f1: Foo)(seqi: Seq[Int])(using Foo): Option[Seq[Int]] = [ unapplySeq-implicit-arg3.scala:5 ] + |│ ^ + |├── Some(f1.m(seqi)) [ unapplySeq-implicit-arg3.scala:6 ] + |│ ^^^^^^^^^^ + |└── def m(seq: Seq[Int]) = i1 +: seq [ unapplySeq-implicit-arg3.scala:3 ] + | ^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/unapplySeq-implicit-arg3.scala b/tests/init-global/neg/unapplySeq-implicit-arg3.scala index 2b5cdd327e57..9efcac577bd3 100644 --- a/tests/init-global/neg/unapplySeq-implicit-arg3.scala +++ b/tests/init-global/neg/unapplySeq-implicit-arg3.scala @@ -1,6 +1,6 @@ object Bar { class Foo { - def m(seq: Seq[Int]) = i1 +: seq // error + def m(seq: Seq[Int]) = i1 +: seq } def unapplySeq(using f1: Foo)(seqi: Seq[Int])(using Foo): Option[Seq[Int]] = Some(f1.m(seqi)) @@ -10,3 +10,5 @@ object Bar { case _ => 0 } } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/adhoc-extension/B.scala b/tests/neg/adhoc-extension/B.scala index 2343a9bc0060..efa783f87178 100644 --- a/tests/neg/adhoc-extension/B.scala +++ b/tests/neg/adhoc-extension/B.scala @@ -1,10 +1,11 @@ //> using options -source future -feature -Xfatal-warnings package adhoc -class B extends A // error: adhoc-extension (under -strict -feature -Xfatal-warnings) -class C extends A // error +class B extends A // warn: adhoc-extension (under -strict -feature -Xfatal-warnings) +class C extends A // warn object O { - val a = new A {} // error - object E extends A // error -} \ No newline at end of file + val a = new A {} // warn + object E extends A // warn +} +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/capt-wf.scala b/tests/neg/capt-wf.scala index fbd334726e55..61dde899a585 100644 --- a/tests/neg/capt-wf.scala +++ b/tests/neg/capt-wf.scala @@ -13,12 +13,12 @@ def test(c: Cap, other: String): Unit = val x3a: () -> String = s1 val s2 = () => if x1 == null then "" else "abc" val x4: C^{s2} = ??? // OK - val x5: C^{c, c} = ??? // error: redundant // error: redundant + val x5: C^{c, c} = ??? // warn: redundant // warn: redundant // val x6: C^{c}^{c} = ??? // would be syntax error - val x7: Cap^{c} = ??? // error: redundant + val x7: Cap^{c} = ??? // warn: redundant // val x8: C^{c}^{cap} = ??? // would be syntax error - val x9: C^{c, cap} = ??? // error: redundant - val x10: C^{cap, c} = ??? // error: redundant + val x9: C^{c, cap} = ??? // warn: redundant + val x10: C^{cap, c} = ??? // warn: redundant def even(n: Int): Boolean = if n == 0 then true else odd(n - 1) def odd(n: Int): Boolean = if n == 1 then true else even(n - 1) @@ -34,4 +34,5 @@ def test(c: Cap, other: String): Unit = if n == 0 then true else od(n - 1) val y3: String^{ev} = ??? // error cs is empty - () \ No newline at end of file + () +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/classtag-typetest/3_1-migration.scala b/tests/neg/classtag-typetest/3_1-migration.scala index 41e0537a6dc1..fb8f3beedc48 100644 --- a/tests/neg/classtag-typetest/3_1-migration.scala +++ b/tests/neg/classtag-typetest/3_1-migration.scala @@ -5,4 +5,5 @@ import scala.reflect.ClassTag def f3_1m[T: ClassTag](x: Any): Unit = x match - case _: T => // error + case _: T => // warn +// nopos-error: No warnings can be incurred under -Werror. diff --git a/tests/neg/classtag-typetest/3_1.scala b/tests/neg/classtag-typetest/3_1.scala index d9101ff2ae57..798489bb90fa 100644 --- a/tests/neg/classtag-typetest/3_1.scala +++ b/tests/neg/classtag-typetest/3_1.scala @@ -5,4 +5,5 @@ import scala.reflect.ClassTag def f3_1[T: ClassTag](x: Any): Unit = x match - case _: T => // error + case _: T => // warn +// nopos-error: No warnings can be incurred under -Werror. diff --git a/tests/neg/i12188/Test.scala b/tests/neg/i12188/Test.scala index 66864438694e..9bbbf6431b13 100644 --- a/tests/neg/i12188/Test.scala +++ b/tests/neg/i12188/Test.scala @@ -7,5 +7,7 @@ case class PC2(b: Int) extends P def Test = MatchTest.test(PC2(10): P) def foo(x: P): Unit = - x match // error - case _: PC1 => \ No newline at end of file + x match // warn + case _: PC1 => + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i13946/BadPrinter.scala b/tests/neg/i13946/BadPrinter.scala index 46913d2c2805..39e8a921d498 100644 --- a/tests/neg/i13946/BadPrinter.scala +++ b/tests/neg/i13946/BadPrinter.scala @@ -2,5 +2,6 @@ // in BadPrinter.scala import language.future -class BadPrinter extends Printer: // error +class BadPrinter extends Printer: // warn override def print(s: String): Unit = println("Bad!!!") +// nopos-error: No warnings can be incurred under -Werror. diff --git a/tests/neg/i14386.scala b/tests/neg/i14386.scala index be0b2497ed5f..d9647da49525 100644 --- a/tests/neg/i14386.scala +++ b/tests/neg/i14386.scala @@ -42,7 +42,8 @@ def braced() = s"""begin ${ val level = 10 - val msg = "hello, world" // error he lets me off with a warning - log(level, msg) // error + val msg = "hello, world" // warn he lets me off with a warning + log(level, msg) // warn } end""" +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i16876/Test.scala b/tests/neg/i16876/Test.scala index 2dd6bfb34421..71a01128990e 100644 --- a/tests/neg/i16876/Test.scala +++ b/tests/neg/i16876/Test.scala @@ -4,8 +4,7 @@ object Foo { private def myMethod(a: Int, b: Int, c: Int) = adder // ok myMethod(1, 2, 3) - private def myMethodFailing(a: Int, b: Int, c: Int) = a + 0 // error // error + private def myMethodFailing(a: Int, b: Int, c: Int) = a + 0 // warn // warn myMethodFailing(1, 2, 3) } - - +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i17612b/i17612b.scala b/tests/neg/i17612b/i17612b.scala index d16feb240c2a..a1aa1973cea2 100644 --- a/tests/neg/i17612b/i17612b.scala +++ b/tests/neg/i17612b/i17612b.scala @@ -18,12 +18,12 @@ object i17612b: trait BaseB trait BaseC(var x2: Int) - class Derived(x : Int, x3: Int, y: Int, z2: Int) extends BaseB, BaseC(x3), Base(x, y + 1, z2): // error // error / for x, y translated to private[this] x field & shadowing var Base.x, Base.y + class Derived(x : Int, x3: Int, y: Int, z2: Int) extends BaseB, BaseC(x3), Base(x, y + 1, z2): // warn // warn / for x, y translated to private[this] x field & shadowing var Base.x, Base.y private def hello() = 4 - private val shadowed2 = 2 + 2 // error (In Scala 2 we cannot do that got the warning) - private[this] val shadowed3 = 3 + 3 // error + private val shadowed2 = 2 + 2 // warn (In Scala 2 we cannot do that got the warning) + private[this] val shadowed3 = 3 + 3 // warn - private val shadowed5 = 5 + 5 // error + private val shadowed5 = 5 + 5 // warn private val notShadowed2 = -4 val lambda: Int => Int => Int = @@ -38,7 +38,8 @@ object i17612b: override def toString = s"x : ${x.toString}, y : ${y.toString}" - class UnderDerived(x: Int, y: Int, z: Int) extends Derived(x, 1, y, z) // error // error // error + class UnderDerived(x: Int, y: Int, z: Int) extends Derived(x, 1, y, z) // warn // warn // warn def main(args: Array[String]) = val derived = new Derived(1, 1, 1, 1) +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i17613b/i17613b.scala b/tests/neg/i17613b/i17613b.scala index b0c4f11b949c..42506a274a65 100644 --- a/tests/neg/i17613b/i17613b.scala +++ b/tests/neg/i17613b/i17613b.scala @@ -1,44 +1,47 @@ -//> using options -Xfatal-warnings -Xlint:type-parameter-shadow +//> using options -Xlint:type-parameter-shadow -Xfatal-warnings object i17613b: import importTry._ class B: type T = Int + trait Typeclass[T] trait D - def foobar[ImTrait](in: D) = in.toString // error - type MySeq[ImTrait] = Seq[D] // error + def foobar[ImTrait](in: D) = in.toString // warn + type MySeq[ImTrait] = Seq[D] // warn - def foobar2[ImClass](in: D) = in.toString // error - type MySeq2[ImClass] = Seq[D] // error + def foobar2[ImClass](in: D) = in.toString // warn + type MySeq2[ImClass] = Seq[D] // warn - given [A]: Ordering[Int]() - type TypeLambda[A] = [ImTrait] =>> Map[ImTrait, B] // error - type PolyFun[A] = [ImTrait] => ImTrait => B // error + given [A]: Typeclass[Int]() // warn + type TypeLambda[A] = [ImTrait] =>> Map[ImTrait, B] + type PolyFun[A] = [ImTrait] => ImTrait => B // warn type MatchType[A] = A match { case String => Int case ImTrait => Boolean } - class Foo[T](t: T): // error class parameter shadows some other type + class Foo[T](t: T): // warn class parameter shadows some other type import scala.collection.immutable.{List => List1} def bar[List](w: T) = w.toString // no warning due to the explicit import renaming - def intType[List1](x: T) = x.toString() // error + def intType[List1](x: T) = x.toString() // warn type Y[List] = Int // no warning - given [A]: Ordering[A]() - given [Int]: Ordering[Int]() // error + given [A]: Typeclass[A]() + given [Int]: Typeclass[Int]() // warn - class C[M[List[_]]] // error List not renamed here - type E[M[Int[_]]] = Int // error + class C[M[List[_]]] // warn List not renamed here + type E[M[Int[_]]] = Int // warn - def foo[N[M[List[_]]]] = // error + def foo[N[M[List[_]]]] = // warn import importTry.{ImClass => ImClassR} def inner[ImClass] = // no warning - type Z[ImClassR] = Int // error - class InnerCl[ImClassR] // error + type Z[ImClassR] = Int // warn + class InnerCl[ImClassR] // warn 5 - def main(args: Array[String]) = println("Test for type parameter shadow") \ No newline at end of file + def main(args: Array[String]) = println("Test for type parameter shadow") + + // nopos-error fatal warnings diff --git a/tests/neg/i4986d.scala b/tests/neg/i4986d.scala index 909221bea5f0..73c92822a291 100644 --- a/tests/neg/i4986d.scala +++ b/tests/neg/i4986d.scala @@ -3,10 +3,10 @@ trait Foo[A] type Fooable[A] = { - def foo(implicit @annotation.implicitNotFound("There's no Foo[${A}]") ev: Foo[A]): Any // error + def foo(implicit @annotation.implicitNotFound("There's no Foo[${A}]") ev: Foo[A]): Any // warn type InnerFooable = { - def foo(implicit @annotation.implicitNotFound("There's no Foo[${A}]") ev: Foo[A]): Any // error + def foo(implicit @annotation.implicitNotFound("There's no Foo[${A}]") ev: Foo[A]): Any // warn } } @@ -22,3 +22,4 @@ trait Bar[A] type Barable[A] = { def bar(implicit ev: Bar[A]): Any // ok } +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i8681.scala b/tests/neg/i8681.scala index 4d91509eb0d3..f7e7066fd2e0 100644 --- a/tests/neg/i8681.scala +++ b/tests/neg/i8681.scala @@ -13,4 +13,5 @@ val b = (A(1): A | B) match { case A(_) => "OK" case B(_) => "OK" case C(_) => "NOT OK" // error -} \ No newline at end of file +} +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i8711.check b/tests/neg/i8711.check index 5dbeeb22460c..10764e936b5a 100644 --- a/tests/neg/i8711.check +++ b/tests/neg/i8711.check @@ -1,12 +1,21 @@ --- [E030] Match case Unreachable Error: tests/neg/i8711.scala:9:9 ------------------------------------------------------ +-- [E030] Match case Unreachable Warning: tests/neg/i8711.scala:9:9 ---------------------------------------------------- 9 | case x: B => x // error: this case is unreachable since class A is not a subclass of class B | ^^^^ | Unreachable case --- [E030] Match case Unreachable Error: tests/neg/i8711.scala:14:9 ----------------------------------------------------- +-- [E030] Match case Unreachable Warning: tests/neg/i8711.scala:14:9 --------------------------------------------------- 14 | case x: C => x // error | ^^^^ | Unreachable case --- [E030] Match case Unreachable Error: tests/neg/i8711.scala:19:9 ----------------------------------------------------- -19 | case x: (B | C) => x // error +-- [E030] Match case Unreachable Warning: tests/neg/i8711.scala:19:9 --------------------------------------------------- +19 | case x: (B | C) => x // warn | ^^^^^^^^^^ | Unreachable case +-- Error: tests/neg/i8711.scala:9:9 ------------------------------------------------------------------------------------ +9 | case x: B => x // error: this case is unreachable since class A is not a subclass of class B + | ^ + | this case is unreachable since type A and class B are unrelated +-- Error: tests/neg/i8711.scala:14:9 ----------------------------------------------------------------------------------- +14 | case x: C => x // error + | ^ + | this case is unreachable since type A | B and class C are unrelated +No warnings can be incurred under -Werror. diff --git a/tests/neg/i8711.scala b/tests/neg/i8711.scala index 2647e20fe03b..0ae32393a327 100644 --- a/tests/neg/i8711.scala +++ b/tests/neg/i8711.scala @@ -16,7 +16,9 @@ object Test { } def baz(x: A) = x match { - case x: (B | C) => x // error + case x: (B | C) => x // warn case _ => } } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i9408b/Test_2.scala b/tests/neg/i9408b/Test_2.scala index 6b3cbbafcb0e..11cad10f1e9f 100644 --- a/tests/neg/i9408b/Test_2.scala +++ b/tests/neg/i9408b/Test_2.scala @@ -5,5 +5,7 @@ import scala.language.implicitConversions object Test { import test.conversions.Conv.* - val length: Int = "abc" // error + val length: Int = "abc" // warn } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/impl-conv/A.scala b/tests/neg/impl-conv/A.scala index 31eccf4fa4f7..9c47e67ca789 100644 --- a/tests/neg/impl-conv/A.scala +++ b/tests/neg/impl-conv/A.scala @@ -2,7 +2,7 @@ package implConv object A { - implicit def s2i(x: String): Int = Integer.parseInt(x) // error: feature + implicit def s2i(x: String): Int = Integer.parseInt(x) // warn: feature given i2s: Conversion[Int, String] = _.toString // ok implicit class Foo(x: String) { diff --git a/tests/neg/impl-conv/B.scala b/tests/neg/impl-conv/B.scala index 618868b8bbc0..b475c460f318 100644 --- a/tests/neg/impl-conv/B.scala +++ b/tests/neg/impl-conv/B.scala @@ -8,5 +8,6 @@ object B { "".foo val x: Int = "" // ok - val y: String = 1 // error: feature + val y: String = 1 // warn: feature } +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/indentLeft.scala b/tests/neg/indentLeft.scala index c4a260583de2..7e1cf8041bc7 100644 --- a/tests/neg/indentLeft.scala +++ b/tests/neg/indentLeft.scala @@ -1,10 +1,11 @@ //> using options -Xfatal-warnings +// nopos-error: No warnings can be incurred under -Werror. object Test { if (true) { println("hi") - println("!") // error: too far to the left + println("!") // warn: too far to the left } // error: too far to the left \ No newline at end of file diff --git a/tests/neg/indentRight.scala b/tests/neg/indentRight.scala index 8eb9deb23389..6c43651d67e6 100644 --- a/tests/neg/indentRight.scala +++ b/tests/neg/indentRight.scala @@ -1,19 +1,19 @@ //> using options -no-indent -Xfatal-warnings trait A - case class B() extends A // error: Line is indented too far to the right - case object C extends A // error: Line is indented too far to the right + case class B() extends A // warn: Line is indented too far to the right + case object C extends A // warn: Line is indented too far to the right object Test { if (true) println("ho") - println("hu") // error: Line is indented too far to the right + println("hu") // warn: Line is indented too far to the right if (true) { println("ho") } - println("hu") // error: Line is indented too far to the right + println("hu") // warn: Line is indented too far to the right while (true) () @@ -24,8 +24,8 @@ object Test { } trait A - case class B() extends A // error: Line is indented too far to the right - case object C extends A // error: Line is indented too far to the right + case class B() extends A // warn: Line is indented too far to the right + case object C extends A // warn: Line is indented too far to the right if (true) // OK println("hi") @@ -33,4 +33,4 @@ object Test { println("!") // error: expected a toplevel definition } - +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/infix.check b/tests/neg/infix.check new file mode 100644 index 000000000000..7c7c87005291 --- /dev/null +++ b/tests/neg/infix.check @@ -0,0 +1,30 @@ +-- Error: tests/neg/infix.scala:26:4 ----------------------------------------------------------------------------------- +26 | c mop 2 // error: should not be used as infix operator + | ^^^ + | Alphanumeric method mop is not declared infix; it should not be used as infix operator. + | Instead, use method syntax .mop(...) or backticked identifier `mop`. + | The latter can be rewritten automatically under -rewrite -source future-migration. +-- Error: tests/neg/infix.scala:27:4 ----------------------------------------------------------------------------------- +27 | c meth 2 // error: should not be used as infix operator + | ^^^^ + | Alphanumeric method meth is not declared infix; it should not be used as infix operator. + | Instead, use method syntax .meth(...) or backticked identifier `meth`. + | The latter can be rewritten automatically under -rewrite -source future-migration. +-- Error: tests/neg/infix.scala:45:14 ---------------------------------------------------------------------------------- +45 | val x1: Int Map String = ??? // error + | ^^^ + | Alphanumeric type Map is not declared infix; it should not be used as infix operator. + | Instead, use prefix syntax Map[...] or backticked identifier `Map`. + | The latter can be rewritten automatically under -rewrite -source future-migration. +-- Error: tests/neg/infix.scala:47:14 ---------------------------------------------------------------------------------- +47 | val x3: Int AndC String = ??? // error + | ^^^^ + | Alphanumeric type AndC is not declared infix; it should not be used as infix operator. + | Instead, use prefix syntax AndC[...] or backticked identifier `AndC`. + | The latter can be rewritten automatically under -rewrite -source future-migration. +-- Error: tests/neg/infix.scala:61:8 ----------------------------------------------------------------------------------- +61 | val _ Pair _ = p // error + | ^^^^ + | Alphanumeric extractor Pair is not declared infix; it should not be used as infix operator. + | Instead, use prefix syntax Pair(...) or backticked identifier `Pair`. + | The latter can be rewritten automatically under -rewrite -source future-migration. diff --git a/tests/neg/infix.scala b/tests/neg/infix.scala index aefdd5c40d47..dda638c829f9 100644 --- a/tests/neg/infix.scala +++ b/tests/neg/infix.scala @@ -1,4 +1,4 @@ -//> using options -source future -deprecation -Xfatal-warnings +//> using options -source future -deprecation // Compile with -strict -Xfatal-warnings -deprecation class C: @@ -67,4 +67,4 @@ def test() = { val _ Q _ = q // OK -} +} \ No newline at end of file diff --git a/tests/neg/missing-targetName.scala b/tests/neg/missing-targetName.scala index b5403ac7cb19..8c799c4a19dd 100644 --- a/tests/neg/missing-targetName.scala +++ b/tests/neg/missing-targetName.scala @@ -5,7 +5,8 @@ import scala.annotation.targetName class & { // error @targetName("op") def *(x: Int): Int = ??? // OK - def / (x: Int): Int // error - val frozen_& : Int = ??? // error - object some_??? // error + def / (x: Int): Int // warn + val frozen_& : Int = ??? // warn + object some_??? // warn } +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/pureStatement.scala b/tests/neg/pureStatement.scala index 4d2ea1d49b08..72d39ce2ecf6 100644 --- a/tests/neg/pureStatement.scala +++ b/tests/neg/pureStatement.scala @@ -3,16 +3,16 @@ class IOCapability object Test { - "" // error: pure expression does nothing in statement position + "" // warn: pure expression does nothing in statement position locally { - "" // error: pure expression does nothing in statement position + "" // warn: pure expression does nothing in statement position println("") - 42 // error: pure expression does nothing in statement position + 42 // warn: pure expression does nothing in statement position - ((x: Int) => println("hi")) // error: pure expression does nothing in statement position + ((x: Int) => println("hi")) // warn: pure expression does nothing in statement position () } @@ -24,7 +24,7 @@ object Test { implicit val cap: IOCapability = new IOCapability - 2 // error: pure expression does nothing in statement position + 2 // warn: pure expression does nothing in statement position doSideEffects(1) // error: pure expression does nothing in statement position @@ -32,3 +32,4 @@ object Test { broken.foo // no extra error, and no pure expression warning broken.foo() // same } +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/structural-2.scala b/tests/neg/structural-2.scala index 3613d6073e34..85fac55c08a5 100644 --- a/tests/neg/structural-2.scala +++ b/tests/neg/structural-2.scala @@ -69,7 +69,8 @@ object Test { package p6 { class Refinements { - val y: { val x: T; type T } // error: deprecated warning: illegal forward reference in refinement; now illegal + val y: { val x: T; type T } // warn: deprecated warning: illegal forward reference in refinement; now illegal } } +// nopos-error: No warnings can be incurred under -Werror. diff --git a/tests/neg/unchecked-patterns.scala b/tests/neg/unchecked-patterns.scala index db304a2f1875..7e6c4de76a50 100644 --- a/tests/neg/unchecked-patterns.scala +++ b/tests/neg/unchecked-patterns.scala @@ -5,23 +5,24 @@ object Test { val (y1: Some[Int]) = Some(1): Option[Int] @unchecked // OK val y2: Some[Int] @unchecked = Some(1): Option[Int] // error - val x :: xs = List(1, 2, 3) // error - val (1, c) = (1, 2) // error - val 1 *: cs = 1 *: Tuple() // error + val x :: xs = List(1, 2, 3) // warn + val (1, c) = (1, 2) // warn + val 1 *: cs = 1 *: Tuple() // warn - val (_: Int | _: AnyRef) = ??? : AnyRef // error + val (_: Int | _: AnyRef) = ??? : AnyRef // warn - val 1 = 2 // error + val 1 = 2 // warn object Positive { def unapply(i: Int): Option[Int] = Some(i).filter(_ > 0) } object Always1 { def unapply(i: Int): Some[Int] = Some(i) } object Pair { def unapply(t: (Int, Int)): t.type = t } object Triple { def unapply(t: (Int, Int, Int)): (Int, Int, Int) = t } - val Positive(p) = 5 // error - val Some(s1) = Option(1) // error + val Positive(p) = 5 // warn + val Some(s1) = Option(1) // warn val Some(s2) = Some(1) // OK val Always1(p1) = 5 // OK val Pair(t1, t2) = (5, 5) // OK val Triple(u1, u2, u3) = (5, 5, 5) // OK -} \ No newline at end of file +} +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file