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

type error on separate compilation (pickler foiled by path dependent parent type in the presence of overloading)

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: Scala 2.9.3, Scala 2.10.1, Scala 2.10.3-RC1, Scala 2.11.0-M3
    • Fix Version/s: Scala 2.11.1-RC1
    • Component/s: Misc Compiler
    • Environment:

      Description

      scalac shows a type error when dao.scala is compiled separately from tables.scala, but not when both are compiled together. The Slick-Play sample app is affected by this.

      Also see same bug at sbt issue tracker https://github.com/sbt/sbt/issues/786 .

      reproduce code

      "tables.scala"
      trait H2Driver{
          abstract class Table[T]
      }
      
      object Config {
        val driver : H2Driver = null
        def driver(app: Any): H2Driver = null
      }
      
      class Sites extends Config.driver.Table[String]
      
      "dao.scala"
      class DAOBase[E]{
        type TableType <: Config.driver.Table[E]
      }
      class SitesDAO extends DAOBase[String]{
        type TableType = Sites
      }
      

      expected

      $ scalac -cp . dao.scala tables.scala 
      $ scalac -cp . dao.scala
      $
      

      actual

      $ scalac . dao.scala tables.scala 
      $ scalac . dao.scala
      
      dao.scala:5: error: overriding type TableType in class DAOBase with bounds <: Config.driver.Table[String];
       type TableType has incompatible type
        type TableType = Sites
             ^
      one error found
      $
      

        Activity

        Hide
        Jason Zaugg added a comment -

        I guess "exposure to bugs in the compiler" would make it into my answer to "Why avoid method overloading" on SO. http://stackoverflow.com/a/2512001/160378

        Show
        Jason Zaugg added a comment - I guess "exposure to bugs in the compiler" would make it into my answer to "Why avoid method overloading" on SO. http://stackoverflow.com/a/2512001/160378
        Show
        Jason Zaugg added a comment - https://github.com/scala/scala/pull/2664
        Hide
        Christopher Vogt added a comment -

        So if you control the code, a viable workaround would be avoiding overloading. But the overloaded methods could come from a library, in which case as a user you have to fall back to clean/recompilation as described above. (Or submit a PR against the library like https://github.com/freekh/play-slick/pull/53).

        Show
        Christopher Vogt added a comment - So if you control the code, a viable workaround would be avoiding overloading. But the overloaded methods could come from a library, in which case as a user you have to fall back to clean/recompilation as described above. (Or submit a PR against the library like https://github.com/freekh/play-slick/pull/53 ).
        Hide
        Christopher Vogt added a comment -

        Jason, I added a link to this issue as a comment to your stackoverflow answer.

        Show
        Christopher Vogt added a comment - Jason, I added a link to this issue as a comment to your stackoverflow answer.
        Hide
        Adriaan Moors added a comment -

        Unassigning and rescheduling to M6 as previous deadline was missed.

        Show
        Adriaan Moors added a comment - Unassigning and rescheduling to M6 as previous deadline was missed.

          People

          • Assignee:
            Unassigned
            Reporter:
            Christopher Vogt
          • Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

            • Created:
              Updated:

              Development