diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2013-01-05 00:43:20 +0300 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2013-01-09 08:10:47 +0100 |
commit | baef45632a2b48c0f881f11c339fb14d1c33f6c3 (patch) | |
tree | 6742600899e41c3057aec277d0786c4317cf6548 /src/reflect/scala/reflect/internal/TreeInfo.scala | |
parent | 1077c928f9961783a9efc16dde201efe8504c092 (diff) | |
download | scala-baef45632a2b48c0f881f11c339fb14d1c33f6c3.tar.gz scala-baef45632a2b48c0f881f11c339fb14d1c33f6c3.tar.bz2 scala-baef45632a2b48c0f881f11c339fb14d1c33f6c3.zip |
changes isTermMacro checks to something more universal
Previously I wanted to be as precise as possible, but as the experience
with type macros shows, a lot of isTermMacro checks should also extend
to include type macros.
Therefore I'm changing the checks to isMacro. This doesn't make any
difference for existing code, but will reduce the amount of changes
in the upcoming type macro pull request.
Diffstat (limited to 'src/reflect/scala/reflect/internal/TreeInfo.scala')
-rw-r--r-- | src/reflect/scala/reflect/internal/TreeInfo.scala | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/reflect/scala/reflect/internal/TreeInfo.scala b/src/reflect/scala/reflect/internal/TreeInfo.scala index 9614513458..032a4aebef 100644 --- a/src/reflect/scala/reflect/internal/TreeInfo.scala +++ b/src/reflect/scala/reflect/internal/TreeInfo.scala @@ -735,4 +735,15 @@ abstract class TreeInfo { case tree: RefTree => true case _ => false }) + + def isMacroApplication(tree: Tree): Boolean = + !tree.isDef && tree.symbol != null && tree.symbol.isMacro && !tree.symbol.isErroneous + + def isMacroApplicationOrBlock(tree: Tree): Boolean = tree match { + case Block(_, expr) => isMacroApplicationOrBlock(expr) + case tree => isMacroApplication(tree) + } + + def isNonTrivialMacroApplication(tree: Tree): Boolean = + isMacroApplication(tree) && dissectApplied(tree).core != tree } |