Skip to content

Commit

Permalink
Add a neg test for -Wmacros:after
Browse files Browse the repository at this point in the history
  • Loading branch information
cb372 committed Mar 16, 2020
1 parent 82349a6 commit f167ae6
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/files/neg/macro-annot-unused-param.check
@@ -0,0 +1,6 @@
Test_2.scala:2: warning: parameter value x in anonymous function is never used
@mymacro
^
error: No warnings can be incurred under -Werror.
1 warning
1 error
22 changes: 22 additions & 0 deletions test/files/neg/macro-annot-unused-param/Macros_1.scala
@@ -0,0 +1,22 @@
// scalac: -Ymacro-annotations
import scala.language.experimental.macros
import scala.reflect.macros.blackbox.Context
import scala.annotation.StaticAnnotation

object Macros {
def annotImpl(c: Context)(annottees: c.Expr[Any]*): c.Expr[Any] = {
import c.universe._
val classTree = annottees.head.tree
val objectTree = q"""
object X {
def f: Int => String = { x => "hello" }
}
"""

c.Expr[Any](Block(List(classTree, objectTree), Literal(Constant(()))))
}
}

class mymacro extends StaticAnnotation {
def macroTransform(annottees: Any*): Any = macro Macros.annotImpl
}
7 changes: 7 additions & 0 deletions test/files/neg/macro-annot-unused-param/Test_2.scala
@@ -0,0 +1,7 @@
// scalac: -Ymacro-annotations -Wunused:params -Wmacros:after -Werror
@mymacro
class X

object Test {
println(X.f(123))
}

0 comments on commit f167ae6

Please sign in to comment.