Skip to content

Commit

Permalink
test for silent annotation with macros
Browse files Browse the repository at this point in the history
  • Loading branch information
lrytz committed Sep 9, 2019
1 parent 04fe4b9 commit 5edc810
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/files/neg/silentWarningsMacros.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Test_2.scala:10: warning: a pure expression does nothing in statement position; multiline expressions might require enclosing parentheses
1 // warn
^
Test_2.scala:19: warning: a pure expression does nothing in statement position; multiline expressions might require enclosing parentheses
1 // warn
^
Test_2.scala:28: warning: a pure expression does nothing in statement position; multiline expressions might require enclosing parentheses
1 // warn
^
error: No warnings can be incurred under -Werror.
three warnings found
one error found
8 changes: 8 additions & 0 deletions test/files/neg/silentWarningsMacros/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import scala.reflect.macros.blackbox.Context

object Macro {
def discard(c: Context)(expr: c.Expr[Any]): c.Tree = {
import c.universe._
q"()"
}
}
35 changes: 35 additions & 0 deletions test/files/neg/silentWarningsMacros/Test_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// scalac: -Werror

import language.experimental.macros
import scala.annotation.silent

object Test {
def discard(expr: Any): Unit = macro Macro.discard

def t1a = discard {
1 // warn
2
}
def t1b = discard {
1: @silent
2
}

def t2a = discard {
1 // warn
2
}
@silent def t2b = discard {
1
2
}

def t3a = discard {
1 // warn
2
}
def t3b = discard {
1 // warn
2
}: @silent
}

0 comments on commit 5edc810

Please sign in to comment.