diff options
author | Martin Odersky <odersky@gmail.com> | 2016-08-17 17:24:09 +0200 |
---|---|---|
committer | Guillaume Martres <smarter@ubuntu.com> | 2016-08-17 15:39:14 -0700 |
commit | 0faeeba25efcae711eee75ba0bcd9682b892ee0e (patch) | |
tree | 004de09b02b49ee13da3889e3ef11c3d4b79c575 /tests/pos/spec-partialmap.scala | |
parent | 76025cd33a64e3ff9d4257f3462fcbd261a9694d (diff) | |
download | dotty-0faeeba25efcae711eee75ba0bcd9682b892ee0e.tar.gz dotty-0faeeba25efcae711eee75ba0bcd9682b892ee0e.tar.bz2 dotty-0faeeba25efcae711eee75ba0bcd9682b892ee0e.zip |
Add passing tests
Diffstat (limited to 'tests/pos/spec-partialmap.scala')
-rw-r--r-- | tests/pos/spec-partialmap.scala | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/pos/spec-partialmap.scala b/tests/pos/spec-partialmap.scala new file mode 100644 index 000000000..09684e024 --- /dev/null +++ b/tests/pos/spec-partialmap.scala @@ -0,0 +1,17 @@ + +// ticket #3378, overloaded specialized variants +import scala.collection.{Traversable,TraversableLike}; +import scala.collection.generic.CanBuildFrom; + +trait PartialMap[@specialized A,@specialized B] +extends PartialFunction[A,B] with Iterable[(A,B)] { + + // commenting out this declaration gives a different exception. + /** Getter for all values for which the given key function returns true. */ + def apply(f : (A => Boolean)) : Iterator[B] = + for ((k,v) <- iterator; if f(k)) yield v; + + // if this is commented, it compiles fine: + def apply[This <: Traversable[A], That](keys : TraversableLike[A,This]) + (implicit bf: CanBuildFrom[This, B, That]) : That = keys.map(apply); +} |