Skip to content

Commit b9c178c

Browse files
committed
add more tests for nowarn
1 parent 17ceea2 commit b9c178c

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

tests/neg-custom-args/nowarn/nowarn.check

+24
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,27 @@ longer explanation available when compiling with `-explain`
6161
38 | @nowarn("msg=fish") // error (unused nowarn)
6262
| ^^^^^^^^^^^^^^^^^^^
6363
| @nowarn annotation does not suppress any warnings
64+
-- Error: tests/neg-custom-args/nowarn/nowarn.scala:50:0 ---------------------------------------------------------------
65+
50 |@nowarn def t9a = { 1: @nowarn; 2 } // error (outer @nowarn is unused)
66+
|^^^^^^^
67+
|@nowarn annotation does not suppress any warnings
68+
-- Error: tests/neg-custom-args/nowarn/nowarn.scala:51:27 --------------------------------------------------------------
69+
51 |@nowarn def t9b = { 1: Int @nowarn; 2 } // error (inner @nowarn is unused, it covers the type, not the expression)
70+
| ^^^^^^^
71+
| @nowarn annotation does not suppress any warnings
72+
-- Error: tests/neg-custom-args/nowarn/nowarn.scala:56:0 ---------------------------------------------------------------
73+
56 |@nowarn @ann(f) def t10b = 0 // error (unused nowarn)
74+
|^^^^^^^
75+
|@nowarn annotation does not suppress any warnings
76+
-- Error: tests/neg-custom-args/nowarn/nowarn.scala:57:8 ---------------------------------------------------------------
77+
57 |@ann(f: @nowarn) def t10c = 0 // error (unused nowarn), should be silent
78+
| ^^^^^^^
79+
| @nowarn annotation does not suppress any warnings
80+
-- Error: tests/neg-custom-args/nowarn/nowarn.scala:60:0 ---------------------------------------------------------------
81+
60 |@nowarn class I1a { // error (unused nowarn)
82+
|^^^^^^^
83+
|@nowarn annotation does not suppress any warnings
84+
-- Error: tests/neg-custom-args/nowarn/nowarn.scala:65:0 ---------------------------------------------------------------
85+
65 |@nowarn class I1b { // error (unused nowarn)
86+
|^^^^^^^
87+
|@nowarn annotation does not suppress any warnings

tests/neg-custom-args/nowarn/nowarn.scala

+30-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import annotation.nowarn
1+
import scala.annotation.{ nowarn, Annotation }
22

33
// This test doesn't run with `-Werror`, because once there's an error, later phases are skipped and we would not see
44
// their warnings.
@@ -46,3 +46,32 @@ def t8a(x: Any) = x match
4646
@nowarn("cat=unchecked") def t8(x: Any) = x match
4747
case _: List[Int] => 0
4848
case _ => 1
49+
50+
@nowarn def t9a = { 1: @nowarn; 2 } // error (outer @nowarn is unused)
51+
@nowarn def t9b = { 1: Int @nowarn; 2 } // error (inner @nowarn is unused, it covers the type, not the expression)
52+
53+
class ann(a: Any) extends Annotation
54+
55+
@ann(f) def t10a = 0 // should be a deprecation warning, but currently isn't
56+
@nowarn @ann(f) def t10b = 0 // error (unused nowarn)
57+
@ann(f: @nowarn) def t10c = 0 // error (unused nowarn), should be silent
58+
59+
def forceCompletionOfI1a = (new I1a).m
60+
@nowarn class I1a { // error (unused nowarn)
61+
@nowarn def m = { 1; 2 }
62+
}
63+
64+
// completion during type checking
65+
@nowarn class I1b { // error (unused nowarn)
66+
@nowarn def m = { 1; 2 }
67+
}
68+
69+
@nowarn class I1c {
70+
def m = { 1; 2 }
71+
}
72+
73+
trait T {
74+
@nowarn val t1 = { 0; 1 }
75+
}
76+
77+
class K extends T

0 commit comments

Comments
 (0)