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

Scala compiler crash on 2.10 with Value Class, separate compilation. #6976

Closed
scabug opened this Issue Jan 15, 2013 · 10 comments

Comments

Projects
None yet
2 participants
@scabug
Copy link

scabug commented Jan 15, 2013

Hello.

We're migrating from Play 2.0 & Scala 2.9.1 to Play 2.1 & Scala 2.10 and we have encountered a weird compiler error.

I think it's from this code:

      def mockIso = {
        val isochrone = mock[Isochrone]
        when(isochrone.rankPoints(
          time.eqM, startTime.near, mode.eqM, origin.eqM, points.eqM,
          accuracy.eqM
        )(Remote.timeout.eqM)).thenReturn(promiseOpt(expected))

        isochrone
      }

The eqM is defined in trait Mocks which is mixed into the test class (using scalatest here).

object Mocks {
  // Time precision in milliseconds
  private[this] val TimePrecision = 1000

  implicit class AnyMatchers[T](val o: T) extends AnyVal {
    def eqM = M.eq(o)
  }

  implicit class DateTimeMatchers(val instant: DateTime) extends AnyVal {
    def within(millis: Int) = M.argThat(new Within(instant, millis))
    def near = within(TimePrecision)
  }
}

trait Mocks extends MockitoSugar {
  implicit def AnyMatchers[T](o: T) = Mocks.AnyMatchers(o)
  implicit def DateTimeMatchers(o: DateTime) = Mocks.DateTimeMatchers(o)
}

The crash info is attached to the bug below.

My project configuration:

import sbt._
import Keys._
import play.Project._

object ApiBuild extends Build {
  val appName         = "tt-api"
  val appVersion      = "1.0"

  object V {
    val Akka = "2.1.0"
  }

  object S {
    val test = "test"
  }

  val appDependencies = Seq(
    //"org.scalaz" %% "scalaz-core" % "6.0.4",
    
    // Java libraries

    // Google geocoding library
    "com.google.code.geocoder-java" % "geocoder-java" % "0.9",
    // Emailer
    "org.apache.commons" % "commons-email" % "1.2",
    // CSV generator
    "net.sf.opencsv" % "opencsv" % "2.0",

    // Scala test libraries

    "org.scalatest" %% "scalatest" % "2.0.M5b" % S.test,
    "org.scalacheck" %% "scalacheck" % "1.10.0" % S.test,
    "com.typesafe.akka" % "akka-testkit_2.10" % V.Akka % S.test,
    //"org.scalamock" %% "scalamock-scalatest-support" % "3.0" % S.test

    // Java test libraries

    "org.mockito" % "mockito-all" % "1.9.0" % S.test
  )

  /** Custom tasks **/

  val igLib = RootProject(file("vendor/ig-lib"))

  lazy val main = play.Project(
    appName, appVersion, appDependencies
  ).settings(
    scalaVersion := "2.10.0",
    scalaBinaryVersion := "2.10",
    scalacOptions ++= Seq("-feature"),
    // Add your own project settings here
    resolvers ++= Seq(
      "Sonatype Snapshots" at
        "http://oss.sonatype.org/content/repositories/snapshots",
      "Sonatype Releases" at
        "http://oss.sonatype.org/content/repositories/releases"
    ),
    // When doing test runs do not launch them in the aggregated projects.
    aggregate in test := false,
    aggregate in testOnly := false,
    // Scalatest compatibility
    testOptions in Test := Nil
//    parallelExecution in Test := false
  ).dependsOn(igLib % "compile->compile;test->test")
   .aggregate(igLib)
}

I'm not sure what else I can provide, but just ask if you need any more information.

Meanwhile - perhaps anyone can give me a hint what's happening and how to work around this?

@scabug

This comment has been minimized.

Copy link
Author

scabug commented Jan 15, 2013

Imported From: https://issues.scala-lang.org/browse/SI-6976?orig=1
Reporter: Artūras Šlajus (arturaz)
Affected Versions: 2.10.0
Attachments:

@scabug

This comment has been minimized.

Copy link
Author

scabug commented Jan 16, 2013

Artūras Šlajus (arturaz) said:
Ok, it seems I've tracked down the bug and it has nothing to do with mockito.

Instead it seems that the bug is in implicit class handling logic in the compiler between compiles. On some projects even sbt clean does not help.

Please take a look at attached implicits-bug.tar.bz2 file.

@scabug

This comment has been minimized.

Copy link
Author

scabug commented Jan 16, 2013

Artūras Šlajus (arturaz) said:
Self-contained sbt project repro.

See ImplicitsBug.scala for step-by-step instructions on how to reproduce this.

@scabug

This comment has been minimized.

Copy link
Author

scabug commented Jan 16, 2013

@retronym said:
Thanks a lot for the detailed test case; I'm looking into this now.

@scabug

This comment has been minimized.

Copy link
Author

scabug commented Jan 16, 2013

Artūras Šlajus (arturaz) said:
I've also just tried to create idea project from this test case. When using FSC as a compiler in Idea everything compiles fine each time, so this might be a bug in SBT.

@scabug

This comment has been minimized.

Copy link
Author

scabug commented Jan 16, 2013

@retronym said:
You've given me enough to work with, but in the future if you want provide a reproduction of a SBT induced scalac bug, you can just run with set logLevel := Level.Debug, and then run the sequence of commands. You will see what classpath/options/sourcefiles are passed to scalac at each step.

@scabug

This comment has been minimized.

Copy link
Author

scabug commented Jan 16, 2013

@scabug

This comment has been minimized.

Copy link
Author

scabug commented Jan 16, 2013

@scabug

This comment has been minimized.

Copy link
Author

scabug commented Jan 18, 2013

Artūras Šlajus (arturaz) said:
Hm. This is really annoying in development. Is this fixed? Should I build scala from master or something? :)

@scabug

This comment has been minimized.

Copy link
Author

scabug commented Jan 18, 2013

@retronym said:
The fix will be delivered in 2.10.1.

@scabug scabug closed this Jan 25, 2013

@scabug scabug added this to the 2.10.1 milestone Apr 7, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.