diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/Definitions.scala | 1 | ||||
-rw-r--r-- | src/library/scala/annotation/experimental.scala | 16 | ||||
-rw-r--r-- | src/library/scala/collection/generic/TraversableTemplate.scala | 14 |
3 files changed, 31 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala index ad0efdec11..af158f27d4 100644 --- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala +++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala @@ -170,6 +170,7 @@ trait Definitions { lazy val UncheckedClass: Symbol = getClass("scala.unchecked") lazy val TailrecClass: Symbol = getClass("scala.annotation.tailrec") lazy val SwitchClass: Symbol = getClass("scala.annotation.switch") + lazy val ExperimentalClass: Symbol = getClass("scala.annotation.experimental") var EqualsPatternClass: Symbol = _ diff --git a/src/library/scala/annotation/experimental.scala b/src/library/scala/annotation/experimental.scala new file mode 100644 index 0000000000..b33d9ea246 --- /dev/null +++ b/src/library/scala/annotation/experimental.scala @@ -0,0 +1,16 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ +package scala.annotation + +/** <p> + * An annotation for experimental features. + * </p> + */ +final class experimental(message: String) extends StaticAnnotation { + def this() = this("") +}
\ No newline at end of file diff --git a/src/library/scala/collection/generic/TraversableTemplate.scala b/src/library/scala/collection/generic/TraversableTemplate.scala index 64017b06aa..e053ab4cb4 100644 --- a/src/library/scala/collection/generic/TraversableTemplate.scala +++ b/src/library/scala/collection/generic/TraversableTemplate.scala @@ -13,6 +13,7 @@ package scala.collection.generic // import immutable.{List, Stream, Nil} //!!! import mutable.{Buffer, ArrayBuffer, ListBuffer} +import annotation.experimental /** A template trait for traversable collections. * This is a base trait of all kinds of Scala collections. It implements @@ -180,6 +181,19 @@ self => b.result } + /** Returns a new traversable based on the partial function <code>pf</code>, + * containing pf(x) for all the elements which are defined on pf. + * The order of the elements is preserved. + * @param pf the partial function which filters and maps the traversable. + * @return the new traversable. + */ + @experimental + def filterMap[B, That](pf: PartialFunction[Any, B])(implicit bf: BuilderFactory[B, That, This]): That = { + val b = bf(thisCollection) + for (x <- this) if (pf.isDefinedAt(x)) b += pf(x) + b.result + } + /** Returns a traversable with all elements of this traversable which do not satisfy the predicate * <code>p</code>. * |