-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
only add @compileTimeOnly if it is not already defined
- Loading branch information
Showing
3 changed files
with
28 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import scala.annotation.compileTimeOnly | ||
import scala.annotation.StaticAnnotation | ||
import scala.language.experimental.macros | ||
import scala.reflect.macros.whitebox.Context | ||
|
||
object issue90Macro { | ||
def impl(c: Context)(annottees: c.Expr[Any]*): c.Expr[Any] = { | ||
import c.universe._ | ||
c.Expr(EmptyTree) | ||
} | ||
} | ||
|
||
@compileTimeOnly("this is the only annotation") | ||
final class issue90Class extends StaticAnnotation { | ||
def macroTransform(annottees: Any*): Any = macro issue90Macro.impl | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import org.scalatest.FunSuite | ||
|
||
import scala.reflect.runtime.{currentMirror => cm} | ||
|
||
class Issue90 extends FunSuite { | ||
test("compileTimeOnly annotation is not added if it is already in the class definition") { | ||
assert(cm.staticClass("issue90Class").annotations.length == 1) | ||
assert(cm.staticClass("issue90Class").annotations.head.toString == "scala.annotation.compileTimeOnly(\"this is the only annotation\")") | ||
} | ||
} |