diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2013-12-01 15:57:52 +0100 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2013-12-01 16:09:38 +0100 |
commit | 32b756494e7a6316156e6915827ac986b91b3997 (patch) | |
tree | 8a05447d65123257dace5d1afd78c739bec837bc /src | |
parent | 073ebbd20ce9775260b83a78ecf9ed6a3e6d3d9e (diff) | |
download | scala-32b756494e7a6316156e6915827ac986b91b3997.tar.gz scala-32b756494e7a6316156e6915827ac986b91b3997.tar.bz2 scala-32b756494e7a6316156e6915827ac986b91b3997.zip |
SI-8022 Backwards compatibility for Regex#unapplySeq
The change in ce1bbfe / SI-6406 introduced overloads of
`unapplySeq` with wider static and dynmaic result types
than the now-deprecated alternative that accepted `Any`.
This is subtly source incompatible and the change was noticed
in Specs2.
This commit uses `List` as the static and runtime type for
the new overloads.
For consistency, the same is done for the new method added
in SI-7737 / 93e9623.
Diffstat (limited to 'src')
-rw-r--r-- | src/library/scala/util/matching/Regex.scala | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/library/scala/util/matching/Regex.scala b/src/library/scala/util/matching/Regex.scala index 439b30e714..22dbb37789 100644 --- a/src/library/scala/util/matching/Regex.scala +++ b/src/library/scala/util/matching/Regex.scala @@ -188,9 +188,9 @@ class Regex private[matching](val pattern: Pattern, groupNames: String*) extends * @param s The string to match * @return The matches */ - def unapplySeq(s: CharSequence): Option[Seq[String]] = { + def unapplySeq(s: CharSequence): Option[List[String]] = { val m = pattern matcher s - if (runMatcher(m)) Some(1 to m.groupCount map m.group) + if (runMatcher(m)) Some((1 to m.groupCount).toList map m.group) else None } @@ -225,10 +225,10 @@ class Regex private[matching](val pattern: Pattern, groupNames: String*) extends * @param c The Char to match * @return The match */ - def unapplySeq(c: Char): Option[Seq[Char]] = { + def unapplySeq(c: Char): Option[List[Char]] = { val m = pattern matcher c.toString if (runMatcher(m)) { - if (m.groupCount > 0) Some(m group 1) else Some(Nil) + if (m.groupCount > 0) Some((m group 1).toList) else Some(Nil) } else None } @@ -238,9 +238,9 @@ class Regex private[matching](val pattern: Pattern, groupNames: String*) extends * Otherwise, this Regex is applied to the previously matched input, * and the result of that match is used. */ - def unapplySeq(m: Match): Option[Seq[String]] = + def unapplySeq(m: Match): Option[List[String]] = if (m.matched == null) None - else if (m.matcher.pattern == this.pattern) Some(1 to m.groupCount map m.group) + else if (m.matcher.pattern == this.pattern) Some((1 to m.groupCount).toList map m.group) else unapplySeq(m.matched) /** Tries to match target. |