Details

      Description

      Trivial overloading resolution in package object doesn't work?

      package object overloading {
          def bar(f: (Int) => Unit): Unit = ()
          def bar(f: (Int, Int) => Unit): Unit = ()
      }
       
      class PackageObjectOverloadingTest {
          overloading.bar( (i: Int) => () ) // doesn't compile.
      }

        Attachments

          Activity

          Hide
          d_m Erik Osheim added a comment -

          Awesome, thanks so much!

          Show
          d_m Erik Osheim added a comment - Awesome, thanks so much!
          Hide
          chris Chris added a comment - - edited

          This fix, present in 2.10-M6 and above can cause the following issue at runtime. Comment added should anyone else hit this.

          The code will "compile" but it generates CCEing byte code:

          scaley.funny.package$ cannot be cast to scales.xml.PullIteratees

          which is true, but for some reason the compiler generates it.

          The code is here:

          https://github.com/chris-twiner/scalesXml/tree/cdeb3a7e04d15cf77c9fda4d406c3eb403920a18

          4 very small files plus the build.sbt. clean + run and you'll see the cce.

          I've commented in the code what can stop the cce, any of which forces
          the correct package$ to be used:

          • change package name of using code (and import the package)
          • comment out the import of scaley.funny._
          • remove the overloaded function in PullIteratees
          • use the fully qualified path to iterate
          Show
          chris Chris added a comment - - edited This fix, present in 2.10-M6 and above can cause the following issue at runtime. Comment added should anyone else hit this. The code will "compile" but it generates CCEing byte code: scaley.funny.package$ cannot be cast to scales.xml.PullIteratees which is true, but for some reason the compiler generates it. The code is here: https://github.com/chris-twiner/scalesXml/tree/cdeb3a7e04d15cf77c9fda4d406c3eb403920a18 4 very small files plus the build.sbt. clean + run and you'll see the cce. I've commented in the code what can stop the cce, any of which forces the correct package$ to be used: change package name of using code (and import the package) comment out the import of scaley.funny._ remove the overloaded function in PullIteratees use the fully qualified path to iterate
          Show
          extempore Paul Phillips added a comment - https://github.com/paulp/scala/commit/fcf2b29
          Hide
          chris Chris added a comment -

          very cool, many thanks

          Show
          chris Chris added a comment - very cool, many thanks
          Show
          moors Adriaan Moors added a comment - https://github.com/scala/scala/pull/1182

            People

            • Assignee:
              odersky Martin Odersky
              Reporter:
              okomok Shunsuke Sogame
              TracCC:
              Harrison Klaperman, Paul Phillips
            • Votes:
              3 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: