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

Comments

Projects
None yet
2 participants
@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

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

Copy link
Author

scabug commented May 7, 2012

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

@scabug

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

Copy link
Author

scabug commented Jul 10, 2013

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

@scabug

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

Copy link
Author

scabug commented Nov 4, 2014

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

@scabug

This comment has been minimized.

Copy link
Author

scabug commented Nov 9, 2014

@scabug

This comment has been minimized.

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.

@scabug scabug closed this Nov 19, 2014

@scabug scabug added this to the 2.12.0-M1 milestone Apr 7, 2017

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