Scala Programming Language
  1. Scala Programming Language
  2. SI-6924

Error in IsTraversableLike scaladoc example

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Scala 2.10.0
    • Fix Version/s: Scala 2.10.1
    • Component/s: Documentation and API
    • Labels:
      None

      Description

      The header example is

      class FilterMapImpl[A, Repr](val r: GenTraversableLike[A, Repr]) {
        final def filterMap[B, That](f: A => Option[B])(implicit cbf: CanBuildFrom[Repr, B, That]): That =
          r.flatMap(f(_).toSeq)
      }
      implicit def filterMap[Repr, A](r: Repr)(implicit fr: IsTraversableOnce[Repr]): FilterMapImpl[fr.A,Repr] =
        new FilterMapImpl(fr.conversion(r))
      

      But it won't compile. The implicit parameter `fr` should be of type `IsTraversableLike`. Furthermore, type parameter `A` in `filterMap` is not used and just confusing. It should be removed:

      class FilterMapImpl[A, Repr](val r: GenTraversableLike[A, Repr]) {
        final def filterMap[B, That](f: A => Option[B])(implicit cbf: CanBuildFrom[Repr, B, That]): That =
          r.flatMap(f(_).toSeq)
      }
      implicit def filterMap[Repr](r: Repr)(implicit fr: IsTraversableLike[Repr]): FilterMapImpl[fr.A,Repr] =
        new FilterMapImpl(fr.conversion(r))
      

      ------

      Furthermore, since this triggers a feature warning, I guess it should use an implicit class now.

        Activity

        Show
        Adriaan Moors added a comment - https://github.com/scala/scala/pull/1875

          People

          • Assignee:
            Heather Miller
            Reporter:
            Sciss
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development