Skip to content

Commit 9e2a58b

Browse files
committed
Fix #581: add tests
1 parent 169afc8 commit 9e2a58b

File tree

6 files changed

+16
-16
lines changed

6 files changed

+16
-16
lines changed

compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,6 @@ object PatternMatcher {
262262

263263
/** Plan for matching the sequence in `getResult` against sequence elements
264264
* and a possible last varargs argument `args`.
265-
*
266-
* `getResult` could also be a product, where the last element is a sequence of elements.
267265
*/
268266
def unapplySeqPlan(getResult: Symbol, args: List[Tree]): Plan = args.lastOption match {
269267
case Some(VarArgPattern(arg)) =>

tests/pending/run/value-class-extractor-seq.check

Lines changed: 0 additions & 3 deletions
This file was deleted.

tests/pending/run/string-extractor.scala renamed to tests/run/string-extractor.scala

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,22 @@ final class StringExtract(val s: String) extends AnyVal {
66
def apply(idx: Int): Char = s charAt idx
77
def head: Char = s charAt 0
88
def tail: String = s drop 1
9-
def drop(n: Int): StringExtract = new StringExtract(s drop n)
9+
def drop(n: Int): Seq[Char] = toSeq.drop(n)
10+
def toSeq: Seq[Char] = s.toSeq
1011

1112
override def toString = s
1213
}
1314

1415
final class ThreeStringExtract(val s: String) extends AnyVal {
15-
def isEmpty = (s eq null) || (s == "")
16-
def get: (List[Int], Double, ThreeStringExtract) = ((s.length :: Nil, s.length.toDouble, this))
17-
def length = s.length
18-
def lengthCompare(n: Int) = s.length compare n
19-
def apply(idx: Int): Char = s charAt idx
20-
def head: Char = s charAt 0
21-
def tail: String = s drop 1
22-
def drop(n: Int): ThreeStringExtract = new ThreeStringExtract(s drop n)
16+
def isEmpty = (s eq null) || (s == "")
17+
def get: (List[Int], Double, Seq[Char]) = ((s.length :: Nil, s.length.toDouble, toSeq))
18+
def length = s.length
19+
def lengthCompare(n: Int) = s.length compare n
20+
def apply(idx: Int): Char = s charAt idx
21+
def head: Char = s charAt 0
22+
def tail: String = s drop 1
23+
def drop(n: Int): Seq[Char] = toSeq.drop(n)
24+
def toSeq: Seq[Char] = s.toSeq
2325

2426
override def toString = s
2527
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Bip(1, 2, 3)
2+
Bip(1, 2, c : WrappedArray(3, 4, 5): _*)
3+
class [I

tests/pending/run/value-class-extractor-seq.scala renamed to tests/run/value-class-extractor-seq.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import scala.runtime.ScalaRunTime.stringOf
22

33
final class ArrayOpt[T](val xs: Array[T]) extends AnyVal {
44
def isEmpty = xs == null
5-
def get = xs
5+
def get: Seq[T] = xs.toSeq
66
}
77

88
object Bip {
@@ -44,7 +44,7 @@ object Bip {
4444
object Test {
4545
def f(x: Any) = x match {
4646
case Bip(a, b, c) => s"Bip($a, $b, $c)"
47-
case Bip(a, b, c : _*) => s"Bip($a, $b, c @ ${stringOf(c)}: _*)"
47+
case Bip(a, b, c : _*) => s"Bip($a, $b, c : ${stringOf(c)}: _*)"
4848
case _ => "" + x.getClass
4949
}
5050

0 commit comments

Comments
 (0)