Skip to content

Commit 3f2b437

Browse files
committed
Move nowarn test to warns, update check
1 parent 0bdc468 commit 3f2b437

File tree

4 files changed

+193
-199
lines changed

4 files changed

+193
-199
lines changed

tests/neg/nowarn.check

Lines changed: 0 additions & 110 deletions
This file was deleted.

tests/neg/nowarn.scala

Lines changed: 0 additions & 89 deletions
This file was deleted.

tests/warn/nowarn.check

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
-- [E002] Syntax Warning: tests/warn/nowarn.scala:5:10 -----------------------------------------------------------------
2+
5 |def t1a = try 1 // warn (parser)
3+
| ^^^^^
4+
| A try without catch or finally is equivalent to putting
5+
| its body in a block; no exceptions are handled.
6+
|
7+
| longer explanation available when compiling with `-explain`
8+
-- [E002] Syntax Warning: tests/warn/nowarn.scala:19:25 ----------------------------------------------------------------
9+
19 |@nowarn(o.inl) def t2d = try 1 // warn // warn (`inl` is not a compile-time constant)
10+
| ^^^^^
11+
| A try without catch or finally is equivalent to putting
12+
| its body in a block; no exceptions are handled.
13+
|
14+
| longer explanation available when compiling with `-explain`
15+
-- [E002] Syntax Warning: tests/warn/nowarn.scala:27:26 ----------------------------------------------------------------
16+
27 |@nowarn("id=1") def t4d = try 1 // warn // warn (unused nowarn, wrong id)
17+
| ^^^^^
18+
| A try without catch or finally is equivalent to putting
19+
| its body in a block; no exceptions are handled.
20+
|
21+
| longer explanation available when compiling with `-explain`
22+
-- [E002] Syntax Warning: tests/warn/nowarn.scala:29:28 ----------------------------------------------------------------
23+
29 |@nowarn("verbose") def t5 = try 1 // warn with details
24+
| ^^^^^
25+
| A try without catch or finally is equivalent to putting
26+
| its body in a block; no exceptions are handled.
27+
|Matching filters for @nowarn or -Wconf:
28+
| - id=E2
29+
| - name=EmptyCatchAndFinallyBlock
30+
|
31+
| longer explanation available when compiling with `-explain`
32+
-- [E129] Potential Issue Warning: tests/warn/nowarn.scala:9:11 --------------------------------------------------------
33+
9 |def t2 = { 1; 2 } // warn (the invalid nowarn doesn't silence anything)
34+
| ^
35+
| A pure expression does nothing in statement position
36+
|
37+
| longer explanation available when compiling with `-explain`
38+
-- Warning: tests/warn/nowarn.scala:8:8 --------------------------------------------------------------------------------
39+
8 |@nowarn("wat?") // warn (typer, invalid filter)
40+
| ^^^^^^
41+
| Invalid message filter
42+
| unknown filter: wat?
43+
-- [E129] Potential Issue Warning: tests/warn/nowarn.scala:12:12 -------------------------------------------------------
44+
12 |def t2a = { 1; 2 } // warn (invalid nowarn doesn't silence)
45+
| ^
46+
| A pure expression does nothing in statement position
47+
|
48+
| longer explanation available when compiling with `-explain`
49+
-- Warning: tests/warn/nowarn.scala:11:8 -------------------------------------------------------------------------------
50+
11 |@nowarn(t1a.toString) // warn (typer, argument not a compile-time constant)
51+
| ^^^^^^^^^^^^
52+
| filter needs to be a compile-time constant string
53+
-- Warning: tests/warn/nowarn.scala:19:10 ------------------------------------------------------------------------------
54+
19 |@nowarn(o.inl) def t2d = try 1 // warn // warn (`inl` is not a compile-time constant)
55+
| ^^^^^
56+
| filter needs to be a compile-time constant string
57+
-- Deprecation Warning: tests/warn/nowarn.scala:33:10 ------------------------------------------------------------------
58+
33 |def t6a = f // warn (refchecks, deprecation)
59+
| ^
60+
| method f is deprecated
61+
-- Deprecation Warning: tests/warn/nowarn.scala:36:30 ------------------------------------------------------------------
62+
36 |@nowarn("msg=fish") def t6d = f // warn (unused nowarn) // warn (deprecation)
63+
| ^
64+
| method f is deprecated
65+
-- Deprecation Warning: tests/warn/nowarn.scala:43:10 ------------------------------------------------------------------
66+
43 |def t7c = f // warn (deprecation)
67+
| ^
68+
| method f is deprecated
69+
-- [E092] Pattern Match Unchecked Warning: tests/warn/nowarn.scala:49:7 ------------------------------------------------
70+
49 | case _: List[Int] => 0 // warn (patmat, unchecked)
71+
| ^
72+
|the type test for List[Int] cannot be checked at runtime because its type arguments can't be determined from Any
73+
|
74+
| longer explanation available when compiling with `-explain`
75+
-- Warning: tests/warn/nowarn.scala:27:1 -------------------------------------------------------------------------------
76+
27 |@nowarn("id=1") def t4d = try 1 // warn // warn (unused nowarn, wrong id)
77+
|^^^^^^^^^^^^^^^
78+
|@nowarn annotation does not suppress any warnings
79+
-- Warning: tests/warn/nowarn.scala:36:1 -------------------------------------------------------------------------------
80+
36 |@nowarn("msg=fish") def t6d = f // warn (unused nowarn) // warn (deprecation)
81+
|^^^^^^^^^^^^^^^^^^^
82+
|@nowarn annotation does not suppress any warnings
83+
-- Warning: tests/warn/nowarn.scala:44:5 -------------------------------------------------------------------------------
84+
44 | : @nowarn("msg=fish") // warn (unused nowarn)
85+
| ^^^^^^^^^^^^^^^^^^^
86+
| @nowarn annotation does not suppress any warnings
87+
-- Warning: tests/warn/nowarn.scala:56:0 -------------------------------------------------------------------------------
88+
56 |@nowarn def t9a = { 1: @nowarn; 2 } // warn (outer @nowarn is unused)
89+
|^^^^^^^
90+
|@nowarn annotation does not suppress any warnings but matches a diagnostic
91+
-- Warning: tests/warn/nowarn.scala:57:27 ------------------------------------------------------------------------------
92+
57 |@nowarn def t9b = { 1: Int @nowarn; 2 } // warn (inner @nowarn is unused, it covers the type, not the expression)
93+
| ^^^^^^^
94+
| @nowarn annotation does not suppress any warnings
95+
-- Warning: tests/warn/nowarn.scala:62:0 -------------------------------------------------------------------------------
96+
62 |@nowarn @ann(f) def t10b = 0 // warn (unused nowarn)
97+
|^^^^^^^
98+
|@nowarn annotation does not suppress any warnings
99+
-- Warning: tests/warn/nowarn.scala:63:8 -------------------------------------------------------------------------------
100+
63 |@ann(f: @nowarn) def t10c = 0 // warn (unused nowarn), should be silent
101+
| ^^^^^^^
102+
| @nowarn annotation does not suppress any warnings
103+
-- Warning: tests/warn/nowarn.scala:66:0 -------------------------------------------------------------------------------
104+
66 |@nowarn class I1a { // warn (unused nowarn)
105+
|^^^^^^^
106+
|@nowarn annotation does not suppress any warnings but matches a diagnostic
107+
-- Warning: tests/warn/nowarn.scala:71:0 -------------------------------------------------------------------------------
108+
71 |@nowarn class I1b { // warn (unused nowarn)
109+
|^^^^^^^
110+
|@nowarn annotation does not suppress any warnings but matches a diagnostic

tests/warn/nowarn.scala

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
//> using options -deprecation -Wunused:nowarn
2+
3+
import scala.annotation.{nowarn, Annotation}
4+
5+
def t1a = try 1 // warn (parser)
6+
@nowarn("msg=try without catch") def t1b = try 1
7+
8+
@nowarn("wat?") // warn (typer, invalid filter)
9+
def t2 = { 1; 2 } // warn (the invalid nowarn doesn't silence anything)
10+
11+
@nowarn(t1a.toString) // warn (typer, argument not a compile-time constant)
12+
def t2a = { 1; 2 } // warn (invalid nowarn doesn't silence)
13+
14+
object o:
15+
final val const = "msg=try"
16+
inline def inl = "msg=try"
17+
18+
@nowarn(o.const) def t2c = try 1 // no warn
19+
@nowarn(o.inl) def t2d = try 1 // warn // warn (`inl` is not a compile-time constant)
20+
21+
@nowarn("id=E129") def t3a = { 1; 2 }
22+
@nowarn("name=PureExpressionInStatementPosition") def t3b = { 1; 2 }
23+
24+
@nowarn("id=E002") def t4a = try 1
25+
@nowarn("id=E2") def t4b = try 1
26+
@nowarn("id=2") def t4c = try 1
27+
@nowarn("id=1") def t4d = try 1 // warn // warn (unused nowarn, wrong id)
28+
29+
@nowarn("verbose") def t5 = try 1 // warn with details
30+
31+
@deprecated def f = 0
32+
33+
def t6a = f // warn (refchecks, deprecation)
34+
@nowarn("cat=deprecation") def t6b = f
35+
@nowarn("msg=deprecated") def t6c = f
36+
@nowarn("msg=fish") def t6d = f // warn (unused nowarn) // warn (deprecation)
37+
@nowarn("") def t6e = f
38+
@nowarn def t6f = f
39+
40+
def t7a = f: @nowarn("cat=deprecation")
41+
def t7b = f
42+
: @nowarn("msg=deprecated")
43+
def t7c = f // warn (deprecation)
44+
: @nowarn("msg=fish") // warn (unused nowarn)
45+
def t7d = f: @nowarn("")
46+
def t7e = f: @nowarn
47+
48+
def t8a(x: Any) = x match
49+
case _: List[Int] => 0 // warn (patmat, unchecked)
50+
case _ => 1
51+
52+
@nowarn("cat=unchecked") def t8(x: Any) = x match
53+
case _: List[Int] => 0
54+
case _ => 1
55+
56+
@nowarn def t9a = { 1: @nowarn; 2 } // warn (outer @nowarn is unused)
57+
@nowarn def t9b = { 1: Int @nowarn; 2 } // warn (inner @nowarn is unused, it covers the type, not the expression)
58+
59+
class ann(a: Any) extends Annotation
60+
61+
@ann(f) def t10a = 0 // should be a deprecation warning, but currently isn't
62+
@nowarn @ann(f) def t10b = 0 // warn (unused nowarn)
63+
@ann(f: @nowarn) def t10c = 0 // warn (unused nowarn), should be silent
64+
65+
def forceCompletionOfI1a = (new I1a).m
66+
@nowarn class I1a { // warn (unused nowarn)
67+
@nowarn def m = { 1; 2 }
68+
}
69+
70+
// completion during type checking
71+
@nowarn class I1b { // warn (unused nowarn)
72+
@nowarn def m = { 1; 2 }
73+
}
74+
75+
@nowarn class I1c {
76+
def m = { 1; 2 }
77+
}
78+
79+
trait T {
80+
@nowarn val t1 = { 0; 1 }
81+
}
82+
83+
class K extends T

0 commit comments

Comments
 (0)