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

Invisible forward reference when using implicit class

    Details

      Description

      Implicit def synthesis from an implicit class suffers from the dread forward reference bug.

      object tiny {
      
        def main(args: Array[String]) {
          ok(); nope()
        }
        def ok() {
          class Foo(val i: Int) {
            def foo[A](body: =>A): A = body
          }
          implicit def toFoo(i: Int): Foo = new Foo(i)
      
          val k = 1
          k foo println("k?")
          val j = 2
        }
        def nope() {
          implicit class Foo(val i: Int) {
            def foo[A](body: =>A): A = body
          }
      
          val k = 1
          k foo println("k?")
          //lazy
          val j = 2
        }
      }
      

        Issue Links

          Activity

          Hide
          Jason Zaugg added a comment -

          You'd better submit a PR, just in case they are too busy staving off the hordes of snozzwangers and whangdoodles.

          Show
          Jason Zaugg added a comment - You'd better submit a PR, just in case they are too busy staving off the hordes of snozzwangers and whangdoodles.
          Hide
          A. P. Marki added a comment -

          Back-applied patch to 2.10.x.

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

          Learned about git format-patch and git am. Was that the most appropriate workflow?

          A vermicious knid ate my patch file.

          Show
          A. P. Marki added a comment - Back-applied patch to 2.10.x. https://github.com/scala/scala/pull/1277 Learned about git format-patch and git am. Was that the most appropriate workflow? A vermicious knid ate my patch file.
          Hide
          Jason Zaugg added a comment -

          I'd have gone for git co 2.10.x; git cherry-pick <hash>.

          Show
          Jason Zaugg added a comment - I'd have gone for git co 2.10.x; git cherry-pick <hash> .
          Hide
          A. P. Marki added a comment -

          Thanks. I thought when you guys talked about cherry picking commits, you were speaking idiomatically.

          Show
          A. P. Marki added a comment - Thanks. I thought when you guys talked about cherry picking commits, you were speaking idiomatically.
          Hide
          A. P. Marki added a comment -

          This form of the fix was merged on trunk and 2.10.x.

          Show
          A. P. Marki added a comment - This form of the fix was merged on trunk and 2.10.x.

            People

            • Assignee:
              A. P. Marki
              Reporter:
              A. P. Marki
            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development