summaryrefslogtreecommitdiff
path: root/src/reflect
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2014-02-01 00:19:16 +0100
committerEugene Burmako <xeno.by@gmail.com>2014-02-14 23:51:24 +0100
commit462d0b8b1c9de95baad773856a7e1f658ebd0956 (patch)
tree7d8476b9f174d53c2e68d8255a5e221c30db3e6c /src/reflect
parent8c29132055845181a34ed9077d30fac87c284574 (diff)
downloadscala-462d0b8b1c9de95baad773856a7e1f658ebd0956.tar.gz
scala-462d0b8b1c9de95baad773856a7e1f658ebd0956.tar.bz2
scala-462d0b8b1c9de95baad773856a7e1f658ebd0956.zip
adds internal.subpatterns
As per Denys’s request, this commit exposes the hack that we use to obtain subpatterns of UnApply nodes. This is useful when writing quasiquoting macros that do pattern matching.
Diffstat (limited to 'src/reflect')
-rw-r--r--src/reflect/scala/reflect/internal/Internals.scala2
-rw-r--r--src/reflect/scala/reflect/macros/Universe.scala5
2 files changed, 7 insertions, 0 deletions
diff --git a/src/reflect/scala/reflect/internal/Internals.scala b/src/reflect/scala/reflect/internal/Internals.scala
index cd2017e693..43a118217d 100644
--- a/src/reflect/scala/reflect/internal/Internals.scala
+++ b/src/reflect/scala/reflect/internal/Internals.scala
@@ -121,6 +121,8 @@ trait Internals extends api.Internals {
def annotatedType(annotations: List[Annotation], underlying: Type): AnnotatedType = self.AnnotatedType(annotations, underlying)
def typeBounds(lo: Type, hi: Type): TypeBounds = self.TypeBounds(lo, hi)
def boundedWildcardType(bounds: TypeBounds): BoundedWildcardType = self.BoundedWildcardType(bounds)
+
+ def subpatterns(tree: Tree): List[Tree] = tree.attachments.get[SubpatternsAttachment].get.patterns
}
lazy val treeBuild = new self.TreeGen {
diff --git a/src/reflect/scala/reflect/macros/Universe.scala b/src/reflect/scala/reflect/macros/Universe.scala
index 15fd6bad99..e69805cfc1 100644
--- a/src/reflect/scala/reflect/macros/Universe.scala
+++ b/src/reflect/scala/reflect/macros/Universe.scala
@@ -134,6 +134,11 @@ abstract class Universe extends scala.reflect.api.Universe {
* @group Macros
*/
def capturedVariableType(vble: Symbol): Type
+
+ /** Retrieves the untyped list of subpatterns attached to selector dummy of an UnApply node.
+ * Useful in writing quasiquoting macros that do pattern matching.
+ */
+ def subpatterns(tree: Tree): List[Tree]
}
/** @group Internal */