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

Scalac does not respect an implicit def when recompiling

    Details

      Description

      Given src/main/scala/pack/age/Foo.scala:hello

      package pack.age
       
      class Baz 
       
      object Implicits  {
      	implicit def Baz(n: Int): Baz = new Baz
      }
      

      and src/main/scala/pack/age/Bar.scala:

      package pack.age
       
      import pack.age.Implicits._
       
      object Quux {
      	def baz : Baz   = 1
      }
      

      When first run, scalac src/main/scala/pack/age/Foo.scala src/main/scala/pack/age/Bar.scala compiles both fine, and places the class files in the pack directory.

      However, if rerun, scalac src/main/scala/pack/age/Foo.scala src/main/scala/pack/age/Bar.scala fails with the following error:

      src/main/scala/pack/age/Bar.scala:6: error: type mismatch;
      found   : Int(1)
      required: pack.age.Baz
       def baz : Baz   = 1
      									 ^
      one error found
      

      This is a simplification of the bug reported in a stackoverflow question (http://stackoverflow.com/questions/9959199/error-in-scala-maven-recompilation-without-code-change). All the above code can be downloaded from github (https://github.com/rampion/scalac-compile-bug).

        Attachments

          Activity

          Hide
          moors Adriaan Moors added a comment -

          Since 2.11.0-RC1 is one week away, pushing all non-blockers without PR to 2.11.1-RC1. Please undo the change if I missed work in progress.

          Show
          moors Adriaan Moors added a comment - Since 2.11.0-RC1 is one week away, pushing all non-blockers without PR to 2.11.1-RC1. Please undo the change if I missed work in progress.
          Hide
          grek Grzegorz Kossakowski added a comment -

          The 2.11.2 is out so I'm rescheduling the issue for 2.11.3.

          Show
          grek Grzegorz Kossakowski added a comment - The 2.11.2 is out so I'm rescheduling the issue for 2.11.3.
          Hide
          retronym Jason Zaugg added a comment -

          Updating fix-by version to 2.11.5.

          Show
          retronym Jason Zaugg added a comment - Updating fix-by version to 2.11.5.
          Show
          retronym Jason Zaugg added a comment - https://github.com/scala/scala/pull/4118
          Hide
          retronym Jason Zaugg added a comment -

          This is now fixed in 2.11.5 under the compiler flag -Xsource:2.12, or in 2.12.0-M1 and later.

          Show
          retronym Jason Zaugg added a comment - This is now fixed in 2.11.5 under the compiler flag -Xsource:2.12, or in 2.12.0-M1 and later.

            People

            • Assignee:
              retronym Jason Zaugg
              Reporter:
              rampion Noah Luck Easterly
            • Votes:
              2 Vote for this issue
              Watchers:
              10 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: