Skip to content

Commit 69927a4

Browse files
committed
Move rest of the warn tests from neg to warn
1 parent 4d111b9 commit 69927a4

File tree

128 files changed

+928
-427
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+928
-427
lines changed

compiler/test/dotty/tools/vulpix/ParallelTesting.scala

+7-4
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
776776
end maybeFailureMessage
777777

778778
def getWarnMapAndExpectedCount(files: Seq[JFile]): (HashMap[String, Integer], Int) =
779-
val comment = raw"//( *)warn".r
779+
val comment = raw"//( *)(nopos-)?warn".r
780780
val map = new HashMap[String, Integer]()
781781
var count = 0
782782
def bump(key: String): Unit =
@@ -787,8 +787,11 @@ trait ParallelTesting extends RunnerOrchestration { self =>
787787
files.filter(isSourceFile).foreach { file =>
788788
Using(Source.fromFile(file, StandardCharsets.UTF_8.name)) { source =>
789789
source.getLines.zipWithIndex.foreach { case (line, lineNbr) =>
790-
comment.findAllMatchIn(line).foreach { _ =>
791-
bump(s"${file.getPath}:${lineNbr+1}")
790+
comment.findAllMatchIn(line).foreach { m =>
791+
m.group(2) match
792+
case "nopos-" =>
793+
bump("nopos")
794+
case _ => bump(s"${file.getPath}:${lineNbr+1}")
792795
}
793796
}
794797
}.get
@@ -809,7 +812,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
809812
val key = s"${relativize(srcpos.source.file.toString())}:${srcpos.line + 1}"
810813
if !seenAt(key) then unexpected += key
811814
else
812-
unpositioned += relativize(srcpos.source.file.toString())
815+
if(!seenAt("nopos")) unpositioned += relativize(srcpos.source.file.toString())
813816

814817
reporterWarnings.foreach(sawDiagnostic)
815818

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
-- Warning: tests/init-global/neg/context-sensitivity.scala:9:21 -------------------------------------------------------
2+
9 | def foo(): Int = A.m
3+
| ^^^
4+
| Access uninitialized field value m. Calling trace:
5+
| ├── object A: [ context-sensitivity.scala:14 ]
6+
| │ ^
7+
| ├── val m: Int = box1.value.foo() [ context-sensitivity.scala:17 ]
8+
| │ ^^^^^^^^^^^^^^^^
9+
| └── def foo(): Int = A.m [ context-sensitivity.scala:9 ]
10+
| ^^^
11+
No warnings can be incurred under -Werror.

tests/init-global/neg/context-sensitivity.scala

100755100644
+3-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class C(var x: Int) extends Foo {
66
}
77

88
class D(var y: Int) extends Foo {
9-
def foo(): Int = A.m // error
9+
def foo(): Int = A.m
1010
}
1111

1212
class Box(var value: Foo)
@@ -15,3 +15,5 @@ object A:
1515
val box1: Box = new Box(new C(5))
1616
val box2: Box = new Box(new D(10))
1717
val m: Int = box1.value.foo()
18+
19+
// nopos-error: No warnings can be incurred under -Werror.
+8-7
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1-
-- Error: tests/init-global/neg/global-cycle1.scala:1:7 ----------------------------------------------------------------
2-
1 |object A { // error
1+
-- Warning: tests/init-global/neg/global-cycle1.scala:1:7 --------------------------------------------------------------
2+
1 |object A {
33
| ^
44
| Cyclic initialization: object A -> object B -> object A. Calling trace:
5-
| ├── object A { // error [ global-cycle1.scala:1 ]
5+
| ├── object A { [ global-cycle1.scala:1 ]
66
| │ ^
77
| ├── val a: Int = B.b [ global-cycle1.scala:2 ]
88
| │ ^
99
| ├── object B { [ global-cycle1.scala:5 ]
1010
| │ ^
11-
| └── val b: Int = A.a // error [ global-cycle1.scala:6 ]
11+
| └── val b: Int = A.a [ global-cycle1.scala:6 ]
1212
| ^
13-
-- Error: tests/init-global/neg/global-cycle1.scala:6:17 ---------------------------------------------------------------
14-
6 | val b: Int = A.a // error
13+
-- Warning: tests/init-global/neg/global-cycle1.scala:6:17 -------------------------------------------------------------
14+
6 | val b: Int = A.a
1515
| ^^^
1616
| Access uninitialized field value a. Calling trace:
1717
| ├── object B { [ global-cycle1.scala:5 ]
1818
| │ ^
19-
| └── val b: Int = A.a // error [ global-cycle1.scala:6 ]
19+
| └── val b: Int = A.a [ global-cycle1.scala:6 ]
2020
| ^^^
21+
No warnings can be incurred under -Werror.
+4-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
object A { // error
1+
object A {
22
val a: Int = B.b
33
}
44

55
object B {
6-
val b: Int = A.a // error
6+
val b: Int = A.a
77
}
88

99
@main
1010
def Test = print(A.a)
11+
12+
// nopos-error: No warnings can be incurred under -Werror.
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
-- Warning: tests/init-global/neg/global-cycle14.scala:8:7 -------------------------------------------------------------
2+
8 |object A {
3+
| ^
4+
| Cyclic initialization: object A -> object B -> object A. Calling trace:
5+
| ├── object A { [ global-cycle14.scala:8 ]
6+
| │ ^
7+
| ├── val n: Int = B.m [ global-cycle14.scala:9 ]
8+
| │ ^
9+
| ├── object B { [ global-cycle14.scala:12 ]
10+
| │ ^
11+
| └── val m: Int = A.n [ global-cycle14.scala:13 ]
12+
| ^
13+
-- Warning: tests/init-global/neg/global-cycle14.scala:13:17 -----------------------------------------------------------
14+
13 | val m: Int = A.n
15+
| ^^^
16+
| Access uninitialized field value n. Calling trace:
17+
| ├── object B { [ global-cycle14.scala:12 ]
18+
| │ ^
19+
| └── val m: Int = A.n [ global-cycle14.scala:13 ]
20+
| ^^^
21+
No warnings can be incurred under -Werror.

tests/init-global/neg/global-cycle14.scala

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ object O {
55
val d = Data(3)
66
}
77

8-
object A { // error
8+
object A {
99
val n: Int = B.m
1010
}
1111

1212
object B {
13-
val m: Int = A.n // error
13+
val m: Int = A.n
1414
}
15+
16+
// nopos-error: No warnings can be incurred under -Werror.
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
-- Warning: tests/init-global/neg/global-cycle2.scala:6:21 -------------------------------------------------------------
2+
6 | def foo(): Int = A.a * 2
3+
| ^^^
4+
| Access uninitialized field value a. Calling trace:
5+
| ├── object A { [ global-cycle2.scala:1 ]
6+
| │ ^
7+
| ├── val a: Int = B.foo() [ global-cycle2.scala:2 ]
8+
| │ ^^^^^^^
9+
| └── def foo(): Int = A.a * 2 [ global-cycle2.scala:6 ]
10+
| ^^^
11+
No warnings can be incurred under -Werror.

tests/init-global/neg/global-cycle2.scala

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@ object A {
33
}
44

55
object B {
6-
def foo(): Int = A.a * 2 // error
6+
def foo(): Int = A.a * 2
77
}
8+
9+
// nopos-error: No warnings can be incurred under -Werror.
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
-- Warning: tests/init-global/neg/global-cycle3.scala:2:21 -------------------------------------------------------------
2+
2 | def foo(): Int = B.a + 10
3+
| ^^^
4+
| Access uninitialized field value a. Calling trace:
5+
| ├── object B { [ global-cycle3.scala:5 ]
6+
| │ ^
7+
| ├── val a: Int = A(4).foo() [ global-cycle3.scala:6 ]
8+
| │ ^^^^^^^^^^
9+
| └── def foo(): Int = B.a + 10 [ global-cycle3.scala:2 ]
10+
| ^^^
11+
No warnings can be incurred under -Werror.
+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
class A(x: Int) {
2-
def foo(): Int = B.a + 10 // error
2+
def foo(): Int = B.a + 10
33
}
44

55
object B {
66
val a: Int = A(4).foo()
77
}
8+
9+
// nopos-error: No warnings can be incurred under -Werror.
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
-- Warning: tests/init-global/neg/global-cycle4.scala:10:21 ------------------------------------------------------------
2+
10 | def foo(): Int = O.a + 10
3+
| ^^^
4+
| Access uninitialized field value a. Calling trace:
5+
| ├── object O { [ global-cycle4.scala:17 ]
6+
| │ ^
7+
| ├── val a: Int = D(5).bar().foo() [ global-cycle4.scala:18 ]
8+
| │ ^^^^^^^^^^^^^^^^
9+
| └── def foo(): Int = O.a + 10 [ global-cycle4.scala:10 ]
10+
| ^^^
11+
No warnings can be incurred under -Werror.

tests/init-global/neg/global-cycle4.scala

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class B extends A {
77
}
88

99
class C extends A {
10-
def foo(): Int = O.a + 10 // error
10+
def foo(): Int = O.a + 10
1111
}
1212

1313
class D(x: Int) {
@@ -17,3 +17,5 @@ class D(x: Int) {
1717
object O {
1818
val a: Int = D(5).bar().foo()
1919
}
20+
21+
// nopos-error: No warnings can be incurred under -Werror.
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
-- Warning: tests/init-global/neg/global-cycle5.scala:10:17 ------------------------------------------------------------
2+
10 | val b: Int = A.a.foo()
3+
| ^^^
4+
|Reading mutable state of object A during initialization of object B.
5+
|Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace:
6+
|├── object B { [ global-cycle5.scala:9 ]
7+
|│ ^
8+
|└── val b: Int = A.a.foo() [ global-cycle5.scala:10 ]
9+
| ^^^
10+
No warnings can be incurred under -Werror.

tests/init-global/neg/global-cycle5.scala

100755100644
+3-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ object A {
77
}
88

99
object B {
10-
val b: Int = A.a.foo() // error
10+
val b: Int = A.a.foo()
1111
}
1212

1313
class Y extends X {
@@ -20,4 +20,5 @@ object C {
2020

2121
def main = {
2222
A.a = new Y(); C
23-
}
23+
}
24+
// nopos-error: No warnings can be incurred under -Werror.
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
-- Warning: tests/init-global/neg/global-cycle6.scala:1:7 --------------------------------------------------------------
2+
1 |object A {
3+
| ^
4+
| Cyclic initialization: object A -> object B -> object A. Calling trace:
5+
| ├── object A { [ global-cycle6.scala:1 ]
6+
| │ ^
7+
| ├── val n: Int = B.m [ global-cycle6.scala:2 ]
8+
| │ ^
9+
| ├── object B { [ global-cycle6.scala:8 ]
10+
| │ ^
11+
| ├── val a = new A.Inner [ global-cycle6.scala:9 ]
12+
| │ ^^^^^^^^^^^
13+
| ├── class Inner { [ global-cycle6.scala:3 ]
14+
| │ ^
15+
| └── println(n) [ global-cycle6.scala:4 ]
16+
| ^
17+
-- Warning: tests/init-global/neg/global-cycle6.scala:4:12 -------------------------------------------------------------
18+
4 | println(n)
19+
| ^
20+
| Access uninitialized field value n. Calling trace:
21+
| ├── object B { [ global-cycle6.scala:8 ]
22+
| │ ^
23+
| ├── val a = new A.Inner [ global-cycle6.scala:9 ]
24+
| │ ^^^^^^^^^^^
25+
| ├── class Inner { [ global-cycle6.scala:3 ]
26+
| │ ^
27+
| └── println(n) [ global-cycle6.scala:4 ]
28+
| ^
29+
No warnings can be incurred under -Werror.

tests/init-global/neg/global-cycle6.scala

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
object A { // error
1+
object A {
22
val n: Int = B.m
33
class Inner {
4-
println(n) // error
4+
println(n)
55
}
66
}
77

@@ -22,4 +22,5 @@ object O {
2222
val a = new A.Inner
2323
val m: Int = 10
2424
}
25-
}
25+
}
26+
// nopos-error: No warnings can be incurred under -Werror.
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
-- Warning: tests/init-global/neg/global-cycle7.scala:1:7 --------------------------------------------------------------
2+
1 |object A {
3+
| ^
4+
| Cyclic initialization: object A -> object B -> object A. Calling trace:
5+
| ├── object A { [ global-cycle7.scala:1 ]
6+
| │ ^
7+
| ├── val n: Int = B.m [ global-cycle7.scala:2 ]
8+
| │ ^
9+
| ├── object B { [ global-cycle7.scala:5 ]
10+
| │ ^
11+
| └── val m: Int = A.n [ global-cycle7.scala:6 ]
12+
| ^
13+
-- Warning: tests/init-global/neg/global-cycle7.scala:6:17 -------------------------------------------------------------
14+
6 | val m: Int = A.n
15+
| ^^^
16+
| Access uninitialized field value n. Calling trace:
17+
| ├── object B { [ global-cycle7.scala:5 ]
18+
| │ ^
19+
| └── val m: Int = A.n [ global-cycle7.scala:6 ]
20+
| ^^^
21+
No warnings can be incurred under -Werror.

tests/init-global/neg/global-cycle7.scala

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
object A { // error
1+
object A {
22
val n: Int = B.m
33
}
44

55
object B {
6-
val m: Int = A.n // error
6+
val m: Int = A.n
77
}
88

99
abstract class TokensCommon {
@@ -16,3 +16,5 @@ object JavaTokens extends TokensCommon {
1616
final def maxToken: Int = DOUBLE
1717
final val DOUBLE = 188
1818
}
19+
20+
// nopos-error: No warnings can be incurred under -Werror.
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
-- Warning: tests/init-global/neg/global-cycle8.scala:9:7 --------------------------------------------------------------
2+
9 |object O {
3+
| ^
4+
| Cyclic initialization: object O -> object P -> object O. Calling trace:
5+
| ├── object O { [ global-cycle8.scala:9 ]
6+
| │ ^
7+
| ├── println(P.m) [ global-cycle8.scala:11 ]
8+
| │ ^
9+
| ├── object P { [ global-cycle8.scala:14 ]
10+
| │ ^
11+
| ├── val m = Q.bar(new B) [ global-cycle8.scala:15 ]
12+
| │ ^^^^^^^^^^^^
13+
| ├── def bar(b: B) = b.a.foo() [ global-cycle8.scala:19 ]
14+
| │ ^^^^^^^^^
15+
| └── def foo() = println(O.n) [ global-cycle8.scala:2 ]
16+
| ^
17+
No warnings can be incurred under -Werror.

tests/init-global/neg/global-cycle8.scala

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class B {
66
val a = new A
77
}
88

9-
object O { // error
9+
object O {
1010
val n: Int = 10
1111
println(P.m)
1212
}
@@ -18,3 +18,5 @@ object P {
1818
object Q {
1919
def bar(b: B) = b.a.foo()
2020
}
21+
22+
// nopos-error: No warnings can be incurred under -Werror.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
-- Warning: tests/init-global/neg/global-irrelevance1.scala:5:12 -------------------------------------------------------
2+
5 | var y = A.x * 2
3+
| ^^^
4+
|Reading mutable state of object A during initialization of object B.
5+
|Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace:
6+
|├── object B: [ global-irrelevance1.scala:4 ]
7+
|│ ^
8+
|└── var y = A.x * 2 [ global-irrelevance1.scala:5 ]
9+
| ^^^
10+
No warnings can be incurred under -Werror.

tests/init-global/neg/global-irrelevance1.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ object A:
22
var x = 6
33

44
object B:
5-
var y = A.x * 2 // error
5+
var y = A.x * 2
6+
// nopos-error: No warnings can be incurred under -Werror.

0 commit comments

Comments
 (0)