Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scalac does not respect an implicit def when recompiling #5639

Closed
scabug opened this issue Apr 2, 2012 · 11 comments
Closed

Scalac does not respect an implicit def when recompiling #5639

scabug opened this issue Apr 2, 2012 · 11 comments

Comments

@scabug
Copy link

scabug commented Apr 2, 2012

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.

@scabug
Copy link
Author

scabug commented Apr 2, 2012

Imported From: https://issues.scala-lang.org/browse/SI-5639?orig=1
Reporter: Noah Luck Easterly (rampion)
Affected Versions: 2.9.1, 2.10.0-M3, 2.10.0

@scabug
Copy link
Author

scabug commented Apr 2, 2012

DaveScala (davescala) said:
The above bug seems to happen with top level imports of implicits.

Object level imports compiles over and over again

package pack.age 

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

More info on scala-user list:
http://groups.google.com/group/scala-user/browse_thread/thread/cf1a3ae39ecf1c81

@scabug
Copy link
Author

scabug commented May 7, 2012

@phaller said:
Test in pending/pos/t5639.

@scabug
Copy link
Author

scabug commented May 18, 2012

@retronym said (edited on May 18, 2012 9:42:30 PM UTC):
This is a regression from 2.7.7 to 2.8.0. The class seems to be incorrectly shadowing the imported implicit of the same name.

  ~/code/scratch/20120518 cat Bar.scala
import Implicits._

class Baz

object Test {
  implicitly[Int]
}

object Implicits  {
  implicit val Baz: Int = 0
}
  ~/code/scratch/20120518 rm -rf out/* 
  ~/code/scratch/20120518 scalac210 -language:implicitConversions -d out -classpath out Bar.scala 
  ~/code/scratch/20120518 scalac210 -language:implicitConversions -d out -classpath out Bar.scala 
Bar.scala:6: error: could not find implicit value for parameter e: Int
  implicitly[Int]
            ^
one error found

@scabug
Copy link
Author

scabug commented Jan 28, 2013

@adriaanm said:
i don't feel comfortable fixing this in 2.10.x
the required behavior change may change the meaning of programs that (unwittingly) rely on this bug

@scabug
Copy link
Author

scabug commented Jul 10, 2013

@adriaanm said:
Unassigning and rescheduling to M6 as previous deadline was missed.

@scabug
Copy link
Author

scabug commented Feb 10, 2014

@adriaanm said:
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.

@scabug
Copy link
Author

scabug commented Aug 5, 2014

@gkossakowski said:
The 2.11.2 is out so I'm rescheduling the issue for 2.11.3.

@scabug
Copy link
Author

scabug commented Nov 4, 2014

@retronym said:
Updating fix-by version to 2.11.5.

@scabug
Copy link
Author

scabug commented Nov 9, 2014

@retronym said:
scala/scala#4118

@scabug
Copy link
Author

scabug commented Nov 19, 2014

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants