diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2014-07-15 14:31:24 +0200 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2014-07-15 14:31:24 +0200 |
commit | 2a137d00faddfc3c23ba52d5d0876e974d547798 (patch) | |
tree | 7fb950d12cc1bc5b1c8a888d0c017d5acdd347e1 /test/files | |
parent | 87bba9418ca891c436f386207b3b9e70b4a64c71 (diff) | |
parent | 5ba2be24f82631f10d9163513204c5e44f445555 (diff) | |
download | scala-2a137d00faddfc3c23ba52d5d0876e974d547798.tar.gz scala-2a137d00faddfc3c23ba52d5d0876e974d547798.tar.bz2 scala-2a137d00faddfc3c23ba52d5d0876e974d547798.zip |
Merge pull request #3844 from xeno-by/topic/rangepos-subpatterns
prevents c.internal.subpatterns from destroying rangeposes
Diffstat (limited to 'test/files')
4 files changed, 25 insertions, 0 deletions
diff --git a/test/files/run/macro-rangepos-subpatterns.check b/test/files/run/macro-rangepos-subpatterns.check new file mode 100644 index 0000000000..760e15d019 --- /dev/null +++ b/test/files/run/macro-rangepos-subpatterns.check @@ -0,0 +1 @@ +The width of the subpattern is: 2 diff --git a/test/files/run/macro-rangepos-subpatterns.flags b/test/files/run/macro-rangepos-subpatterns.flags new file mode 100644 index 0000000000..fcf951d907 --- /dev/null +++ b/test/files/run/macro-rangepos-subpatterns.flags @@ -0,0 +1 @@ +-Yrangepos
\ No newline at end of file diff --git a/test/files/run/macro-rangepos-subpatterns/Macros_1.scala b/test/files/run/macro-rangepos-subpatterns/Macros_1.scala new file mode 100644 index 0000000000..0f30862347 --- /dev/null +++ b/test/files/run/macro-rangepos-subpatterns/Macros_1.scala @@ -0,0 +1,18 @@ +import scala.reflect.macros.whitebox.Context +import language.experimental.macros + +object Extractor { + def unapply(x: Any): Any = macro unapplyImpl + def unapplyImpl(c: Context)(x: c.Tree) = { + import c.universe._ + import internal._ + val pos = subpatterns(x).get.head.pos + q""" + new { + def isEmpty = false + def get = ${"The width of the subpattern is: " + (pos.end - pos.start + 1)} + def unapply(x: Any) = this + }.unapply($x) + """ + } +} diff --git a/test/files/run/macro-rangepos-subpatterns/Test_2.scala b/test/files/run/macro-rangepos-subpatterns/Test_2.scala new file mode 100644 index 0000000000..7b076e6632 --- /dev/null +++ b/test/files/run/macro-rangepos-subpatterns/Test_2.scala @@ -0,0 +1,5 @@ +object Test extends App { + 42 match { + case Extractor(a) => println(a) + } +} |