diff options
author | Den Shabalin <den.shabalin@gmail.com> | 2013-08-29 17:52:02 +0200 |
---|---|---|
committer | Den Shabalin <den.shabalin@gmail.com> | 2013-09-05 14:39:07 +0200 |
commit | f9d5e3d4e8cca61ee75072ab13c2935061a1850e (patch) | |
tree | c96fe138c69a5d49f9485a1424b9b72b41282c65 /src/reflect | |
parent | c637cfc01cb8258d47094fc79313a76bfdd5d268 (diff) | |
download | scala-f9d5e3d4e8cca61ee75072ab13c2935061a1850e.tar.gz scala-f9d5e3d4e8cca61ee75072ab13c2935061a1850e.tar.bz2 scala-f9d5e3d4e8cca61ee75072ab13c2935061a1850e.zip |
SI-7196 add support for refineStat splicing and extraction
Diffstat (limited to 'src/reflect')
-rw-r--r-- | src/reflect/scala/reflect/api/BuildUtils.scala | 3 | ||||
-rw-r--r-- | src/reflect/scala/reflect/internal/BuildUtils.scala | 12 | ||||
-rw-r--r-- | src/reflect/scala/reflect/internal/StdNames.scala | 6 |
3 files changed, 19 insertions, 2 deletions
diff --git a/src/reflect/scala/reflect/api/BuildUtils.scala b/src/reflect/scala/reflect/api/BuildUtils.scala index 394cbf55c5..03980f5f0a 100644 --- a/src/reflect/scala/reflect/api/BuildUtils.scala +++ b/src/reflect/scala/reflect/api/BuildUtils.scala @@ -76,6 +76,9 @@ private[reflect] trait BuildUtils { self: Universe => def mkAnnotation(tree: Tree, args: List[Tree]): Tree + def mkRefineStat(stat: Tree): Tree + + def mkRefineStat(stats: List[Tree]): List[Tree] val FlagsRepr: FlagsReprExtractor diff --git a/src/reflect/scala/reflect/internal/BuildUtils.scala b/src/reflect/scala/reflect/internal/BuildUtils.scala index 73b7b79fdb..208a61d9d3 100644 --- a/src/reflect/scala/reflect/internal/BuildUtils.scala +++ b/src/reflect/scala/reflect/internal/BuildUtils.scala @@ -76,6 +76,18 @@ trait BuildUtils { self: SymbolTable => case _ => throw new IllegalArgumentException(s"Tree ${showRaw(tree)} isn't a correct representation of annotation, consider passing Ident as a first argument") } + def mkRefineStat(stat: Tree): Tree = { + stat match { + case dd: DefDef => require(dd.rhs.isEmpty, "can't use DefDef with non-empty body as refine stat") + case vd: ValDef => require(vd.rhs.isEmpty, "can't use ValDef with non-empty rhs as refine stat") + case td: TypeDef => + case _ => throw new IllegalArgumentException(s"not legal refine stat: $stat") + } + stat + } + + def mkRefineStat(stats: List[Tree]): List[Tree] = stats.map(mkRefineStat) + object FlagsRepr extends FlagsReprExtractor { def apply(bits: Long): FlagSet = bits def unapply(flags: Long): Some[Long] = Some(flags) diff --git a/src/reflect/scala/reflect/internal/StdNames.scala b/src/reflect/scala/reflect/internal/StdNames.scala index 4811010815..eb24706f29 100644 --- a/src/reflect/scala/reflect/internal/StdNames.scala +++ b/src/reflect/scala/reflect/internal/StdNames.scala @@ -247,8 +247,9 @@ trait StdNames { final val Quasiquote: NameType = "Quasiquote" // quasiquote-specific names - final val QUASIQUOTE_MODS: NameType = "$quasiquote$mods$" - final val QUASIQUOTE_TUPLE: NameType = "$quasiquote$tuple$" + final val QUASIQUOTE_MODS: NameType = "$quasiquote$mods$" + final val QUASIQUOTE_TUPLE: NameType = "$quasiquote$tuple$" + final val QUASIQUOTE_REFINE_STAT: NameType = "$quasiquote$refine$stat$" // Annotation simple names, used in Namer final val BeanPropertyAnnot: NameType = "BeanProperty" @@ -682,6 +683,7 @@ trait StdNames { val materializeTypeTag: NameType = "materializeTypeTag" val moduleClass : NameType = "moduleClass" val mkAnnotation: NameType = "mkAnnotation" + val mkRefineStat: NameType = "mkRefineStat" val ne: NameType = "ne" val newArray: NameType = "newArray" val newFreeTerm: NameType = "newFreeTerm" |