summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSom Snytt <som.snytt@gmail.com>2013-05-12 12:09:12 -0700
committerSom Snytt <som.snytt@gmail.com>2013-05-12 12:09:12 -0700
commit135cfa88814ea5391c50bdeb2b2aaadfebd6da67 (patch)
treef6fae022488347aa44d21eb45d5ead888584d1ee /src
parentda91728a0b1d5e449eb13b697993d056e7ad53d6 (diff)
downloadscala-135cfa88814ea5391c50bdeb2b2aaadfebd6da67.tar.gz
scala-135cfa88814ea5391c50bdeb2b2aaadfebd6da67.tar.bz2
scala-135cfa88814ea5391c50bdeb2b2aaadfebd6da67.zip
SI-6406 Restore deprecated API
The original patch for SI-6406 was intended for 2.10 but during those volatile weeks of early autumn, it missed the boat. A deprecated method was incorrectly tagged at 2.10 and later removed; this restores the method and its test, and resets the deprecation clock to 2.11. The deprecation tool should confirm that changes occur on the git timeline as claimed.
Diffstat (limited to 'src')
-rw-r--r--src/library/scala/util/matching/Regex.scala14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/library/scala/util/matching/Regex.scala b/src/library/scala/util/matching/Regex.scala
index 8d135ecf02..8eac0a2520 100644
--- a/src/library/scala/util/matching/Regex.scala
+++ b/src/library/scala/util/matching/Regex.scala
@@ -205,6 +205,20 @@ class Regex private[matching](val pattern: Pattern, groupNames: String*) extends
else if (m.matcher.pattern == this.pattern) Some(1 to m.groupCount map m.group)
else unapplySeq(m.matched)
+ /** Tries to match target.
+ * @param target The string to match
+ * @return The matches
+ */
+ @deprecated("Extracting a match result from anything but a CharSequence or Match is deprecated", "2.11.0")
+ def unapplySeq(target: Any): Option[List[String]] = target match {
+ case s: CharSequence =>
+ val m = pattern matcher s
+ if (runMatcher(m)) Some((1 to m.groupCount).toList map m.group)
+ else None
+ case m: Match => unapplySeq(m.matched)
+ case _ => None
+ }
+
// @see UnanchoredRegex
protected def runMatcher(m: Matcher) = m.matches()