diff --git a/compiler/test/dotty/tools/vulpix/ParallelTesting.scala b/compiler/test/dotty/tools/vulpix/ParallelTesting.scala index e93a0435987b..174fbb60ef34 100644 --- a/compiler/test/dotty/tools/vulpix/ParallelTesting.scala +++ b/compiler/test/dotty/tools/vulpix/ParallelTesting.scala @@ -776,7 +776,7 @@ trait ParallelTesting extends RunnerOrchestration { self => end maybeFailureMessage def getWarnMapAndExpectedCount(files: Seq[JFile]): (HashMap[String, Integer], Int) = - val comment = raw"//( *)warn".r + val comment = raw"//( *)(nopos-)?warn".r val map = new HashMap[String, Integer]() var count = 0 def bump(key: String): Unit = @@ -787,8 +787,11 @@ trait ParallelTesting extends RunnerOrchestration { self => files.filter(isSourceFile).foreach { file => Using(Source.fromFile(file, StandardCharsets.UTF_8.name)) { source => source.getLines.zipWithIndex.foreach { case (line, lineNbr) => - comment.findAllMatchIn(line).foreach { _ => - bump(s"${file.getPath}:${lineNbr+1}") + comment.findAllMatchIn(line).foreach { m => + m.group(2) match + case "nopos-" => + bump("nopos") + case _ => bump(s"${file.getPath}:${lineNbr+1}") } } }.get @@ -809,7 +812,7 @@ trait ParallelTesting extends RunnerOrchestration { self => val key = s"${relativize(srcpos.source.file.toString())}:${srcpos.line + 1}" if !seenAt(key) then unexpected += key else - unpositioned += relativize(srcpos.source.file.toString()) + if(!seenAt("nopos")) unpositioned += relativize(srcpos.source.file.toString()) reporterWarnings.foreach(sawDiagnostic) diff --git a/tests/init-global/neg/context-sensitivity.check b/tests/init-global/neg/context-sensitivity.check new file mode 100644 index 000000000000..e5eaad3d2a58 --- /dev/null +++ b/tests/init-global/neg/context-sensitivity.check @@ -0,0 +1,11 @@ +-- Warning: tests/init-global/neg/context-sensitivity.scala:9:21 ------------------------------------------------------- +9 | def foo(): Int = A.m + | ^^^ + | Access uninitialized field value m. Calling trace: + | ├── object A: [ context-sensitivity.scala:14 ] + | │ ^ + | ├── val m: Int = box1.value.foo() [ context-sensitivity.scala:17 ] + | │ ^^^^^^^^^^^^^^^^ + | └── def foo(): Int = A.m [ context-sensitivity.scala:9 ] + | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/context-sensitivity.scala b/tests/init-global/neg/context-sensitivity.scala old mode 100755 new mode 100644 index 626fd41bb43f..7b7477df5773 --- a/tests/init-global/neg/context-sensitivity.scala +++ b/tests/init-global/neg/context-sensitivity.scala @@ -6,7 +6,7 @@ class C(var x: Int) extends Foo { } class D(var y: Int) extends Foo { - def foo(): Int = A.m // error + def foo(): Int = A.m } class Box(var value: Foo) @@ -15,3 +15,5 @@ object A: val box1: Box = new Box(new C(5)) val box2: Box = new Box(new D(10)) val m: Int = box1.value.foo() + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-cycle1.check b/tests/init-global/neg/global-cycle1.check index c68b8b51a419..81859776b06f 100644 --- a/tests/init-global/neg/global-cycle1.check +++ b/tests/init-global/neg/global-cycle1.check @@ -1,20 +1,21 @@ --- Error: tests/init-global/neg/global-cycle1.scala:1:7 ---------------------------------------------------------------- -1 |object A { // error +-- Warning: tests/init-global/neg/global-cycle1.scala:1:7 -------------------------------------------------------------- +1 |object A { | ^ | Cyclic initialization: object A -> object B -> object A. Calling trace: - | ├── object A { // error [ global-cycle1.scala:1 ] + | ├── object A { [ global-cycle1.scala:1 ] | │ ^ | ├── val a: Int = B.b [ global-cycle1.scala:2 ] | │ ^ | ├── object B { [ global-cycle1.scala:5 ] | │ ^ - | └── val b: Int = A.a // error [ global-cycle1.scala:6 ] + | └── val b: Int = A.a [ global-cycle1.scala:6 ] | ^ --- Error: tests/init-global/neg/global-cycle1.scala:6:17 --------------------------------------------------------------- -6 | val b: Int = A.a // error +-- Warning: tests/init-global/neg/global-cycle1.scala:6:17 ------------------------------------------------------------- +6 | val b: Int = A.a | ^^^ | Access uninitialized field value a. Calling trace: | ├── object B { [ global-cycle1.scala:5 ] | │ ^ - | └── val b: Int = A.a // error [ global-cycle1.scala:6 ] + | └── val b: Int = A.a [ global-cycle1.scala:6 ] | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-cycle1.scala b/tests/init-global/neg/global-cycle1.scala index 592f5a652dc8..992d3eacc6f5 100644 --- a/tests/init-global/neg/global-cycle1.scala +++ b/tests/init-global/neg/global-cycle1.scala @@ -1,10 +1,12 @@ -object A { // error +object A { val a: Int = B.b } object B { - val b: Int = A.a // error + val b: Int = A.a } @main def Test = print(A.a) + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-cycle14.check b/tests/init-global/neg/global-cycle14.check new file mode 100644 index 000000000000..d976653c05f0 --- /dev/null +++ b/tests/init-global/neg/global-cycle14.check @@ -0,0 +1,21 @@ +-- Warning: tests/init-global/neg/global-cycle14.scala:8:7 ------------------------------------------------------------- +8 |object A { + | ^ + | Cyclic initialization: object A -> object B -> object A. Calling trace: + | ├── object A { [ global-cycle14.scala:8 ] + | │ ^ + | ├── val n: Int = B.m [ global-cycle14.scala:9 ] + | │ ^ + | ├── object B { [ global-cycle14.scala:12 ] + | │ ^ + | └── val m: Int = A.n [ global-cycle14.scala:13 ] + | ^ +-- Warning: tests/init-global/neg/global-cycle14.scala:13:17 ----------------------------------------------------------- +13 | val m: Int = A.n + | ^^^ + | Access uninitialized field value n. Calling trace: + | ├── object B { [ global-cycle14.scala:12 ] + | │ ^ + | └── val m: Int = A.n [ global-cycle14.scala:13 ] + | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-cycle14.scala b/tests/init-global/neg/global-cycle14.scala index bcacbebb74fa..35a3019a2a64 100644 --- a/tests/init-global/neg/global-cycle14.scala +++ b/tests/init-global/neg/global-cycle14.scala @@ -5,10 +5,12 @@ object O { val d = Data(3) } -object A { // error +object A { val n: Int = B.m } object B { - val m: Int = A.n // error + val m: Int = A.n } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-cycle2.check b/tests/init-global/neg/global-cycle2.check new file mode 100644 index 000000000000..e01fb2f15aea --- /dev/null +++ b/tests/init-global/neg/global-cycle2.check @@ -0,0 +1,11 @@ +-- Warning: tests/init-global/neg/global-cycle2.scala:6:21 ------------------------------------------------------------- +6 | def foo(): Int = A.a * 2 + | ^^^ + | Access uninitialized field value a. Calling trace: + | ├── object A { [ global-cycle2.scala:1 ] + | │ ^ + | ├── val a: Int = B.foo() [ global-cycle2.scala:2 ] + | │ ^^^^^^^ + | └── def foo(): Int = A.a * 2 [ global-cycle2.scala:6 ] + | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-cycle2.scala b/tests/init-global/neg/global-cycle2.scala index d86fe09fb0fa..f3bd33a1c179 100644 --- a/tests/init-global/neg/global-cycle2.scala +++ b/tests/init-global/neg/global-cycle2.scala @@ -3,5 +3,7 @@ object A { } object B { - def foo(): Int = A.a * 2 // error + def foo(): Int = A.a * 2 } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-cycle3.check b/tests/init-global/neg/global-cycle3.check new file mode 100644 index 000000000000..1b3ccd8dd857 --- /dev/null +++ b/tests/init-global/neg/global-cycle3.check @@ -0,0 +1,11 @@ +-- Warning: tests/init-global/neg/global-cycle3.scala:2:21 ------------------------------------------------------------- +2 | def foo(): Int = B.a + 10 + | ^^^ + | Access uninitialized field value a. Calling trace: + | ├── object B { [ global-cycle3.scala:5 ] + | │ ^ + | ├── val a: Int = A(4).foo() [ global-cycle3.scala:6 ] + | │ ^^^^^^^^^^ + | └── def foo(): Int = B.a + 10 [ global-cycle3.scala:2 ] + | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-cycle3.scala b/tests/init-global/neg/global-cycle3.scala index 405e007b044a..5e97ba59c735 100644 --- a/tests/init-global/neg/global-cycle3.scala +++ b/tests/init-global/neg/global-cycle3.scala @@ -1,7 +1,9 @@ class A(x: Int) { - def foo(): Int = B.a + 10 // error + def foo(): Int = B.a + 10 } object B { val a: Int = A(4).foo() } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-cycle4.check b/tests/init-global/neg/global-cycle4.check new file mode 100644 index 000000000000..68a4dcae4b77 --- /dev/null +++ b/tests/init-global/neg/global-cycle4.check @@ -0,0 +1,11 @@ +-- Warning: tests/init-global/neg/global-cycle4.scala:10:21 ------------------------------------------------------------ +10 | def foo(): Int = O.a + 10 + | ^^^ + | Access uninitialized field value a. Calling trace: + | ├── object O { [ global-cycle4.scala:17 ] + | │ ^ + | ├── val a: Int = D(5).bar().foo() [ global-cycle4.scala:18 ] + | │ ^^^^^^^^^^^^^^^^ + | └── def foo(): Int = O.a + 10 [ global-cycle4.scala:10 ] + | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-cycle4.scala b/tests/init-global/neg/global-cycle4.scala index 8c1627afeae4..789d682da3be 100644 --- a/tests/init-global/neg/global-cycle4.scala +++ b/tests/init-global/neg/global-cycle4.scala @@ -7,7 +7,7 @@ class B extends A { } class C extends A { - def foo(): Int = O.a + 10 // error + def foo(): Int = O.a + 10 } class D(x: Int) { @@ -17,3 +17,5 @@ class D(x: Int) { object O { val a: Int = D(5).bar().foo() } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-cycle5.check b/tests/init-global/neg/global-cycle5.check new file mode 100644 index 000000000000..c1d21cb77a45 --- /dev/null +++ b/tests/init-global/neg/global-cycle5.check @@ -0,0 +1,10 @@ +-- Warning: tests/init-global/neg/global-cycle5.scala:10:17 ------------------------------------------------------------ +10 | val b: Int = A.a.foo() + | ^^^ + |Reading mutable state of object A during initialization of object B. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object B { [ global-cycle5.scala:9 ] + |│ ^ + |└── val b: Int = A.a.foo() [ global-cycle5.scala:10 ] + | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-cycle5.scala b/tests/init-global/neg/global-cycle5.scala old mode 100755 new mode 100644 index 1ba3435d3830..281ea9b879d1 --- a/tests/init-global/neg/global-cycle5.scala +++ b/tests/init-global/neg/global-cycle5.scala @@ -7,7 +7,7 @@ object A { } object B { - val b: Int = A.a.foo() // error + val b: Int = A.a.foo() } class Y extends X { @@ -20,4 +20,5 @@ object C { def main = { A.a = new Y(); C -} \ No newline at end of file +} +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-cycle6.check b/tests/init-global/neg/global-cycle6.check new file mode 100644 index 000000000000..47a1c1543773 --- /dev/null +++ b/tests/init-global/neg/global-cycle6.check @@ -0,0 +1,29 @@ +-- Warning: tests/init-global/neg/global-cycle6.scala:1:7 -------------------------------------------------------------- +1 |object A { + | ^ + | Cyclic initialization: object A -> object B -> object A. Calling trace: + | ├── object A { [ global-cycle6.scala:1 ] + | │ ^ + | ├── val n: Int = B.m [ global-cycle6.scala:2 ] + | │ ^ + | ├── object B { [ global-cycle6.scala:8 ] + | │ ^ + | ├── val a = new A.Inner [ global-cycle6.scala:9 ] + | │ ^^^^^^^^^^^ + | ├── class Inner { [ global-cycle6.scala:3 ] + | │ ^ + | └── println(n) [ global-cycle6.scala:4 ] + | ^ +-- Warning: tests/init-global/neg/global-cycle6.scala:4:12 ------------------------------------------------------------- +4 | println(n) + | ^ + | Access uninitialized field value n. Calling trace: + | ├── object B { [ global-cycle6.scala:8 ] + | │ ^ + | ├── val a = new A.Inner [ global-cycle6.scala:9 ] + | │ ^^^^^^^^^^^ + | ├── class Inner { [ global-cycle6.scala:3 ] + | │ ^ + | └── println(n) [ global-cycle6.scala:4 ] + | ^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-cycle6.scala b/tests/init-global/neg/global-cycle6.scala index 36e3ab0b6a94..88adc536b307 100644 --- a/tests/init-global/neg/global-cycle6.scala +++ b/tests/init-global/neg/global-cycle6.scala @@ -1,7 +1,7 @@ -object A { // error +object A { val n: Int = B.m class Inner { - println(n) // error + println(n) } } @@ -22,4 +22,5 @@ object O { val a = new A.Inner val m: Int = 10 } -} \ No newline at end of file +} +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-cycle7.check b/tests/init-global/neg/global-cycle7.check new file mode 100644 index 000000000000..96a63b77b73e --- /dev/null +++ b/tests/init-global/neg/global-cycle7.check @@ -0,0 +1,21 @@ +-- Warning: tests/init-global/neg/global-cycle7.scala:1:7 -------------------------------------------------------------- +1 |object A { + | ^ + | Cyclic initialization: object A -> object B -> object A. Calling trace: + | ├── object A { [ global-cycle7.scala:1 ] + | │ ^ + | ├── val n: Int = B.m [ global-cycle7.scala:2 ] + | │ ^ + | ├── object B { [ global-cycle7.scala:5 ] + | │ ^ + | └── val m: Int = A.n [ global-cycle7.scala:6 ] + | ^ +-- Warning: tests/init-global/neg/global-cycle7.scala:6:17 ------------------------------------------------------------- +6 | val m: Int = A.n + | ^^^ + | Access uninitialized field value n. Calling trace: + | ├── object B { [ global-cycle7.scala:5 ] + | │ ^ + | └── val m: Int = A.n [ global-cycle7.scala:6 ] + | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-cycle7.scala b/tests/init-global/neg/global-cycle7.scala index aea75726fbf7..b8084984aeec 100644 --- a/tests/init-global/neg/global-cycle7.scala +++ b/tests/init-global/neg/global-cycle7.scala @@ -1,9 +1,9 @@ -object A { // error +object A { val n: Int = B.m } object B { - val m: Int = A.n // error + val m: Int = A.n } abstract class TokensCommon { @@ -16,3 +16,5 @@ object JavaTokens extends TokensCommon { final def maxToken: Int = DOUBLE final val DOUBLE = 188 } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-cycle8.check b/tests/init-global/neg/global-cycle8.check new file mode 100644 index 000000000000..6dc544fe8e7c --- /dev/null +++ b/tests/init-global/neg/global-cycle8.check @@ -0,0 +1,17 @@ +-- Warning: tests/init-global/neg/global-cycle8.scala:9:7 -------------------------------------------------------------- +9 |object O { + | ^ + | Cyclic initialization: object O -> object P -> object O. Calling trace: + | ├── object O { [ global-cycle8.scala:9 ] + | │ ^ + | ├── println(P.m) [ global-cycle8.scala:11 ] + | │ ^ + | ├── object P { [ global-cycle8.scala:14 ] + | │ ^ + | ├── val m = Q.bar(new B) [ global-cycle8.scala:15 ] + | │ ^^^^^^^^^^^^ + | ├── def bar(b: B) = b.a.foo() [ global-cycle8.scala:19 ] + | │ ^^^^^^^^^ + | └── def foo() = println(O.n) [ global-cycle8.scala:2 ] + | ^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-cycle8.scala b/tests/init-global/neg/global-cycle8.scala index 344dc3241395..91290da30353 100644 --- a/tests/init-global/neg/global-cycle8.scala +++ b/tests/init-global/neg/global-cycle8.scala @@ -6,7 +6,7 @@ class B { val a = new A } -object O { // error +object O { val n: Int = 10 println(P.m) } @@ -18,3 +18,5 @@ object P { object Q { def bar(b: B) = b.a.foo() } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-irrelevance1.check b/tests/init-global/neg/global-irrelevance1.check new file mode 100644 index 000000000000..799d80ec9623 --- /dev/null +++ b/tests/init-global/neg/global-irrelevance1.check @@ -0,0 +1,10 @@ +-- Warning: tests/init-global/neg/global-irrelevance1.scala:5:12 ------------------------------------------------------- +5 | var y = A.x * 2 + | ^^^ + |Reading mutable state of object A during initialization of object B. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object B: [ global-irrelevance1.scala:4 ] + |│ ^ + |└── var y = A.x * 2 [ global-irrelevance1.scala:5 ] + | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-irrelevance1.scala b/tests/init-global/neg/global-irrelevance1.scala index 903d3b14ae18..2eb5511001e2 100644 --- a/tests/init-global/neg/global-irrelevance1.scala +++ b/tests/init-global/neg/global-irrelevance1.scala @@ -2,4 +2,5 @@ object A: var x = 6 object B: - var y = A.x * 2 // error \ No newline at end of file + var y = A.x * 2 +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-irrelevance2.check b/tests/init-global/neg/global-irrelevance2.check new file mode 100644 index 000000000000..56263b936308 --- /dev/null +++ b/tests/init-global/neg/global-irrelevance2.check @@ -0,0 +1,14 @@ +-- Warning: tests/init-global/neg/global-irrelevance2.scala:5:6 -------------------------------------------------------- +5 | A.x = b * 2 + | ^^^^^^^^^^^^ + | Mutating object A during initialization of object B. + | Mutating other static objects during the initialization of one static object is forbidden. Calling trace: + | ├── object B: [ global-irrelevance2.scala:7 ] + | │ ^ + | ├── new B(10) [ global-irrelevance2.scala:8 ] + | │ ^^^^^^^^^ + | ├── class B(b: Int): [ global-irrelevance2.scala:4 ] + | │ ^ + | └── A.x = b * 2 [ global-irrelevance2.scala:5 ] + | ^^^^^^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-irrelevance2.scala b/tests/init-global/neg/global-irrelevance2.scala index 66b06677b689..8804eed6cc52 100644 --- a/tests/init-global/neg/global-irrelevance2.scala +++ b/tests/init-global/neg/global-irrelevance2.scala @@ -2,7 +2,9 @@ object A: var x = 6 class B(b: Int): - A.x = b * 2 // error + A.x = b * 2 object B: new B(10) + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-irrelevance3.check b/tests/init-global/neg/global-irrelevance3.check new file mode 100644 index 000000000000..7d7f9dbfb1fc --- /dev/null +++ b/tests/init-global/neg/global-irrelevance3.check @@ -0,0 +1,12 @@ +-- Warning: tests/init-global/neg/global-irrelevance3.scala:9:13 ------------------------------------------------------- +9 | (() => x) + | ^ + |Reading mutable state of object A during initialization of object B. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object B: [ global-irrelevance3.scala:13 ] + |│ ^ + |├── var y = A.p.g() [ global-irrelevance3.scala:14 ] + |│ ^^^^^^^ + |└── (() => x) [ global-irrelevance3.scala:9 ] + | ^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-irrelevance3.scala b/tests/init-global/neg/global-irrelevance3.scala index 2f36d65d917e..4b53c0335314 100644 --- a/tests/init-global/neg/global-irrelevance3.scala +++ b/tests/init-global/neg/global-irrelevance3.scala @@ -6,9 +6,11 @@ object A: var x = 6 new Pair( y => x = y, - (() => x) // error + (() => x) ) object B: var y = A.p.g() + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-irrelevance4.check b/tests/init-global/neg/global-irrelevance4.check new file mode 100644 index 000000000000..ebabde96294d --- /dev/null +++ b/tests/init-global/neg/global-irrelevance4.check @@ -0,0 +1,12 @@ +-- Warning: tests/init-global/neg/global-irrelevance4.scala:8:9 -------------------------------------------------------- +8 | (y => x = y), + | ^^^^^^^^^^ + | Mutating object A during initialization of object B. + | Mutating other static objects during the initialization of one static object is forbidden. Calling trace: + | ├── object B: [ global-irrelevance4.scala:12 ] + | │ ^ + | ├── A.p.f(10) [ global-irrelevance4.scala:13 ] + | │ ^^^^^^^^^ + | └── (y => x = y), [ global-irrelevance4.scala:8 ] + | ^^^^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-irrelevance4.scala b/tests/init-global/neg/global-irrelevance4.scala index 7a2a778814b2..caf7f2bb6466 100644 --- a/tests/init-global/neg/global-irrelevance4.scala +++ b/tests/init-global/neg/global-irrelevance4.scala @@ -5,9 +5,11 @@ object A: def foo(): Pair = var x = 6 new Pair( - (y => x = y), // error + (y => x = y), () => x ) object B: A.p.f(10) + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-irrelevance5.check b/tests/init-global/neg/global-irrelevance5.check new file mode 100644 index 000000000000..7d472621821c --- /dev/null +++ b/tests/init-global/neg/global-irrelevance5.check @@ -0,0 +1,10 @@ +-- Warning: tests/init-global/neg/global-irrelevance5.scala:6:17 ------------------------------------------------------- +6 | var y = A.array(0) * 2 + | ^^^^^^^^^^ + |Reading mutable state of object A during initialization of object B. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object B: [ global-irrelevance5.scala:5 ] + |│ ^ + |└── var y = A.array(0) * 2 [ global-irrelevance5.scala:6 ] + | ^^^^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-irrelevance5.scala b/tests/init-global/neg/global-irrelevance5.scala index fd5bde3032aa..a1cff0aeb802 100644 --- a/tests/init-global/neg/global-irrelevance5.scala +++ b/tests/init-global/neg/global-irrelevance5.scala @@ -3,4 +3,6 @@ object A: array(0) = 10 object B: - var y = A.array(0) * 2 // error + var y = A.array(0) * 2 + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-irrelevance6.check b/tests/init-global/neg/global-irrelevance6.check new file mode 100644 index 000000000000..52df6bd253e2 --- /dev/null +++ b/tests/init-global/neg/global-irrelevance6.check @@ -0,0 +1,10 @@ +-- Warning: tests/init-global/neg/global-irrelevance6.scala:9:17 ------------------------------------------------------- +9 | var y = A.array(0).foo() * 2 + | ^^^^^^^^^^ + |Reading mutable state of object A during initialization of object B. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object B: [ global-irrelevance6.scala:8 ] + |│ ^ + |└── var y = A.array(0).foo() * 2 [ global-irrelevance6.scala:9 ] + | ^^^^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-irrelevance6.scala b/tests/init-global/neg/global-irrelevance6.scala index 78699b6988b6..a16849a81934 100644 --- a/tests/init-global/neg/global-irrelevance6.scala +++ b/tests/init-global/neg/global-irrelevance6.scala @@ -6,4 +6,6 @@ object A: val n = array(0).foo() // ok, no crash object B: - var y = A.array(0).foo() * 2 // error + var y = A.array(0).foo() * 2 + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-irrelevance7.check b/tests/init-global/neg/global-irrelevance7.check new file mode 100644 index 000000000000..3178c21cbca5 --- /dev/null +++ b/tests/init-global/neg/global-irrelevance7.check @@ -0,0 +1,10 @@ +-- Warning: tests/init-global/neg/global-irrelevance7.scala:10:17 ------------------------------------------------------ +10 | var y = A.array(0).foo() * 2 + | ^^^^^^^^^^ + |Reading mutable state of object A during initialization of object B. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object B: [ global-irrelevance7.scala:9 ] + |│ ^ + |└── var y = A.array(0).foo() * 2 [ global-irrelevance7.scala:10 ] + | ^^^^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-irrelevance7.scala b/tests/init-global/neg/global-irrelevance7.scala index 2c860cbc4259..f679c9cc60b7 100644 --- a/tests/init-global/neg/global-irrelevance7.scala +++ b/tests/init-global/neg/global-irrelevance7.scala @@ -7,4 +7,6 @@ object A: val n = array(0).foo() // ok object B: - var y = A.array(0).foo() * 2 // error + var y = A.array(0).foo() * 2 + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-list.check b/tests/init-global/neg/global-list.check new file mode 100644 index 000000000000..4d4bc3d7e8ca --- /dev/null +++ b/tests/init-global/neg/global-list.check @@ -0,0 +1,37 @@ +-- Warning: tests/init-global/neg/global-list.scala:3:7 ---------------------------------------------------------------- +3 |object O: + | ^ + | Cyclic initialization: object O -> object Foo -> object O. Calling trace: + | ├── object O: [ global-list.scala:3 ] + | │ ^ + | ├── val a = Foo("Apple") [ global-list.scala:4 ] + | │ ^^^ + | ├── object Foo: [ global-list.scala:8 ] + | │ ^ + | └── val all: List[Foo] = List(O.a, O.b, O.c) [ global-list.scala:9 ] + | ^ +-- Warning: tests/init-global/neg/global-list.scala:9:30 --------------------------------------------------------------- +9 | val all: List[Foo] = List(O.a, O.b, O.c) + | ^^^ + | Access uninitialized field value a. Calling trace: + | ├── object Foo: [ global-list.scala:8 ] + | │ ^ + | └── val all: List[Foo] = List(O.a, O.b, O.c) [ global-list.scala:9 ] + | ^^^ +-- Warning: tests/init-global/neg/global-list.scala:9:35 --------------------------------------------------------------- +9 | val all: List[Foo] = List(O.a, O.b, O.c) + | ^^^ + | Access uninitialized field value b. Calling trace: + | ├── object Foo: [ global-list.scala:8 ] + | │ ^ + | └── val all: List[Foo] = List(O.a, O.b, O.c) [ global-list.scala:9 ] + | ^^^ +-- Warning: tests/init-global/neg/global-list.scala:9:40 --------------------------------------------------------------- +9 | val all: List[Foo] = List(O.a, O.b, O.c) + | ^^^ + | Access uninitialized field value c. Calling trace: + | ├── object Foo: [ global-list.scala:8 ] + | │ ^ + | └── val all: List[Foo] = List(O.a, O.b, O.c) [ global-list.scala:9 ] + | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-list.scala b/tests/init-global/neg/global-list.scala old mode 100755 new mode 100644 index cdef6dbf3bbe..e9fed153f78f --- a/tests/init-global/neg/global-list.scala +++ b/tests/init-global/neg/global-list.scala @@ -1,9 +1,10 @@ case class Foo(name: String) -object O: // error +object O: val a = Foo("Apple") val b = Foo("Banana") val c = Foo("Cherry") object Foo: - val all: List[Foo] = List(O.a, O.b, O.c) // error // error // error \ No newline at end of file + val all: List[Foo] = List(O.a, O.b, O.c) +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-local-var.check b/tests/init-global/neg/global-local-var.check new file mode 100644 index 000000000000..bbedc06dce3d --- /dev/null +++ b/tests/init-global/neg/global-local-var.check @@ -0,0 +1,13 @@ +-- Warning: tests/init-global/neg/global-local-var.scala:10:6 ---------------------------------------------------------- +10 | B.a + 10 + sum + | ^^^ + | Access uninitialized field value a. Calling trace: + | ├── object B { [ global-local-var.scala:14 ] + | │ ^ + | ├── val a: Int = A(4).foo() [ global-local-var.scala:15 ] + | │ ^^^^^^^^^^ + | ├── def foo(): Int = { [ global-local-var.scala:2 ] + | │ ^ + | └── B.a + 10 + sum [ global-local-var.scala:10 ] + | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-local-var.scala b/tests/init-global/neg/global-local-var.scala index 6965a42bd37f..9db071de5ae8 100644 --- a/tests/init-global/neg/global-local-var.scala +++ b/tests/init-global/neg/global-local-var.scala @@ -7,10 +7,12 @@ class A(x: Int) { sum += i i += 1 - B.a + 10 + sum // error + B.a + 10 + sum } } object B { val a: Int = A(4).foo() } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/global-region1.check b/tests/init-global/neg/global-region1.check new file mode 100644 index 000000000000..b3b7e2a3b7ca --- /dev/null +++ b/tests/init-global/neg/global-region1.check @@ -0,0 +1,11 @@ +-- Warning: tests/init-global/neg/global-region1.scala:3:51 ------------------------------------------------------------ +3 |class D(var y: Int) extends B { def foo(): Int = A.m } + | ^^^ + | Access uninitialized field value m. Calling trace: + | ├── object A: [ global-region1.scala:6 ] + | │ ^ + | ├── val m: Int = box1.value.foo() [ global-region1.scala:9 ] + | │ ^^^^^^^^^^^^^^^^ + | └── class D(var y: Int) extends B { def foo(): Int = A.m } [ global-region1.scala:3 ] + | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/global-region1.scala b/tests/init-global/neg/global-region1.scala index 48473717b5b5..f47e10a06424 100644 --- a/tests/init-global/neg/global-region1.scala +++ b/tests/init-global/neg/global-region1.scala @@ -1,9 +1,11 @@ trait B { def foo(): Int } class C(var x: Int) extends B { def foo(): Int = 20 } -class D(var y: Int) extends B { def foo(): Int = A.m } // error +class D(var y: Int) extends B { def foo(): Int = A.m } class Box(var value: B) object A: val box1: Box = new Box(new C(5)) val box2: Box = new Box(new D(10)) val m: Int = box1.value.foo() + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/i11262.check b/tests/init-global/neg/i11262.check new file mode 100644 index 000000000000..643a70838167 --- /dev/null +++ b/tests/init-global/neg/i11262.check @@ -0,0 +1,15 @@ +-- Warning: tests/init-global/neg/i11262.scala:1:7 --------------------------------------------------------------------- +1 |object A { val x: String = B.y } + | ^ + | Cyclic initialization: object A -> object B -> object A. Calling trace: + | ├── object A { val x: String = B.y } [ i11262.scala:1 ] + | │ ^ + | └── object B { val y: String = A.x } [ i11262.scala:2 ] + | ^ +-- Warning: tests/init-global/neg/i11262.scala:2:29 -------------------------------------------------------------------- +2 |object B { val y: String = A.x } + | ^^^ + | Access uninitialized field value x. Calling trace: + | └── object B { val y: String = A.x } [ i11262.scala:2 ] + | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/i11262.scala b/tests/init-global/neg/i11262.scala index c1c01f6aad8c..befc9ca0834d 100644 --- a/tests/init-global/neg/i11262.scala +++ b/tests/init-global/neg/i11262.scala @@ -1,2 +1,4 @@ -object A { val x: String = B.y } // error -object B { val y: String = A.x } // error +object A { val x: String = B.y } +object B { val y: String = A.x } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/i12544b.check b/tests/init-global/neg/i12544b.check new file mode 100644 index 000000000000..7680b62d0b7b --- /dev/null +++ b/tests/init-global/neg/i12544b.check @@ -0,0 +1,21 @@ +-- Warning: tests/init-global/neg/i12544b.scala:5:9 -------------------------------------------------------------------- +5 | object nested: + | ^ + | Cyclic initialization: object nested -> object Enum -> object nested. Calling trace: + | ├── object nested: [ i12544b.scala:5 ] + | │ ^ + | ├── val a: Enum = Case [ i12544b.scala:6 ] + | │ ^^^^ + | ├── object Enum: [ i12544b.scala:4 ] + | │ ^ + | └── val b: Enum = f(nested.a) [ i12544b.scala:8 ] + | ^^^^^^ +-- Warning: tests/init-global/neg/i12544b.scala:8:25 ------------------------------------------------------------------- +8 | val b: Enum = f(nested.a) + | ^^^^^^^^ + | Access uninitialized field value a. Calling trace: + | ├── object Enum: [ i12544b.scala:4 ] + | │ ^ + | └── val b: Enum = f(nested.a) [ i12544b.scala:8 ] + | ^^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/i12544b.scala b/tests/init-global/neg/i12544b.scala index 586b88df04bd..759829e3bd75 100644 --- a/tests/init-global/neg/i12544b.scala +++ b/tests/init-global/neg/i12544b.scala @@ -2,11 +2,13 @@ enum Enum: case Case object Enum: - object nested: // error + object nested: val a: Enum = Case - val b: Enum = f(nested.a) // error + val b: Enum = f(nested.a) def f(e: Enum): Enum = e @main def main(): Unit = println(Enum.b) + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/i9176.check b/tests/init-global/neg/i9176.check new file mode 100644 index 000000000000..a26b66081d75 --- /dev/null +++ b/tests/init-global/neg/i9176.check @@ -0,0 +1,9 @@ +-- Warning: tests/init-global/neg/i9176.scala:2:12 --------------------------------------------------------------------- +2 |case object A extends Foo(B) + | ^ + | Cyclic initialization: object A -> object B -> object A. Calling trace: + | ├── case object A extends Foo(B) [ i9176.scala:2 ] + | │ ^ + | └── case object B extends Foo(A) [ i9176.scala:3 ] + | ^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/i9176.scala b/tests/init-global/neg/i9176.scala index c93a16f2f8b1..fe1c5388029e 100644 --- a/tests/init-global/neg/i9176.scala +++ b/tests/init-global/neg/i9176.scala @@ -1,5 +1,5 @@ class Foo(val opposite: Foo) -case object A extends Foo(B) // error +case object A extends Foo(B) case object B extends Foo(A) object Test { def main(args: Array[String]): Unit = { @@ -7,3 +7,5 @@ object Test { println(B.opposite) } } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/line-spacing.check b/tests/init-global/neg/line-spacing.check index 6fa8801bb07b..66f695d62ca5 100644 --- a/tests/init-global/neg/line-spacing.check +++ b/tests/init-global/neg/line-spacing.check @@ -1,6 +1,6 @@ --- Error: tests/init-global/neg/line-spacing.scala:4:7 ----------------------------------------------------------------- +-- Warning: tests/init-global/neg/line-spacing.scala:4:7 --------------------------------------------------------------- 3 | B -4 | .s.length // error +4 | .s.length | ^ | Access uninitialized field value s. Calling trace: | ├── object B { [ line-spacing.scala:7 ] @@ -9,5 +9,6 @@ | │ ^^^ | ├── def a: Int = [ line-spacing.scala:2 ] | │ ^ - | └── .s.length // error [ line-spacing.scala:4 ] + | └── .s.length [ line-spacing.scala:4 ] | ^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/line-spacing.scala b/tests/init-global/neg/line-spacing.scala index 42474decb53c..7855e82954b8 100644 --- a/tests/init-global/neg/line-spacing.scala +++ b/tests/init-global/neg/line-spacing.scala @@ -1,9 +1,11 @@ object A { def a: Int = B - .s.length // error + .s.length } object B { val s: String = s"${A.a}a" } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/mutable-array.check b/tests/init-global/neg/mutable-array.check new file mode 100644 index 000000000000..9a877be4eff4 --- /dev/null +++ b/tests/init-global/neg/mutable-array.check @@ -0,0 +1,10 @@ +-- Warning: tests/init-global/neg/mutable-array.scala:8:19 ------------------------------------------------------------- +8 | val x: Int = box.value + | ^^^^^^^^^ + |Reading mutable state of object A during initialization of object B. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object B: [ mutable-array.scala:5 ] + |│ ^ + |└── val x: Int = box.value [ mutable-array.scala:8 ] + | ^^^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/mutable-array.scala b/tests/init-global/neg/mutable-array.scala index 3cbc23a5e127..4fea9a813423 100644 --- a/tests/init-global/neg/mutable-array.scala +++ b/tests/init-global/neg/mutable-array.scala @@ -5,4 +5,6 @@ object A: object B: val boxes: Array[A.Box] = Array(A.box) val box: A.Box = boxes(0) - val x: Int = box.value // error + val x: Int = box.value + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/mutable-read1.check b/tests/init-global/neg/mutable-read1.check new file mode 100644 index 000000000000..4e446490d7e5 --- /dev/null +++ b/tests/init-global/neg/mutable-read1.check @@ -0,0 +1,10 @@ +-- Warning: tests/init-global/neg/mutable-read1.scala:10:20 ------------------------------------------------------------ +10 | val n: Int = boxA.value + | ^^^^^^^^^^ + |Reading mutable state of object A during initialization of object B. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object B: [ mutable-read1.scala:6 ] + |│ ^ + |└── val n: Int = boxA.value [ mutable-read1.scala:10 ] + | ^^^^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/mutable-read1.scala b/tests/init-global/neg/mutable-read1.scala old mode 100755 new mode 100644 index 507a8b7d74ad..78aa0e1c4ff3 --- a/tests/init-global/neg/mutable-read1.scala +++ b/tests/init-global/neg/mutable-read1.scala @@ -7,4 +7,5 @@ object B: val boxB: Box = new Box(5) val boxA: Box = A.box val m: Int = boxB.value - val n: Int = boxA.value // error \ No newline at end of file + val n: Int = boxA.value +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/mutable-read2.check b/tests/init-global/neg/mutable-read2.check new file mode 100644 index 000000000000..24c3c0ef3789 --- /dev/null +++ b/tests/init-global/neg/mutable-read2.check @@ -0,0 +1,10 @@ +-- Warning: tests/init-global/neg/mutable-read2.scala:10:19 ------------------------------------------------------------ +10 | val b: Int = box.value + | ^^^^^^^^^ + |Reading mutable state of object A during initialization of object B. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object B: [ mutable-read2.scala:7 ] + |│ ^ + |└── val b: Int = box.value [ mutable-read2.scala:10 ] + | ^^^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/mutable-read2.scala b/tests/init-global/neg/mutable-read2.scala old mode 100755 new mode 100644 index e7653c63d8bb..d223de11d801 --- a/tests/init-global/neg/mutable-read2.scala +++ b/tests/init-global/neg/mutable-read2.scala @@ -7,4 +7,5 @@ object A: object B: val box: A.Box = A.box val a: Int = box.initial - val b: Int = box.value // error \ No newline at end of file + val b: Int = box.value +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/mutable-read3.check b/tests/init-global/neg/mutable-read3.check new file mode 100644 index 000000000000..e0eeb62cee63 --- /dev/null +++ b/tests/init-global/neg/mutable-read3.check @@ -0,0 +1,10 @@ +-- Warning: tests/init-global/neg/mutable-read3.scala:9:19 ------------------------------------------------------------- +9 | val x: Int = box.value + | ^^^^^^^^^ + |Reading mutable state of object A during initialization of object B. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object B: [ mutable-read3.scala:5 ] + |│ ^ + |└── val x: Int = box.value [ mutable-read3.scala:9 ] + | ^^^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/mutable-read3.scala b/tests/init-global/neg/mutable-read3.scala old mode 100755 new mode 100644 index d103e112f372..d5cf067f7609 --- a/tests/init-global/neg/mutable-read3.scala +++ b/tests/init-global/neg/mutable-read3.scala @@ -6,4 +6,5 @@ object B: val boxes: Array[A.Box] = new Array(1) boxes(0) = A.box val box: A.Box = boxes(0) - val x: Int = box.value // error \ No newline at end of file + val x: Int = box.value +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/mutable-read4.check b/tests/init-global/neg/mutable-read4.check new file mode 100644 index 000000000000..81f3a68e0f8b --- /dev/null +++ b/tests/init-global/neg/mutable-read4.check @@ -0,0 +1,10 @@ +-- Warning: tests/init-global/neg/mutable-read4.scala:10:20 ------------------------------------------------------------ +10 | val n: Int = boxA.value + | ^^^^^^^^^^ + |Reading mutable state of object A during initialization of object B. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object B: [ mutable-read4.scala:6 ] + |│ ^ + |└── val n: Int = boxA.value [ mutable-read4.scala:10 ] + | ^^^^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/mutable-read4.scala b/tests/init-global/neg/mutable-read4.scala old mode 100755 new mode 100644 index 507a8b7d74ad..78aa0e1c4ff3 --- a/tests/init-global/neg/mutable-read4.scala +++ b/tests/init-global/neg/mutable-read4.scala @@ -7,4 +7,5 @@ object B: val boxB: Box = new Box(5) val boxA: Box = A.box val m: Int = boxB.value - val n: Int = boxA.value // error \ No newline at end of file + val n: Int = boxA.value +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/mutable-read5.check b/tests/init-global/neg/mutable-read5.check new file mode 100644 index 000000000000..0fa788588d97 --- /dev/null +++ b/tests/init-global/neg/mutable-read5.check @@ -0,0 +1,12 @@ +-- Warning: tests/init-global/neg/mutable-read5.scala:4:38 ------------------------------------------------------------- +4 | def name(s: String): Name = Name(0, chrs.length) + | ^^^^ + |Reading mutable state of object Names during initialization of object StdNames. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object StdNames: [ mutable-read5.scala:6 ] + |│ ^ + |├── val AnyRef: Names.Name = Names.name("AnyRef") [ mutable-read5.scala:7 ] + |│ ^^^^^^^^^^^^^^^^^^^^ + |└── def name(s: String): Name = Name(0, chrs.length) [ mutable-read5.scala:4 ] + | ^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/mutable-read5.scala b/tests/init-global/neg/mutable-read5.scala old mode 100755 new mode 100644 index c166295bf9fa..884f027c970e --- a/tests/init-global/neg/mutable-read5.scala +++ b/tests/init-global/neg/mutable-read5.scala @@ -1,9 +1,10 @@ object Names: class Name(val start: Int, val length: Int) var chrs: Array[Char] = new Array[Char](0x20000) - def name(s: String): Name = Name(0, chrs.length) // error + def name(s: String): Name = Name(0, chrs.length) object StdNames: val AnyRef: Names.Name = Names.name("AnyRef") val Array: Names.Name = Names.name("Array") - val List: Names.Name = Names.name("List") \ No newline at end of file + val List: Names.Name = Names.name("List") +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/mutable-read6.check b/tests/init-global/neg/mutable-read6.check new file mode 100644 index 000000000000..a43e62bafae0 --- /dev/null +++ b/tests/init-global/neg/mutable-read6.check @@ -0,0 +1,12 @@ +-- Warning: tests/init-global/neg/mutable-read6.scala:7:35 ------------------------------------------------------------- +7 | final def source: SourceFile = _source + | ^^^^^^^ + |Reading mutable state of object Contexts during initialization of object Implicits. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object Implicits: [ mutable-read6.scala:12 ] + |│ ^ + |├── val NoMatchingFailure: SearchFailure = SearchFailure(1, NoContext.source) [ mutable-read6.scala:15 ] + |│ ^^^^^^^^^^^^^^^^ + |└── final def source: SourceFile = _source [ mutable-read6.scala:7 ] + | ^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/mutable-read6.scala b/tests/init-global/neg/mutable-read6.scala old mode 100755 new mode 100644 index 8b00eeaf4216..ce6034769f60 --- a/tests/init-global/neg/mutable-read6.scala +++ b/tests/init-global/neg/mutable-read6.scala @@ -4,7 +4,7 @@ object Contexts: val NoContext: Context = new Context class Context: private var _source: SourceFile = null - final def source: SourceFile = _source // error + final def source: SourceFile = _source def setSource(source: SourceFile) = { this._source = source } @@ -12,4 +12,5 @@ object Contexts: object Implicits: import Contexts.* case class SearchFailure(tag: Int, source: SourceFile) - val NoMatchingFailure: SearchFailure = SearchFailure(1, NoContext.source) \ No newline at end of file + val NoMatchingFailure: SearchFailure = SearchFailure(1, NoContext.source) +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/mutable-read7.check b/tests/init-global/neg/mutable-read7.check new file mode 100644 index 000000000000..5198721ebf40 --- /dev/null +++ b/tests/init-global/neg/mutable-read7.check @@ -0,0 +1,16 @@ +-- Warning: tests/init-global/neg/mutable-read7.scala:7:17 ------------------------------------------------------------- +7 | if (Positioned.debug) { + | ^^^^^^^^^^^^^^^^ + |Reading mutable state of object Positioned during initialization of object Trees. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object Trees: [ mutable-read7.scala:11 ] + |│ ^ + |├── val emptyTree = new Tree [ mutable-read7.scala:13 ] + |│ ^^^^^^^^ + |├── class Tree extends Positioned [ mutable-read7.scala:12 ] + |│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + |├── abstract class Positioned: [ mutable-read7.scala:6 ] + |│ ^ + |└── if (Positioned.debug) { [ mutable-read7.scala:7 ] + | ^^^^^^^^^^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/mutable-read7.scala b/tests/init-global/neg/mutable-read7.scala old mode 100755 new mode 100644 index ad9d154d74f5..b840bdc11a5d --- a/tests/init-global/neg/mutable-read7.scala +++ b/tests/init-global/neg/mutable-read7.scala @@ -4,10 +4,11 @@ object Positioned: var nextId: Int = 0 abstract class Positioned: - if (Positioned.debug) { // error + if (Positioned.debug) { println("do debugging") } object Trees: class Tree extends Positioned - val emptyTree = new Tree \ No newline at end of file + val emptyTree = new Tree +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/mutable-read8.check b/tests/init-global/neg/mutable-read8.check new file mode 100644 index 000000000000..030208a605dd --- /dev/null +++ b/tests/init-global/neg/mutable-read8.check @@ -0,0 +1,14 @@ +-- Warning: tests/init-global/neg/mutable-read8.scala:6:12 ------------------------------------------------------------- +6 | if (Stats.monitored) println("record stats") + | ^^^^^^^^^^^^^^^ + |Reading mutable state of object Stats during initialization of object NoCompleter. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object NoCompleter extends LazyType [ mutable-read8.scala:11 ] + |│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + |├── class LazyType extends UncachedGroundType [ mutable-read8.scala:9 ] + |│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + |├── class UncachedGroundType { [ mutable-read8.scala:5 ] + |│ ^ + |└── if (Stats.monitored) println("record stats") [ mutable-read8.scala:6 ] + | ^^^^^^^^^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/mutable-read8.scala b/tests/init-global/neg/mutable-read8.scala old mode 100755 new mode 100644 index e830fa65be73..0e84fe534b26 --- a/tests/init-global/neg/mutable-read8.scala +++ b/tests/init-global/neg/mutable-read8.scala @@ -3,9 +3,10 @@ object Stats { } class UncachedGroundType { - if (Stats.monitored) println("record stats") // error + if (Stats.monitored) println("record stats") } class LazyType extends UncachedGroundType -object NoCompleter extends LazyType \ No newline at end of file +object NoCompleter extends LazyType +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/partial-ordering.check b/tests/init-global/neg/partial-ordering.check new file mode 100644 index 000000000000..d7a71995dd4c --- /dev/null +++ b/tests/init-global/neg/partial-ordering.check @@ -0,0 +1,13 @@ +-- Warning: tests/init-global/neg/partial-ordering.scala:1:7 ----------------------------------------------------------- +1 |object Names: + | ^ + | Cyclic initialization: object Names -> object MethodName -> object Names. Calling trace: + | ├── object Names: [ partial-ordering.scala:1 ] + | │ ^ + | ├── val ctorName: MethodName = MethodName.apply(ctorString) [ partial-ordering.scala:3 ] + | │ ^^^^^^^^^^ + | ├── object MethodName: [ partial-ordering.scala:6 ] + | │ ^ + | └── val ctor: MethodName = new MethodName(Names.ctorString) [ partial-ordering.scala:7 ] + | ^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/partial-ordering.scala b/tests/init-global/neg/partial-ordering.scala old mode 100755 new mode 100644 index 1bc1b251fb72..7cc1333706a9 --- a/tests/init-global/neg/partial-ordering.scala +++ b/tests/init-global/neg/partial-ordering.scala @@ -1,8 +1,9 @@ -object Names: // error +object Names: val ctorString = "" val ctorName: MethodName = MethodName.apply(ctorString) class MethodName(encoded: String) object MethodName: val ctor: MethodName = new MethodName(Names.ctorString) - def apply(name: String): MethodName = new MethodName(name) \ No newline at end of file + def apply(name: String): MethodName = new MethodName(name) +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/patmat-unapplySeq.check b/tests/init-global/neg/patmat-unapplySeq.check index 8f7a1f64631b..8131e730b8b2 100644 --- a/tests/init-global/neg/patmat-unapplySeq.check +++ b/tests/init-global/neg/patmat-unapplySeq.check @@ -1,5 +1,5 @@ --- Error: tests/init-global/neg/patmat-unapplySeq.scala:8:32 ----------------------------------------------------------- -8 | def apply(i: Int): Box = array(i) // error +-- Warning: tests/init-global/neg/patmat-unapplySeq.scala:8:32 --------------------------------------------------------- +8 | def apply(i: Int): Box = array(i) | ^^^^^^^^ |Reading mutable state of object A during initialization of object B. |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: @@ -7,5 +7,6 @@ |│ ^ |├── case A(b) => [ patmat-unapplySeq.scala:17 ] |│ ^^^^ - |└── def apply(i: Int): Box = array(i) // error [ patmat-unapplySeq.scala:8 ] + |└── def apply(i: Int): Box = array(i) [ patmat-unapplySeq.scala:8 ] | ^^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/patmat-unapplySeq.scala b/tests/init-global/neg/patmat-unapplySeq.scala index 81c853a6e19f..3f0f1c60c801 100644 --- a/tests/init-global/neg/patmat-unapplySeq.scala +++ b/tests/init-global/neg/patmat-unapplySeq.scala @@ -5,7 +5,7 @@ object A: array(0) = new Box(10) def length: Int = array.length - def apply(i: Int): Box = array(i) // error + def apply(i: Int): Box = array(i) def drop(n: Int): Seq[Box] = array.toSeq def toSeq: Seq[Box] = array.toSeq @@ -15,3 +15,5 @@ object A: object B: A.array match case A(b) => + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/patmat-unapplySeq2.check b/tests/init-global/neg/patmat-unapplySeq2.check new file mode 100644 index 000000000000..57a67452c10f --- /dev/null +++ b/tests/init-global/neg/patmat-unapplySeq2.check @@ -0,0 +1,12 @@ +-- Warning: tests/init-global/neg/patmat-unapplySeq2.scala:8:32 -------------------------------------------------------- +8 | def apply(i: Int): Box = array(i) + | ^^^^^^^^ + |Reading mutable state of object A during initialization of object B. + |Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: + |├── object B: [ patmat-unapplySeq2.scala:15 ] + |│ ^ + |├── case A(b*) => [ patmat-unapplySeq2.scala:17 ] + |│ ^^^^^ + |└── def apply(i: Int): Box = array(i) [ patmat-unapplySeq2.scala:8 ] + | ^^^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/patmat-unapplySeq2.scala b/tests/init-global/neg/patmat-unapplySeq2.scala index adab9495db49..c890a09efd2e 100644 --- a/tests/init-global/neg/patmat-unapplySeq2.scala +++ b/tests/init-global/neg/patmat-unapplySeq2.scala @@ -5,7 +5,7 @@ object A: array(0) = new Box(10) def length: Int = array.length - def apply(i: Int): Box = array(i) // error + def apply(i: Int): Box = array(i) def drop(n: Int): Seq[Box] = array.toSeq def toSeq: Seq[Box] = array.toSeq @@ -15,3 +15,5 @@ object A: object B: A.array match case A(b*) => + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/patmat.check b/tests/init-global/neg/patmat.check new file mode 100644 index 000000000000..e05d144db7ce --- /dev/null +++ b/tests/init-global/neg/patmat.check @@ -0,0 +1,27 @@ +-- Warning: tests/init-global/neg/patmat.scala:1:7 --------------------------------------------------------------------- +1 |object A: + | ^ + | Cyclic initialization: object A -> object B -> object A. Calling trace: + | ├── object A: [ patmat.scala:1 ] + | │ ^ + | ├── case Some(x) => println(x * 2 + B.a.size) [ patmat.scala:4 ] + | │ ^ + | ├── object B: [ patmat.scala:7 ] + | │ ^ + | └── if A.a.isEmpty then println(xs.size) [ patmat.scala:12 ] + | ^ +-- Warning: tests/init-global/neg/patmat.scala:29:9 -------------------------------------------------------------------- +29 | object Inner: + | ^ + | Cyclic initialization: object Inner -> object C -> object Inner. Calling trace: + | ├── object Inner: [ patmat.scala:29 ] + | │ ^ + | ├── case Box(f) => f() [ patmat.scala:35 ] + | │ ^^^ + | ├── val foo: () => Int = () => C.a [ patmat.scala:32 ] + | │ ^ + | ├── object C: [ patmat.scala:18 ] + | │ ^ + | └── val a: Int = Inner.b [ patmat.scala:27 ] + | ^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/patmat.scala b/tests/init-global/neg/patmat.scala index 126e66e7cf7b..05f6ea0cdbac 100644 --- a/tests/init-global/neg/patmat.scala +++ b/tests/init-global/neg/patmat.scala @@ -1,4 +1,4 @@ -object A: // error +object A: val a: Option[Int] = Some(3) a match case Some(x) => println(x * 2 + B.a.size) @@ -26,7 +26,7 @@ object C: val a: Int = Inner.b - object Inner: // error + object Inner: val b: Int = 10 val foo: () => Int = () => C.a @@ -34,3 +34,5 @@ object C: (Box(foo): Box[() => Int] | Holder[Int]) match case Box(f) => f() case Holder(x) => x + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/return.check b/tests/init-global/neg/return.check new file mode 100644 index 000000000000..a420b2bab4c3 --- /dev/null +++ b/tests/init-global/neg/return.check @@ -0,0 +1,11 @@ +-- Warning: tests/init-global/neg/return.scala:4:31 -------------------------------------------------------------------- +4 | return (a: Int) => a + B.n + | ^^^ + | Access uninitialized field value n. Calling trace: + | ├── object B: [ return.scala:8 ] + | │ ^ + | ├── val n = A.foo(-10)(20) [ return.scala:9 ] + | │ ^^^^^^^^^^^^^^ + | └── return (a: Int) => a + B.n [ return.scala:4 ] + | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/return.scala b/tests/init-global/neg/return.scala old mode 100755 new mode 100644 index 5cbf6915fc0e..442b0f200f45 --- a/tests/init-global/neg/return.scala +++ b/tests/init-global/neg/return.scala @@ -1,10 +1,12 @@ object A: def foo(x: Int): Int => Int = if x <= 0 then - return (a: Int) => a + B.n // error + return (a: Int) => a + B.n (a: Int) => a * a + x object B: val n = A.foo(-10)(20) + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/return2.check b/tests/init-global/neg/return2.check new file mode 100644 index 000000000000..e0d9a6e33b14 --- /dev/null +++ b/tests/init-global/neg/return2.check @@ -0,0 +1,15 @@ +-- Warning: tests/init-global/neg/return2.scala:3:30 ------------------------------------------------------------------- +3 | val f = (a: Int) => a + B.n + | ^^^ + | Access uninitialized field value n. Calling trace: + | ├── object B: [ return2.scala:12 ] + | │ ^ + | ├── val n = A.foo(-10)(20) [ return2.scala:13 ] + | │ ^^^^^^^^^^^^^^ + | └── val f = (a: Int) => a + B.n [ return2.scala:3 ] + | ^^^ +-- Warning: tests/init-global/neg/return2.scala:6:18 ------------------------------------------------------------------- +6 | val g = () => return f + | ^^^^^^^^ + | Non local returns are no longer supported; use `boundary` and `boundary.break` in `scala.util` instead +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/return2.scala b/tests/init-global/neg/return2.scala old mode 100755 new mode 100644 index 6a4dec50c2dd..3c93fe9120c6 --- a/tests/init-global/neg/return2.scala +++ b/tests/init-global/neg/return2.scala @@ -1,6 +1,6 @@ object A: def foo(x: Int): Int => Int = - val f = (a: Int) => a + B.n // error + val f = (a: Int) => a + B.n var i = 0 val g = () => return f @@ -11,3 +11,5 @@ object A: object B: val n = A.foo(-10)(20) + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/t5366.check b/tests/init-global/neg/t5366.check new file mode 100644 index 000000000000..3aeda68fd96f --- /dev/null +++ b/tests/init-global/neg/t5366.check @@ -0,0 +1,21 @@ +-- Warning: tests/init-global/neg/t5366.scala:3:12 --------------------------------------------------------------------- +3 |case object ObjA extends IdAndMsg(1) + | ^ + | Cyclic initialization: object ObjA -> object IdAndMsg -> object ObjA. Calling trace: + | ├── case object ObjA extends IdAndMsg(1) [ t5366.scala:3 ] + | │ ^ + | ├── object IdAndMsg { [ t5366.scala:6 ] + | │ ^ + | └── val values = List(ObjA , ObjB) [ t5366.scala:7 ] + | ^^^^ +-- Warning: tests/init-global/neg/t5366.scala:6:7 ---------------------------------------------------------------------- +6 |object IdAndMsg { + | ^ + | Cyclic initialization: object IdAndMsg -> object ObjB -> object IdAndMsg. Calling trace: + | ├── object IdAndMsg { [ t5366.scala:6 ] + | │ ^ + | ├── val values = List(ObjA , ObjB) [ t5366.scala:7 ] + | │ ^^^^ + | └── case object ObjB extends IdAndMsg(2) [ t5366.scala:4 ] + | ^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/t5366.scala b/tests/init-global/neg/t5366.scala index 854bdfe0544b..2283b79bfb8f 100644 --- a/tests/init-global/neg/t5366.scala +++ b/tests/init-global/neg/t5366.scala @@ -1,9 +1,9 @@ class IdAndMsg(val id: Int, val msg: String = "") -case object ObjA extends IdAndMsg(1) // error +case object ObjA extends IdAndMsg(1) case object ObjB extends IdAndMsg(2) -object IdAndMsg { // error +object IdAndMsg { val values = List(ObjA , ObjB) } @@ -12,4 +12,5 @@ object Test { ObjA println(IdAndMsg.values) } -} \ No newline at end of file +} +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/t9115.check b/tests/init-global/neg/t9115.check new file mode 100644 index 000000000000..a55c2eb151a1 --- /dev/null +++ b/tests/init-global/neg/t9115.check @@ -0,0 +1,21 @@ +-- Warning: tests/init-global/neg/t9115.scala:4:14 --------------------------------------------------------------------- +4 | case object D1 extends Z(aaa) + | ^ + | Cyclic initialization: object D1 -> object D -> object D1. Calling trace: + | ├── case object D1 extends Z(aaa) [ t9115.scala:4 ] + | │ ^^^ + | ├── object D { [ t9115.scala:1 ] + | │ ^ + | └── println(D1) [ t9115.scala:6 ] + | ^^ +-- Warning: tests/init-global/neg/t9115.scala:1:7 ---------------------------------------------------------------------- +1 |object D { + | ^ + | Cyclic initialization: object D -> object D2 -> object D. Calling trace: + | ├── object D { [ t9115.scala:1 ] + | │ ^ + | ├── println(D2) [ t9115.scala:7 ] + | │ ^^ + | └── case object D2 extends Z(aaa) // 'null' when calling D.D2 first time [ t9115.scala:5 ] + | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/t9115.scala b/tests/init-global/neg/t9115.scala index a3020c6939a8..aa9573554260 100644 --- a/tests/init-global/neg/t9115.scala +++ b/tests/init-global/neg/t9115.scala @@ -1,8 +1,10 @@ -object D { // error +object D { def aaa = 1 //that’s the reason class Z (depends: Any) - case object D1 extends Z(aaa) // 'null' when calling D.D1 first time // error + case object D1 extends Z(aaa) case object D2 extends Z(aaa) // 'null' when calling D.D2 first time println(D1) println(D2) } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/t9261.check b/tests/init-global/neg/t9261.check new file mode 100644 index 000000000000..dbda32347e74 --- /dev/null +++ b/tests/init-global/neg/t9261.check @@ -0,0 +1,9 @@ +-- Warning: tests/init-global/neg/t9261.scala:2:12 --------------------------------------------------------------------- +2 |case object Buy extends OrderType(Sell) + | ^ + | Cyclic initialization: object Buy -> object Sell -> object Buy. Calling trace: + | ├── case object Buy extends OrderType(Sell) [ t9261.scala:2 ] + | │ ^^^^ + | └── case object Sell extends OrderType(Buy) [ t9261.scala:3 ] + | ^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/t9261.scala b/tests/init-global/neg/t9261.scala index 1e23bedb9b6a..9eb7f255492c 100644 --- a/tests/init-global/neg/t9261.scala +++ b/tests/init-global/neg/t9261.scala @@ -1,3 +1,5 @@ sealed abstract class OrderType(val reverse: OrderType) -case object Buy extends OrderType(Sell) // error +case object Buy extends OrderType(Sell) case object Sell extends OrderType(Buy) + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/t9312.check b/tests/init-global/neg/t9312.check new file mode 100644 index 000000000000..d6f1b00b1a09 --- /dev/null +++ b/tests/init-global/neg/t9312.check @@ -0,0 +1,29 @@ +-- Warning: tests/init-global/neg/t9312.scala:18:11 -------------------------------------------------------------------- +18 | object Child1 extends Child + | ^ + | Cyclic initialization: object Child1 -> object Parent -> object Child1. Calling trace: + | ├── object Child1 extends Child [ t9312.scala:18 ] + | │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ├── trait Child { [ t9312.scala:12 ] + | │ ^ + | ├── val parent = Parent [ t9312.scala:14 ] + | │ ^^^^^^ + | ├── object Parent { [ t9312.scala:11 ] + | │ ^ + | └── final val children = Set(Child1, Child2) [ t9312.scala:21 ] + | ^^^^^^ +-- Warning: tests/init-global/neg/t9312.scala:11:9 --------------------------------------------------------------------- +11 | object Parent { + | ^ + | Cyclic initialization: object Parent -> object Child2 -> object Parent. Calling trace: + | ├── object Parent { [ t9312.scala:11 ] + | │ ^ + | ├── final val children = Set(Child1, Child2) [ t9312.scala:21 ] + | │ ^^^^^^ + | ├── object Child2 extends Child [ t9312.scala:19 ] + | │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ├── trait Child { [ t9312.scala:12 ] + | │ ^ + | └── val parent = Parent [ t9312.scala:14 ] + | ^^^^^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/t9312.scala b/tests/init-global/neg/t9312.scala index d88093a2f67a..7dc9af580162 100644 --- a/tests/init-global/neg/t9312.scala +++ b/tests/init-global/neg/t9312.scala @@ -8,16 +8,18 @@ object DeadLockTest { } - object Parent { // error + object Parent { trait Child { Thread.sleep(2000) // ensure concurrent behavior val parent = Parent def siblings = parent.children - this } - object Child1 extends Child // error + object Child1 extends Child object Child2 extends Child final val children = Set(Child1, Child2) } } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/t9360.check b/tests/init-global/neg/t9360.check new file mode 100644 index 000000000000..23ceea224a10 --- /dev/null +++ b/tests/init-global/neg/t9360.check @@ -0,0 +1,21 @@ +-- Warning: tests/init-global/neg/t9360.scala:8:9 ---------------------------------------------------------------------- +8 | object AObj extends BaseClass(s) + | ^ + | Cyclic initialization: object AObj -> object Obj -> object AObj. Calling trace: + | ├── object AObj extends BaseClass(s) [ t9360.scala:8 ] + | │ ^ + | ├── object Obj { [ t9360.scala:5 ] + | │ ^ + | └── val list = List(AObj, BObj) [ t9360.scala:12 ] + | ^^^^ +-- Warning: tests/init-global/neg/t9360.scala:5:7 ---------------------------------------------------------------------- +5 |object Obj { + | ^ + | Cyclic initialization: object Obj -> object BObj -> object Obj. Calling trace: + | ├── object Obj { [ t9360.scala:5 ] + | │ ^ + | ├── val list = List(AObj, BObj) [ t9360.scala:12 ] + | │ ^^^^ + | └── object BObj extends BaseClass(s) [ t9360.scala:10 ] + | ^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/t9360.scala b/tests/init-global/neg/t9360.scala index 2ec0c740d739..0fca843cd01d 100644 --- a/tests/init-global/neg/t9360.scala +++ b/tests/init-global/neg/t9360.scala @@ -2,10 +2,10 @@ class BaseClass(s: String) { def print: Unit = () } -object Obj { // error +object Obj { val s: String = "hello" - object AObj extends BaseClass(s) // error + object AObj extends BaseClass(s) object BObj extends BaseClass(s) @@ -23,3 +23,5 @@ object ObjectInit { Obj.print } } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/unapply-implicit-arg.check b/tests/init-global/neg/unapply-implicit-arg.check new file mode 100644 index 000000000000..4e45d79e7e14 --- /dev/null +++ b/tests/init-global/neg/unapply-implicit-arg.check @@ -0,0 +1,9 @@ +-- Warning: tests/init-global/neg/unapply-implicit-arg.scala:11:16 ----------------------------------------------------- +11 | val i2: Int = i2 match + | ^^ + | Access uninitialized field value i2. Calling trace: + | ├── object Bar { [ unapply-implicit-arg.scala:1 ] + | │ ^ + | └── val i2: Int = i2 match [ unapply-implicit-arg.scala:11 ] + | ^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/unapply-implicit-arg.scala b/tests/init-global/neg/unapply-implicit-arg.scala index bf41fbbf9412..dd8d03821d0a 100644 --- a/tests/init-global/neg/unapply-implicit-arg.scala +++ b/tests/init-global/neg/unapply-implicit-arg.scala @@ -8,7 +8,8 @@ object Bar { given Foo = new Foo val i1: Int = 0 - val i2: Int = i2 match // error + val i2: Int = i2 match case Bar(i) => i case _ => 0 -} \ No newline at end of file +} +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/unapply-implicit-arg2.check b/tests/init-global/neg/unapply-implicit-arg2.check new file mode 100644 index 000000000000..ec317d59f1bd --- /dev/null +++ b/tests/init-global/neg/unapply-implicit-arg2.check @@ -0,0 +1,13 @@ +-- Warning: tests/init-global/neg/unapply-implicit-arg2.scala:7:51 ----------------------------------------------------- +7 | if i == 0 then Some(f1.m1(i1)) else Some(f1.m2(i2)) + | ^^ + | Access uninitialized field value i2. Calling trace: + | ├── object Bar { [ unapply-implicit-arg2.scala:1 ] + | │ ^ + | ├── case Bar(i) => i [ unapply-implicit-arg2.scala:12 ] + | │ ^^^^^^ + | ├── def unapply(using f1: Foo)(i: Int): Option[Int] = [ unapply-implicit-arg2.scala:6 ] + | │ ^ + | └── if i == 0 then Some(f1.m1(i1)) else Some(f1.m2(i2)) [ unapply-implicit-arg2.scala:7 ] + | ^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/unapply-implicit-arg2.scala b/tests/init-global/neg/unapply-implicit-arg2.scala index c0a16faac377..b180e5eee495 100644 --- a/tests/init-global/neg/unapply-implicit-arg2.scala +++ b/tests/init-global/neg/unapply-implicit-arg2.scala @@ -4,7 +4,7 @@ object Bar { def m2(i: Int) = i+2 } def unapply(using f1: Foo)(i: Int): Option[Int] = - if i == 0 then Some(f1.m1(i1)) else Some(f1.m2(i2)) // error + if i == 0 then Some(f1.m1(i1)) else Some(f1.m2(i2)) given Foo = new Foo val i1: Int = 0 @@ -12,3 +12,5 @@ object Bar { case Bar(i) => i case _ => 0 } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/unapply-implicit-arg3.check b/tests/init-global/neg/unapply-implicit-arg3.check new file mode 100644 index 000000000000..3bb9c0ad2930 --- /dev/null +++ b/tests/init-global/neg/unapply-implicit-arg3.check @@ -0,0 +1,15 @@ +-- Warning: tests/init-global/neg/unapply-implicit-arg3.scala:4:25 ----------------------------------------------------- +4 | def m2(i: Int) = i + i2 + | ^^ + | Access uninitialized field value i2. Calling trace: + | ├── object Bar { [ unapply-implicit-arg3.scala:1 ] + | │ ^ + | ├── case Bar(i) => i [ unapply-implicit-arg3.scala:12 ] + | │ ^^^^^^ + | ├── def unapply(using f1: Foo)(i: Int): Option[Int] = [ unapply-implicit-arg3.scala:6 ] + | │ ^ + | ├── if i == 0 then Some(f1.m1(i)) else Some(f1.m2(i)) [ unapply-implicit-arg3.scala:7 ] + | │ ^^^^^^^^ + | └── def m2(i: Int) = i + i2 [ unapply-implicit-arg3.scala:4 ] + | ^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/unapply-implicit-arg3.scala b/tests/init-global/neg/unapply-implicit-arg3.scala index efa348f6cfdb..3bf923eeeb4e 100644 --- a/tests/init-global/neg/unapply-implicit-arg3.scala +++ b/tests/init-global/neg/unapply-implicit-arg3.scala @@ -1,7 +1,7 @@ object Bar { class Foo { def m1(i: Int) = i + i1 - def m2(i: Int) = i + i2 // error + def m2(i: Int) = i + i2 } def unapply(using f1: Foo)(i: Int): Option[Int] = if i == 0 then Some(f1.m1(i)) else Some(f1.m2(i)) @@ -12,3 +12,5 @@ object Bar { case Bar(i) => i case _ => 0 } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/unapplySeq-implicit-arg.check b/tests/init-global/neg/unapplySeq-implicit-arg.check new file mode 100644 index 000000000000..d021cd1f5d94 --- /dev/null +++ b/tests/init-global/neg/unapplySeq-implicit-arg.check @@ -0,0 +1,9 @@ +-- Warning: tests/init-global/neg/unapplySeq-implicit-arg.scala:11:20 -------------------------------------------------- +11 | val i2: Int = Seq(i2) match + | ^^ + | Access uninitialized field value i2. Calling trace: + | ├── object Bar { [ unapplySeq-implicit-arg.scala:1 ] + | │ ^ + | └── val i2: Int = Seq(i2) match [ unapplySeq-implicit-arg.scala:11 ] + | ^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/unapplySeq-implicit-arg.scala b/tests/init-global/neg/unapplySeq-implicit-arg.scala index e58635a3090f..1ec3ab6fa79a 100644 --- a/tests/init-global/neg/unapplySeq-implicit-arg.scala +++ b/tests/init-global/neg/unapplySeq-implicit-arg.scala @@ -8,7 +8,9 @@ object Bar { given Foo = new Foo val i1: Int = 0 - val i2: Int = Seq(i2) match // error + val i2: Int = Seq(i2) match case Bar(i) => i case _ => 0 } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/unapplySeq-implicit-arg2.check b/tests/init-global/neg/unapplySeq-implicit-arg2.check new file mode 100644 index 000000000000..2e5164d7b405 --- /dev/null +++ b/tests/init-global/neg/unapplySeq-implicit-arg2.check @@ -0,0 +1,13 @@ +-- Warning: tests/init-global/neg/unapplySeq-implicit-arg2.scala:4:9 --------------------------------------------------- +4 | Some(i1 +: seqi) + | ^^ + |Access uninitialized field value i1. Calling trace: + |├── object Bar { [ unapplySeq-implicit-arg2.scala:1 ] + |│ ^ + |├── case Bar(i) => i [ unapplySeq-implicit-arg2.scala:7 ] + |│ ^^^^^^ + |├── def unapplySeq(using f1: Foo)(using f2: Foo)(seqi: Seq[Int])(using Foo): Option[Seq[Int]] = [ unapplySeq-implicit-arg2.scala:3 ] + |│ ^ + |└── Some(i1 +: seqi) [ unapplySeq-implicit-arg2.scala:4 ] + | ^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/unapplySeq-implicit-arg2.scala b/tests/init-global/neg/unapplySeq-implicit-arg2.scala index 35f5105b84d2..7a48651a3a7a 100644 --- a/tests/init-global/neg/unapplySeq-implicit-arg2.scala +++ b/tests/init-global/neg/unapplySeq-implicit-arg2.scala @@ -1,10 +1,12 @@ object Bar { class Foo def unapplySeq(using f1: Foo)(using f2: Foo)(seqi: Seq[Int])(using Foo): Option[Seq[Int]] = - Some(i1 +: seqi) // error + Some(i1 +: seqi) given Foo = new Foo val i1: Int = Seq(0) match { case Bar(i) => i case _ => 0 } } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/unapplySeq-implicit-arg3.check b/tests/init-global/neg/unapplySeq-implicit-arg3.check new file mode 100644 index 000000000000..59ea56320452 --- /dev/null +++ b/tests/init-global/neg/unapplySeq-implicit-arg3.check @@ -0,0 +1,15 @@ +-- Warning: tests/init-global/neg/unapplySeq-implicit-arg3.scala:3:27 -------------------------------------------------- +3 | def m(seq: Seq[Int]) = i1 +: seq + | ^^ + |Access uninitialized field value i1. Calling trace: + |├── object Bar { [ unapplySeq-implicit-arg3.scala:1 ] + |│ ^ + |├── case Bar(i, _) => i [ unapplySeq-implicit-arg3.scala:9 ] + |│ ^^^^^^^^^ + |├── def unapplySeq(using f1: Foo)(seqi: Seq[Int])(using Foo): Option[Seq[Int]] = [ unapplySeq-implicit-arg3.scala:5 ] + |│ ^ + |├── Some(f1.m(seqi)) [ unapplySeq-implicit-arg3.scala:6 ] + |│ ^^^^^^^^^^ + |└── def m(seq: Seq[Int]) = i1 +: seq [ unapplySeq-implicit-arg3.scala:3 ] + | ^^ +No warnings can be incurred under -Werror. diff --git a/tests/init-global/neg/unapplySeq-implicit-arg3.scala b/tests/init-global/neg/unapplySeq-implicit-arg3.scala index 2b5cdd327e57..9efcac577bd3 100644 --- a/tests/init-global/neg/unapplySeq-implicit-arg3.scala +++ b/tests/init-global/neg/unapplySeq-implicit-arg3.scala @@ -1,6 +1,6 @@ object Bar { class Foo { - def m(seq: Seq[Int]) = i1 +: seq // error + def m(seq: Seq[Int]) = i1 +: seq } def unapplySeq(using f1: Foo)(seqi: Seq[Int])(using Foo): Option[Seq[Int]] = Some(f1.m(seqi)) @@ -10,3 +10,5 @@ object Bar { case _ => 0 } } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/init-global/neg/i18628.scala b/tests/init-global/warn/i18628.scala similarity index 69% rename from tests/init-global/neg/i18628.scala rename to tests/init-global/warn/i18628.scala index 798b3204338c..afd5c14d0b7d 100644 --- a/tests/init-global/neg/i18628.scala +++ b/tests/init-global/warn/i18628.scala @@ -2,6 +2,6 @@ object Test: class Box(val x: Int) def recur(a: => Box, b: => Box): Int = - a.x + recur(a, b) + b.x // error // error + a.x + recur(a, b) + b.x // warn // warn recur(Box(1), Box(2)) \ No newline at end of file diff --git a/tests/init-global/neg/i18628_2.scala b/tests/init-global/warn/i18628_2.scala similarity index 73% rename from tests/init-global/neg/i18628_2.scala rename to tests/init-global/warn/i18628_2.scala index 4ad428035441..7f90f51ccc1a 100644 --- a/tests/init-global/neg/i18628_2.scala +++ b/tests/init-global/warn/i18628_2.scala @@ -2,6 +2,6 @@ object Test: class Box(val x: Int) def recur(a: => Box, b: Box): Int = - a.x + recur(a, b) + b.x // error + a.x + recur(a, b) + b.x // warn recur(Box(1), Box(2)) diff --git a/tests/init-global/neg/i18628_3.scala b/tests/init-global/warn/i18628_3.scala similarity index 67% rename from tests/init-global/neg/i18628_3.scala rename to tests/init-global/warn/i18628_3.scala index 101674cffb6f..0a14c7d4c73e 100644 --- a/tests/init-global/neg/i18628_3.scala +++ b/tests/init-global/warn/i18628_3.scala @@ -4,6 +4,6 @@ object Test: class Box(val x: Int) def recur(a: => Box, b: => Box): Int = - a.x + recur(a: @widen(5), b: @widen(5)) + b.x // error // error + a.x + recur(a: @widen(5), b: @widen(5)) + b.x // warn // warn recur(Box(1), Box(2)) \ No newline at end of file diff --git a/tests/neg-custom-args/sourcepath2/hi/A.check b/tests/neg-custom-args/sourcepath2/hi/A.check index 61d4798a34e7..1fac6b1147ef 100644 --- a/tests/neg-custom-args/sourcepath2/hi/A.check +++ b/tests/neg-custom-args/sourcepath2/hi/A.check @@ -1,6 +1,7 @@ --- Error: tests/neg-custom-args/sourcepath2/hi/A.scala:3:6 ------------------------------------------------------------- -3 |class Hello { // error +-- Warning: tests/neg-custom-args/sourcepath2/hi/A.scala:3:6 ----------------------------------------------------------- +3 |class Hello { // warn | ^ | class Hello is in the wrong directory. | It was declared to be in package | But it is found in directory hi +No warnings can be incurred under -Werror. diff --git a/tests/neg-custom-args/sourcepath2/hi/A.scala b/tests/neg-custom-args/sourcepath2/hi/A.scala index c332f2494e15..039910e55ce7 100644 --- a/tests/neg-custom-args/sourcepath2/hi/A.scala +++ b/tests/neg-custom-args/sourcepath2/hi/A.scala @@ -1,5 +1,6 @@ // Missing `package hi` -class Hello { // error +class Hello { // warn val x: Int = 1 } +// nopos-error: werror \ No newline at end of file diff --git a/tests/neg-deep-subtype/1828.scala b/tests/neg-deep-subtype/1828.scala deleted file mode 100644 index ae228a83e898..000000000000 --- a/tests/neg-deep-subtype/1828.scala +++ /dev/null @@ -1,11 +0,0 @@ -//> using options -Xfatal-warnings - -class Test { - def remove[S](a: S | Int, f: Int => S):S = a match { - case a: S => a // error - case a: Int => f(a) - } - - val t: Int | String = 5 - val t1 = remove[String](t, _.toString) -} diff --git a/tests/neg-deep-subtype/3324b.scala b/tests/neg-deep-subtype/3324b.scala deleted file mode 100644 index df0cc5432eff..000000000000 --- a/tests/neg-deep-subtype/3324b.scala +++ /dev/null @@ -1,11 +0,0 @@ -//> using options -Xfatal-warnings - -class C[T] { - val x: Any = ??? - if (x.isInstanceOf[List[String]]) // error: unchecked - if (x.isInstanceOf[T]) // error: unchecked - x match { - case x: List[String] => // error: unchecked - case x: T => // error: unchecked - } -} diff --git a/tests/neg-deep-subtype/3324f.scala b/tests/neg-deep-subtype/3324f.scala deleted file mode 100644 index 445da5cb25a0..000000000000 --- a/tests/neg-deep-subtype/3324f.scala +++ /dev/null @@ -1,11 +0,0 @@ -//> using options -Xfatal-warnings - -trait C[T] -class D[T] - -class Test { - def foo[T](x: C[T]) = x match { - case _: D[T] => // error - case _: C[Int] => // error - } -} \ No newline at end of file diff --git a/tests/neg-deep-subtype/3324g.scala b/tests/neg-deep-subtype/3324g.scala deleted file mode 100644 index a5b842e4e450..000000000000 --- a/tests/neg-deep-subtype/3324g.scala +++ /dev/null @@ -1,21 +0,0 @@ -//> using options -Xfatal-warnings - -class Test { - trait A[+T] - class B[T] extends A[T] - class C[T] extends B[Any] with A[T] - - def foo[T](c: C[T]): Unit = c match { - case _: B[T] => // error - } - - def bar[T](b: B[T]): Unit = b match { - case _: A[T] => - } - - def quux[T](a: A[T]): Unit = a match { - case _: B[T] => // error!! - } - - quux(new C[Int]) -} diff --git a/tests/neg-deep-subtype/JavaSeqLiteral.scala b/tests/neg-deep-subtype/JavaSeqLiteral.scala deleted file mode 100644 index 6003731ae657..000000000000 --- a/tests/neg-deep-subtype/JavaSeqLiteral.scala +++ /dev/null @@ -1,31 +0,0 @@ -//> using options -Xfatal-warnings - -object Test1 { - trait Tree[-T] - - class JavaSeqLiteral[T] extends Tree[T] - - trait Type - - class DummyTree extends JavaSeqLiteral[Any] - - def foo1(tree: Tree[Type]) = - tree.isInstanceOf[JavaSeqLiteral[Type]] // error - - foo1(new DummyTree) -} - -object Test2 { - trait Tree[-T] - - class JavaSeqLiteral[-T] extends Tree[T] - - trait Type - - class DummyTree extends JavaSeqLiteral[Any] - - def foo1(tree: Tree[Type]) = - tree.isInstanceOf[JavaSeqLiteral[Type]] - - foo1(new DummyTree) -} \ No newline at end of file diff --git a/tests/neg-deep-subtype/conditionalWarnings.scala b/tests/neg-deep-subtype/conditionalWarnings.scala deleted file mode 100644 index c4757cbb7546..000000000000 --- a/tests/neg-deep-subtype/conditionalWarnings.scala +++ /dev/null @@ -1,15 +0,0 @@ -//> using options -deprecation -Xfatal-warnings - -object Test { - @deprecated def foo = ??? - - given Conversion[String, Int] = _.length - - foo // error - - val x: Int = "abc" - // OK, since -feature warnings are not enabled. - // The program compiles with final line - // there was 1 feature warning; re-run with -feature for details - // nopos-error -} diff --git a/tests/neg-deep-subtype/gadt.scala b/tests/neg-deep-subtype/gadt.scala deleted file mode 100644 index 661c04fef373..000000000000 --- a/tests/neg-deep-subtype/gadt.scala +++ /dev/null @@ -1,15 +0,0 @@ -//> using options -Xfatal-warnings - -class Test { - trait A[+T] - class B[T] extends A[T] - - class C - class D extends C - - def quux(a: A[C]): Unit = a match { - case _: B[C] => // error!! - } - - quux(new B[D]) -} \ No newline at end of file diff --git a/tests/neg-deep-subtype/html.scala b/tests/neg-deep-subtype/html.scala deleted file mode 100644 index f17cfb661505..000000000000 --- a/tests/neg-deep-subtype/html.scala +++ /dev/null @@ -1,20 +0,0 @@ -//> using options -Xfatal-warnings - -object HTML: - type AttrArg = AppliedAttr | Seq[AppliedAttr] - opaque type AppliedAttr = String - opaque type AppliedTag = StringBuilder - - case class Tag(name: String): - def apply(attrs: AttrArg*): AppliedTag = { - val sb = StringBuilder() - sb.append(s"<$name") - attrs.filter(_ != Nil).foreach{ - case s: Seq[AppliedAttr] => - s.foreach(sb.append(" ").append) - case s: Seq[Int] => // error - case e: AppliedAttr => - sb.append(" ").append(e) - } - sb - } diff --git a/tests/neg-deep-subtype/i3324.scala b/tests/neg-deep-subtype/i3324.scala deleted file mode 100644 index 9b1060836430..000000000000 --- a/tests/neg-deep-subtype/i3324.scala +++ /dev/null @@ -1,6 +0,0 @@ -//> using options -Xfatal-warnings - -class Foo { - def foo(x: Any): Boolean = - x.isInstanceOf[List[String]] // error -} diff --git a/tests/neg-deep-subtype/i4297.scala b/tests/neg-deep-subtype/i4297.scala deleted file mode 100644 index 88e66c59d1b4..000000000000 --- a/tests/neg-deep-subtype/i4297.scala +++ /dev/null @@ -1,13 +0,0 @@ -//> using options -Xfatal-warnings - -class Test { - def test[X <: Option[Int]](x: X) = x.isInstanceOf[Some[Int]] - def test1[Y <: Int, X <: Option[Y]](x: X) = x.isInstanceOf[Some[Int]] - def test2(x: Any) = x.isInstanceOf[Function1[Nothing, ?]] - def test3a(x: Any) = x.isInstanceOf[Function1[Any, ?]] // error - def test3b(x: Any) = x.isInstanceOf[Function1[Int, ?]] // error - def test4[Y <: Int, X <: Function1[Y, Unit]](x: X) = x.isInstanceOf[Function1[Int, ?]] // error - def test5[Y <: Int, X <: Function1[Y, Unit]](x: X) = x.isInstanceOf[Function1[Int, Unit]] // error - def test6[Y <: Int, X <: Function1[Y, Unit]](x: X) = x.isInstanceOf[Function1[Int, Any]] // error - def test7[Y <: Int, X <: Function1[Y, Unit]](x: X) = x.isInstanceOf[Function1[?, Unit]] -} diff --git a/tests/neg-deep-subtype/or-type-trees.scala b/tests/neg-deep-subtype/or-type-trees.scala deleted file mode 100644 index d0338ffe6066..000000000000 --- a/tests/neg-deep-subtype/or-type-trees.scala +++ /dev/null @@ -1,40 +0,0 @@ -//> using options -Xfatal-warnings - -object Test1 { - trait Tree - trait Context - - def foo1(myTree: Tree | (Context => Tree)) = - println(myTree.isInstanceOf[Tree]) - - def foo2(myTree: Tree | (Context => Tree)) = - myTree match - case treeFn: (Context => Tree) => // error - case _ => - - def foo3(myTree: Tree | (Context => Tree)) = - myTree match - case treeFn: (? => ?) => // ok - case _ => -} - -object Test2 { - trait Tree[-T] - trait Context - - trait Type - - def foo1(myTree: Tree[Type] | (Context => Tree[Type])) = - println(myTree.isInstanceOf[Tree[Type]]) // error - /* class DummyTree extends Tree[Nothing] with (Context => Tree[Type]) */ - - def foo2(myTree: Tree[Type] | (Context => Tree[Type])) = - myTree match - case treeFn: (Context => Tree[Type]) => // error - case _ => - - def foo3(myTree: Tree[Type] | (Context => Tree[Type])) = - myTree match - case treeFn: (? => ?) => // ok - case _ => -} \ No newline at end of file diff --git a/tests/neg-deep-subtype/refined-types.scala b/tests/neg-deep-subtype/refined-types.scala deleted file mode 100644 index 5f5cc5a45f04..000000000000 --- a/tests/neg-deep-subtype/refined-types.scala +++ /dev/null @@ -1,24 +0,0 @@ -//> using options -Xfatal-warnings - -class A -class B extends A -type AA = A { type T = Int } -type BA = B { type T = Int } -type AL = A { type T >: Int } -type BL = B { type T >: Int } -type AU = A { type T <: Int } -type BU = B { type T <: Int } - -def aa(x: AA) = x.isInstanceOf[BA] // was: the type test for BA cannot be checked at runtime -def al(x: AL) = x.isInstanceOf[BL] // was: the type test for BL cannot be checked at runtime -def au(x: AU) = x.isInstanceOf[BU] // was: the type test for BU cannot be checked at runtime - -// an alias leaves nothing unchecked when type testing against one bound: -def bl(x: AA) = x.isInstanceOf[BL] // was: the type test for BL cannot be checked at runtime -def bu(x: AA) = x.isInstanceOf[BU] // was: the type test for BU cannot be checked at runtime - -// but static knowledge of only one bound makes checking against an alias unchecked: -def al_ba(x: AL) = x.isInstanceOf[BA] // error: the type test for BA cannot be checked at runtime -def au_ba(x: AU) = x.isInstanceOf[BA] // error: the type test for BA cannot be checked at runtime -def al_bu(x: AL) = x.isInstanceOf[BU] // error: the type test for BU cannot be checked at runtime -def au_bl(x: AU) = x.isInstanceOf[BL] // error: the type test for BL cannot be checked at runtime diff --git a/tests/neg-deep-subtype/t2755.scala b/tests/neg-deep-subtype/t2755.scala deleted file mode 100644 index ec3cb6aadefc..000000000000 --- a/tests/neg-deep-subtype/t2755.scala +++ /dev/null @@ -1,60 +0,0 @@ -//> using options -Xfatal-warnings - -// Test cases: the only place we can cut and paste without crying -// ourself to sleep. -object Test { - def f1(a: Any) = a match { - case x: Array[Int] => x(0) - case x: Array[Double] => 2 - case x: Array[Float] => x.sum.toInt - case x: Array[String] => x.size - case x: Array[AnyRef] => 5 - case x: Array[?] => 6 - case _ => 7 - } - def f2(a: Array[?]) = a match { - case x: Array[Int] => x(0) - case x: Array[Double] => 2 - case x: Array[Float] => x.sum.toInt - case x: Array[String] => x.size - case x: Array[AnyRef] => 5 - case x: Array[?] => 6 - case _ => 7 // error: only null is matched - } - def f3[T](a: Array[T]) = a match { - case x: Array[Int] => x(0) - case x: Array[Double] => 2 - case x: Array[Float] => x.sum.toInt - case x: Array[String] => x.size - case x: Array[AnyRef] => 5 - case x: Array[?] => 6 - case _ => 7 // error: only null is matched - } - - - def main(args: Array[String]): Unit = { - println(f1(Array(1, 2, 3))) - println(f1(Array(1.0, -2.0, 3.0, 1.0))) - println(f1(Array(1.0f, 2.0f, 3.0f, -3.0f))) - println(f1((1 to 4).toArray map (_.toString))) - println(f1(new Array[Any](10))) // should match as Array[AnyRef] - println(f1(Array(1L))) - println(f1(null)) - - println(f2(Array(1, 2, 3))) - println(f2(Array(1.0, -2.0, 3.0, 1.0))) - println(f2(Array(1.0f, 2.0f, 3.0f, -3.0f))) - println(f2((1 to 4).toArray map (_.toString))) - println(f2(new Array[Any](10))) // should match as Array[AnyRef] - println(f2(Array(1L))) - println(f2(null)) - - println(f3(Array(1, 2, 3))) - println(f3(Array(1.0, -2.0, 3.0, 1.0))) - println(f3(Array(1.0f, 2.0f, 3.0f, -3.0f))) - println(f3((1 to 4).toArray map (_.toString))) - println(f3(new Array[Any](10))) // should match as Array[AnyRef] - println(f3(Array(1L))) - println(f3(null)) - } -} diff --git a/tests/neg-deep-subtype/type-lambda.scala b/tests/neg-deep-subtype/type-lambda.scala deleted file mode 100644 index 4c4627fe1cf3..000000000000 --- a/tests/neg-deep-subtype/type-lambda.scala +++ /dev/null @@ -1,16 +0,0 @@ -//> using options -Xfatal-warnings - -trait A[T] -trait B[T] extends A[T] - -object Test { - def foo(x: ([X] =>> A[X])[Any]) = x match { - case x: ([X] =>> B[X])[Any] => - case _ => - } - - def bar(x: ([X] =>> A[X])[Any]) = x match { - case x: ([X] =>> B[Nothing])[Any] => // error - case _ => - } -} diff --git a/tests/neg-macros/i9570.check b/tests/neg-macros/i9570.check new file mode 100644 index 000000000000..16b71d317b7c --- /dev/null +++ b/tests/neg-macros/i9570.check @@ -0,0 +1,5 @@ +-- Warning: tests/neg-macros/i9570.scala:15:21 ------------------------------------------------------------------------- +15 | case '{HCons(_,$t)} => // warn (in .check file) + | ^ + | Use of `_` for lambda in quoted pattern. Use explicit lambda instead or use `$_` to match any term. +No warnings can be incurred under -Werror. diff --git a/tests/neg-macros/i9570.scala b/tests/neg-macros/i9570.scala index 9242fd2e9bbd..0c67c2d0f8d1 100644 --- a/tests/neg-macros/i9570.scala +++ b/tests/neg-macros/i9570.scala @@ -12,7 +12,7 @@ object Macros { private def sizeImpl(e: Expr[HList], n:Int)(using qctx:Quotes): Expr[Int] = { import quotes.reflect.* e match { - case '{HCons(_,$t)} => // error if run with fatal warinings in BootstrappedOnlyCompilationTests + case '{HCons(_,$t)} => // warn (in .check file) sizeImpl(t,n+1) case '{HNil} => Expr(n) } @@ -20,7 +20,9 @@ object Macros { inline def size(inline expr: HList ): Int = { ${sizeImpl('expr,0)} - } + } } } + +// nopos-error No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg-macros/macro-deprecation.check b/tests/neg-macros/macro-deprecation.check new file mode 100644 index 000000000000..5ce8a2427127 --- /dev/null +++ b/tests/neg-macros/macro-deprecation.check @@ -0,0 +1,5 @@ +-- Deprecation Warning: tests/neg-macros/macro-deprecation.scala:5:18 -------------------------------------------------- +5 |inline def f = ${ impl } // warn (in .check file) + | ^^^^ + | method impl is deprecated +No warnings can be incurred under -Werror. diff --git a/tests/neg-macros/macro-deprecation.scala b/tests/neg-macros/macro-deprecation.scala index ad1cdda001bb..0bbf4d5faa1e 100644 --- a/tests/neg-macros/macro-deprecation.scala +++ b/tests/neg-macros/macro-deprecation.scala @@ -2,5 +2,7 @@ import scala.quoted.* -inline def f = ${ impl } // error +inline def f = ${ impl } // warn (in .check file) @deprecated def impl(using Quotes) = '{1} + +// nopos-error No warnings can be incurred under -Werror. diff --git a/tests/neg-scalajs/enumeration-warnings.check b/tests/neg-scalajs/enumeration-warnings.check index b356a150daa5..5d791be5928a 100644 --- a/tests/neg-scalajs/enumeration-warnings.check +++ b/tests/neg-scalajs/enumeration-warnings.check @@ -1,60 +1,61 @@ --- Error: tests/neg-scalajs/enumeration-warnings.scala:6:4 ------------------------------------------------------------- -6 | Value // error +-- Warning: tests/neg-scalajs/enumeration-warnings.scala:6:4 ----------------------------------------------------------- +6 | Value // warn | ^^^^^ | Could not transform call to scala.Enumeration.Value. | The resulting program is unlikely to function properly as this operation requires reflection. --- Error: tests/neg-scalajs/enumeration-warnings.scala:10:9 ------------------------------------------------------------ -10 | Value(4) // error +-- Warning: tests/neg-scalajs/enumeration-warnings.scala:10:9 ---------------------------------------------------------- +10 | Value(4) // warn | ^^^^^^^^ | Could not transform call to scala.Enumeration.Value. | The resulting program is unlikely to function properly as this operation requires reflection. --- Error: tests/neg-scalajs/enumeration-warnings.scala:15:15 ----------------------------------------------------------- -15 | val a = Value(null) // error +-- Warning: tests/neg-scalajs/enumeration-warnings.scala:15:15 --------------------------------------------------------- +15 | val a = Value(null) // warn | ^^^^^^^^^^^ | Passing null as name to scala.Enumeration.Value requires reflection at run-time. | The resulting program is unlikely to function properly. --- Error: tests/neg-scalajs/enumeration-warnings.scala:16:15 ----------------------------------------------------------- -16 | val b = Value(10, null) // error +-- Warning: tests/neg-scalajs/enumeration-warnings.scala:16:15 --------------------------------------------------------- +16 | val b = Value(10, null) // warn | ^^^^^^^^^^^^^^^ | Passing null as name to scala.Enumeration.Value requires reflection at run-time. | The resulting program is unlikely to function properly. --- Error: tests/neg-scalajs/enumeration-warnings.scala:20:10 ----------------------------------------------------------- -20 | val a = new Val // error +-- Warning: tests/neg-scalajs/enumeration-warnings.scala:20:10 --------------------------------------------------------- +20 | val a = new Val // warn | ^^^^^^^ | Calls to the non-string constructors of scala.Enumeration.Val require reflection at run-time. | The resulting program is unlikely to function properly. --- Error: tests/neg-scalajs/enumeration-warnings.scala:21:10 ----------------------------------------------------------- -21 | val b = new Val(10) // error +-- Warning: tests/neg-scalajs/enumeration-warnings.scala:21:10 --------------------------------------------------------- +21 | val b = new Val(10) // warn | ^^^^^^^^^^^ | Calls to the non-string constructors of scala.Enumeration.Val require reflection at run-time. | The resulting program is unlikely to function properly. --- Error: tests/neg-scalajs/enumeration-warnings.scala:25:10 ----------------------------------------------------------- -25 | val a = new Val(null) // error +-- Warning: tests/neg-scalajs/enumeration-warnings.scala:25:10 --------------------------------------------------------- +25 | val a = new Val(null) // warn | ^^^^^^^^^^^^^ | Passing null as name to a constructor of scala.Enumeration.Val requires reflection at run-time. | The resulting program is unlikely to function properly. --- Error: tests/neg-scalajs/enumeration-warnings.scala:26:10 ----------------------------------------------------------- -26 | val b = new Val(10, null) // error +-- Warning: tests/neg-scalajs/enumeration-warnings.scala:26:10 --------------------------------------------------------- +26 | val b = new Val(10, null) // warn | ^^^^^^^^^^^^^^^^^ | Passing null as name to a constructor of scala.Enumeration.Val requires reflection at run-time. | The resulting program is unlikely to function properly. --- Error: tests/neg-scalajs/enumeration-warnings.scala:30:31 ----------------------------------------------------------- -30 | protected class Val1 extends Val // error +-- Warning: tests/neg-scalajs/enumeration-warnings.scala:30:31 --------------------------------------------------------- +30 | protected class Val1 extends Val // warn | ^^^ | Calls to the non-string constructors of scala.Enumeration.Val require reflection at run-time. | The resulting program is unlikely to function properly. --- Error: tests/neg-scalajs/enumeration-warnings.scala:31:31 ----------------------------------------------------------- -31 | protected class Val2 extends Val(1) // error +-- Warning: tests/neg-scalajs/enumeration-warnings.scala:31:31 --------------------------------------------------------- +31 | protected class Val2 extends Val(1) // warn | ^^^^^^ | Calls to the non-string constructors of scala.Enumeration.Val require reflection at run-time. | The resulting program is unlikely to function properly. --- Error: tests/neg-scalajs/enumeration-warnings.scala:35:31 ----------------------------------------------------------- -35 | protected class Val1 extends Val(null) // error +-- Warning: tests/neg-scalajs/enumeration-warnings.scala:35:31 --------------------------------------------------------- +35 | protected class Val1 extends Val(null) // warn | ^^^^^^^^^ | Passing null as name to a constructor of scala.Enumeration.Val requires reflection at run-time. | The resulting program is unlikely to function properly. --- Error: tests/neg-scalajs/enumeration-warnings.scala:36:31 ----------------------------------------------------------- -36 | protected class Val2 extends Val(1, null) // error +-- Warning: tests/neg-scalajs/enumeration-warnings.scala:36:31 --------------------------------------------------------- +36 | protected class Val2 extends Val(1, null) // warn | ^^^^^^^^^^^^ | Passing null as name to a constructor of scala.Enumeration.Val requires reflection at run-time. | The resulting program is unlikely to function properly. +No warnings can be incurred under -Werror. diff --git a/tests/neg-scalajs/enumeration-warnings.scala b/tests/neg-scalajs/enumeration-warnings.scala index b48ffc9500e3..10536fef4ba6 100644 --- a/tests/neg-scalajs/enumeration-warnings.scala +++ b/tests/neg-scalajs/enumeration-warnings.scala @@ -3,35 +3,37 @@ class UnableToTransformValue extends Enumeration { val a = { println("oh, oh!") - Value // error + Value // warn } val b = { println("oh, oh!") - Value(4) // error + Value(4) // warn } } class ValueWithNullName extends Enumeration { - val a = Value(null) // error - val b = Value(10, null) // error + val a = Value(null) // warn + val b = Value(10, null) // warn } class NewValWithNoName extends Enumeration { - val a = new Val // error - val b = new Val(10) // error + val a = new Val // warn + val b = new Val(10) // warn } class NewValWithNullName extends Enumeration { - val a = new Val(null) // error - val b = new Val(10, null) // error + val a = new Val(null) // warn + val b = new Val(10, null) // warn } class ExtendsValWithNoName extends Enumeration { - protected class Val1 extends Val // error - protected class Val2 extends Val(1) // error + protected class Val1 extends Val // warn + protected class Val2 extends Val(1) // warn } class ExtendsValWithNullName extends Enumeration { - protected class Val1 extends Val(null) // error - protected class Val2 extends Val(1, null) // error + protected class Val1 extends Val(null) // warn + protected class Val2 extends Val(1, null) // warn } + +// nopos-error: No warnings can be incurred under -Werror. diff --git a/tests/patmat/i14407.dupe.check b/tests/patmat/i14407.dupe.check index b0605bcd95e5..e6f742314d98 100644 --- a/tests/patmat/i14407.dupe.check +++ b/tests/patmat/i14407.dupe.check @@ -1 +1,2 @@ 6: Match case Unreachable +0: No Kind diff --git a/tests/patmat/i18118.check b/tests/patmat/i18118.check index 8861eb273fb9..f7ad777f5e8c 100644 --- a/tests/patmat/i18118.check +++ b/tests/patmat/i18118.check @@ -2,3 +2,4 @@ 21: Pattern Match 32: Pattern Match 41: Pattern Match +0: No Kind