Skip to content

Console fails when using Typelevel Scala with monocle-macro #275

@julianmichael

Description

@julianmichael

I'm porting a project over to Mill (using 0.1.7) from SBT and I'm having issues running the console command, which is important for my project.

I've isolated the problem to the following build.sc:

import mill._, mill.scalalib._

val thisScalaVersion = "2.11.8"
val monocleVersion = "1.4.0"

def typelevelScalaCompilerIvyDeps(scalaVersion: String) = Agg[Dep](
  ivy"org.typelevel:scala-compiler:$scalaVersion",
  ivy"org.typelevel:scala-reflect:$scalaVersion"
)
def typelevelScalaRuntimeIvyDeps(scalaVersion: String) = Agg[Dep](
  ivy"org.typelevel:scala-library:$scalaVersion"
)

object foo extends ScalaModule {
  def scalaVersion = thisScalaVersion
  def scalaLibraryIvyDeps = T{ typelevelScalaRuntimeIvyDeps(scalaVersion()) }
  def scalaCompilerClasspath: T[Agg[PathRef]] = T{
    resolveDeps(
      T.task{typelevelScalaCompilerIvyDeps(scalaVersion()) ++ typelevelScalaRuntimeIvyDeps(scalaVersion())}
    )()
  }
  def ivyDeps = Agg(
    ivy"com.github.julien-truffaut::monocle-macro::$monocleVersion"
  )
}

When I run mill -i foo.console, right when the scala console starts up, it spits out:

Failed to initialize compiler: NoSuchMethodError.                                                                                                    This is most often remedied by a full clean and recompile.                                                                     
Otherwise, your classpath may continue bytecode compiled by                                                                                       
different and incompatible versions of scala.                                                                                    
                                                                                                                                                     java.lang.NoSuchMethodError: scala.reflect.internal.Types$ConstantType$.apply(Lscala/reflect/internal/Constants$Constant;)Lscala/reflect/internal/Types$ConstantType;                                                                                                                                             at scala.tools.nsc.symtab.classfile.ClassfileParser.scala$tools$nsc$symtab$classfile$ClassfileParser$$parseAttribute$1(ClassfileParser.scala:817)                                                                                                                                                         at scala.tools.nsc.symtab.classfile.ClassfileParser$$anonfun$parseAttributes$1.apply$mcVI$sp(ClassfileParser.scala:1017) 
        at scala.collection.immutable.Range.foreach$mVc$sp(Range.scala:160)
        ...

with a long stack trace, followed by another error with the same message and another long stack trace.

If I remove the def ivyDeps = ... statement or the Typelevel Scala specifications, it works fine. The compile target works fine too, including in my actual project which has Scala sources that require the Typelevel compiler (whereas the console has the same error). I also tried changing the Scala version to 2.12.0 and again got the same error (though my project needs 2.11.8 at the moment).

Not sure exactly what's causing this—it seems to be a weird interaction between this dependency and Typelevel Scala. But the console worked fine in my SBT version of the build, and this issue is preventing me from porting over to Mill.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions