Uploaded image for project: 'Scala Programming Language'
  1. Scala Programming Language
  2. SI-6455

deprecate fallback to filter when withFilter is not found in for-comprehension desugaring

    Details

      Description

      See the error message below? I use filter but it's not defined: I see, it seems I'm a bad kid. But... where is the call to filter? Is the compiler really complaining on the call to withFilter (retorical question, answer: yes)?

      [error] /Users/pgiarrusso/Documents/Research/Sorgenti/linqonsteroids/src/main/scala/ivm/optimization/SubquerySharing.scala:372: value filter is not a member of ivm.expressiontree.Lifting.TypeMappingApp[Traversable,TupleTAnd,AnyRef,T]
      [error]             Some(ConstByIdentity(t.asInstanceOf[TypeMapping[Traversable, TupleTAnd, AnyRef]], cTag, tTag).get[T](clazz) /*map(_._1) */withFilter Fun.makefun(cond, fx).f)
      [error]                                                                                                                                       ^
      

      I did not believe my eyes (I was also tired, so that was a good idea), but after a couple of minutes I realized I should trust them more than my computer.

      Grepping withFilter on the compiler reveals the following wonder in Typers:

                  val tree1 = // temporarily use `filter` and an alternative for `withFilter`
                    if (name == nme.withFilter)
                      silent(_ => typedSelect(tree, qual1, name)) match {
                        case SilentResultValue(result) =>
                          result
                        case _ =>
                          silent(_ => typed1(Select(qual1, nme.filter) setPos tree.pos, mode, pt)) match {
      [...]
      

      I know this was intended. It's even documented somewhere, IIRC about the desugaring of for comprehensions (where it makes total sense). But whenever I call withFilter? Also, this was introduced IIRC in 2.8.
      Could we please, at the very least, deprecate this aliasing in 2.10, so that it can be removed in 2.11? Or improve the error message?

        Attachments

          Issue Links

            Activity

            Hide
            soc Simon Ochsenreither added a comment -

            Hi Paolo,

            could be that I'm completely missing the point ... I'm incredibly tired right now, but I re-read the ticket (and SI-2700) and now I'm even more confused.
            So the compiler is complaining that filter is missing, despite the code not actually using filter, but withFilter? Is this the problem?
            If yes, then I think this should be fixed ... feel free to reassign it to you, I'm pretty much drowning in tickets and other life-related things currently.

            Show
            soc Simon Ochsenreither added a comment - Hi Paolo, could be that I'm completely missing the point ... I'm incredibly tired right now, but I re-read the ticket (and SI-2700 ) and now I'm even more confused. So the compiler is complaining that filter is missing, despite the code not actually using filter, but withFilter? Is this the problem? If yes, then I think this should be fixed ... feel free to reassign it to you, I'm pretty much drowning in tickets and other life-related things currently.
            Hide
            pggiarrusso Paolo G. Giarrusso added a comment -

            Simon: you got it right.

            Adriaan: reassigning to you per your wish, since Simon is busy.

            Show
            pggiarrusso Paolo G. Giarrusso added a comment - Simon: you got it right. Adriaan: reassigning to you per your wish, since Simon is busy.
            Hide
            moors Adriaan Moors added a comment -

            Thanks for the clarifications, guys!

            Show
            moors Adriaan Moors added a comment - Thanks for the clarifications, guys!
            Hide
            moors Adriaan Moors added a comment - - edited

            https://github.com/scala/scala/pull/3566

            Perhaps a bit eager, but let's see what the build says.

            Show
            moors Adriaan Moors added a comment - - edited https://github.com/scala/scala/pull/3566 Perhaps a bit eager, but let's see what the build says.
            Hide
            moors Adriaan Moors added a comment -

            I weakened the PR to enforce the deprecation (by not doing the rewrite) under -Xfuture.

            Show
            moors Adriaan Moors added a comment - I weakened the PR to enforce the deprecation (by not doing the rewrite) under -Xfuture.

              People

              • Assignee:
                moors Adriaan Moors
                Reporter:
                pggiarrusso Paolo G. Giarrusso
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: