Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Scala 2.10.0-M7, Scala 2.10.0
    • Component/s: Misc Compiler
    • Labels:
      None
    • Environment:

      package object overload

      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.
      }
      

        Activity

        Hide
        Erik Osheim added a comment -

        Awesome, thanks so much!

        Show
        Erik Osheim added a comment - Awesome, thanks so much!
        Hide
        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 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
        Paul Phillips added a comment - https://github.com/paulp/scala/commit/fcf2b29
        Hide
        Chris added a comment -

        very cool, many thanks

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

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development