Skip to content

Commit 749fc3c

Browse files
committed
Fixed warn tests for init-global
1 parent a452a73 commit 749fc3c

File tree

99 files changed

+299
-383
lines changed

Some content is hidden

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

99 files changed

+299
-383
lines changed

compiler/test/dotty/tools/dotc/CompilationTests.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ class CompilationTests {
216216
@Test def checkInitGlobal: Unit = {
217217
implicit val testGroup: TestGroup = TestGroup("checkInitGlobal")
218218
val options = defaultOptions.and("-Ysafe-init-global", "-Xfatal-warnings")
219-
compileFilesInDir("tests/init-global/neg", options, FileFilter.exclude(TestSources.negInitGlobalScala2LibraryTastyBlacklisted)).checkExpectedErrors()
220219
compileFilesInDir("tests/init-global/warn", defaultOptions.and("-Ysafe-init-global"), FileFilter.exclude(TestSources.negInitGlobalScala2LibraryTastyBlacklisted)).checkWarnings()
221220
compileFilesInDir("tests/init-global/pos", options, FileFilter.exclude(TestSources.posInitGlobalScala2LibraryTastyBlacklisted)).checkCompile()
222221
}
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
-- Warning: tests/init-global/neg/global-cycle1.scala:1:7 --------------------------------------------------------------
2-
1 |object A {
1+
-- Warning: tests/init-global/warn/global-cycle1.scala:1:7 -------------------------------------------------------------
2+
1 |object A { // warn
33
| ^
44
| Cyclic initialization: object A -> object B -> object A. Calling trace:
5-
| ├── object A { [ global-cycle1.scala:1 ]
5+
| ├── object A { // warn [ 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 [ global-cycle1.scala:6 ]
11+
| └── val b: Int = A.a // warn [ global-cycle1.scala:6 ]
1212
| ^
13-
-- Warning: tests/init-global/neg/global-cycle1.scala:6:17 -------------------------------------------------------------
14-
6 | val b: Int = A.a
13+
-- Warning: tests/init-global/warn/global-cycle1.scala:6:17 ------------------------------------------------------------
14+
6 | val b: Int = A.a // warn
1515
| ^^^
1616
| Access uninitialized field value a. Calling trace:
1717
| ├── object B { [ global-cycle1.scala:5 ]
1818
| │ ^
19-
| └── val b: Int = A.a [ global-cycle1.scala:6 ]
19+
| └── val b: Int = A.a // warn [ global-cycle1.scala:6 ]
2020
| ^^^
21-
No warnings can be incurred under -Werror.
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
object A {
1+
object A { // warn
22
val a: Int = B.b
33
}
44

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

99
@main
1010
def Test = print(A.a)
11-
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
-- Warning: tests/init-global/neg/global-cycle14.scala:8:7 -------------------------------------------------------------
2-
8 |object A {
1+
-- Warning: tests/init-global/warn/global-cycle14.scala:8:7 ------------------------------------------------------------
2+
8 |object A { // warn
33
| ^
44
| Cyclic initialization: object A -> object B -> object A. Calling trace:
5-
| ├── object A { [ global-cycle14.scala:8 ]
5+
| ├── object A { // warn [ global-cycle14.scala:8 ]
66
| │ ^
77
| ├── val n: Int = B.m [ global-cycle14.scala:9 ]
88
| │ ^
99
| ├── object B { [ global-cycle14.scala:12 ]
1010
| │ ^
11-
| └── val m: Int = A.n [ global-cycle14.scala:13 ]
11+
| └── val m: Int = A.n // warn [ global-cycle14.scala:13 ]
1212
| ^
13-
-- Warning: tests/init-global/neg/global-cycle14.scala:13:17 -----------------------------------------------------------
14-
13 | val m: Int = A.n
13+
-- Warning: tests/init-global/warn/global-cycle14.scala:13:17 ----------------------------------------------------------
14+
13 | val m: Int = A.n // warn
1515
| ^^^
1616
| Access uninitialized field value n. Calling trace:
1717
| ├── object B { [ global-cycle14.scala:12 ]
1818
| │ ^
19-
| └── val m: Int = A.n [ global-cycle14.scala:13 ]
19+
| └── val m: Int = A.n // warn [ global-cycle14.scala:13 ]
2020
| ^^^
21-
No warnings can be incurred under -Werror.

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@ object O {
55
val d = Data(3)
66
}
77

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

1212
object B {
13-
val m: Int = A.n
13+
val m: Int = A.n // warn
1414
}
15-
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
-- Warning: tests/init-global/neg/global-cycle2.scala:6:21 -------------------------------------------------------------
2-
6 | def foo(): Int = A.a * 2
1+
-- Warning: tests/init-global/warn/global-cycle2.scala:6:21 ------------------------------------------------------------
2+
6 | def foo(): Int = A.a * 2 // warn
33
| ^^^
44
| Access uninitialized field value a. Calling trace:
55
| ├── object A { [ global-cycle2.scala:1 ]
66
| │ ^
77
| ├── val a: Int = B.foo() [ global-cycle2.scala:2 ]
88
| │ ^^^^^^^
9-
| └── def foo(): Int = A.a * 2 [ global-cycle2.scala:6 ]
9+
| └── def foo(): Int = A.a * 2 // warn [ global-cycle2.scala:6 ]
1010
| ^^^
11-
No warnings can be incurred under -Werror.

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,5 @@ object A {
33
}
44

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

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

0 commit comments

Comments
 (0)