Skip to content

Commit d9e5fd4

Browse files
committed
Add test cases for -Wall
1 parent 5727187 commit d9e5fd4

File tree

6 files changed

+67
-0
lines changed

6 files changed

+67
-0
lines changed

tests/warn/i18559a.check

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
-- [E198] Unused Symbol Warning: tests/warn/i18559a.scala:4:28 ---------------------------------------------------------
2+
4 | import collection.mutable.Set // warn
3+
| ^^^
4+
| unused import
5+
-- [E198] Unused Symbol Warning: tests/warn/i18559a.scala:8:8 ----------------------------------------------------------
6+
8 | val x = 1 // warn
7+
| ^
8+
| unused local definition
9+
-- [E198] Unused Symbol Warning: tests/warn/i18559a.scala:11:26 --------------------------------------------------------
10+
11 | import SomeGivenImports.given // warn
11+
| ^^^^^
12+
| unused import

tests/warn/i18559a.scala

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//> using options -Wall
2+
// This test checks that -Wall turns on -Wunused:all if -Wunused is not set
3+
object FooImportUnused:
4+
import collection.mutable.Set // warn
5+
6+
object FooUnusedLocal:
7+
def test(): Unit =
8+
val x = 1 // warn
9+
10+
object FooGivenUnused:
11+
import SomeGivenImports.given // warn
12+
13+
object SomeGivenImports:
14+
given Int = 0
15+
given String = "foo"

tests/warn/i18559b.check

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
-- Warning: tests/warn/i18559b.scala:8:6 -------------------------------------------------------------------------------
2+
8 | val localFile: String = s"${url.##}.tmp" // warn
3+
| ^
4+
| Access non-initialized value localFile. Calling trace:
5+
| ├── class RemoteFile(url: String) extends AbstractFile: [ i18559b.scala:7 ]
6+
| │ ^
7+
| ├── abstract class AbstractFile: [ i18559b.scala:3 ]
8+
| │ ^
9+
| ├── val extension: String = name.substring(4) [ i18559b.scala:5 ]
10+
| │ ^^^^
11+
| └── def name: String = localFile [ i18559b.scala:9 ]
12+
| ^^^^^^^^^

tests/warn/i18559b.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//> using options -Wall
2+
// This test checks that -Wall turns on -Wsafe-init
3+
abstract class AbstractFile:
4+
def name: String
5+
val extension: String = name.substring(4)
6+
7+
class RemoteFile(url: String) extends AbstractFile:
8+
val localFile: String = s"${url.##}.tmp" // warn
9+
def name: String = localFile

tests/warn/i18559c.check

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-- [E198] Unused Symbol Warning: tests/warn/i18559c.scala:8:8 ----------------------------------------------------------
2+
8 | val x = 1 // warn
3+
| ^
4+
| unused local definition

tests/warn/i18559c.scala

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//> using options -Wall -Wunused:locals
2+
// This test checks that -Wall leaves -Wunused:... untouched if it is already set
3+
object FooImportUnused:
4+
import collection.mutable.Set // not warn
5+
6+
object FooUnusedLocal:
7+
def test(): Unit =
8+
val x = 1 // warn
9+
10+
object FooGivenUnused:
11+
import SomeGivenImports.given // not warn
12+
13+
object SomeGivenImports:
14+
given Int = 0
15+
given String = "foo"

0 commit comments

Comments
 (0)