scalascalac

Scalac option Yopt-log-inline make errors


With scala 2.12.4 when I use theses parameters

scalacOptions := Seq("-unchecked", "-deprecation", "-opt:l:inline","-opt-inline-from:bfd.DateTime$","-Yopt-log-inline")

I have error which doesn't exist when I don't use "-Yopt-log-inline"

[info] Compiling 7 Scala sources to /Users/admin/Workspace/bfd/target/scala-2.12/classes ...
[error] error while loading Object, Missing dependency 'object scala in compiler mirror', required by /Library/Java/JavaVirtualMachines/jdk1.8.0_92.jdk/Contents/Home/jre/lib/rt.jar(java/lang/Object.class)
[error] ## Exception when compiling 7 sources to /Users/admin/Workspace/bfd/target/scala-2.12/classes
[error] object scala in compiler mirror not found.
[error] scala.reflect.internal.MissingRequirementError$.signal(MissingRequirementError.scala:17)
[error] scala.reflect.internal.MissingRequirementError$.notFound(MissingRequirementError.scala:18)
[error] scala.reflect.internal.Mirrors$RootsBase.$anonfun$getModuleOrClass$4(Mirrors.scala:54)
[error] scala.reflect.internal.Mirrors$RootsBase.getModuleOrClass(Mirrors.scala:54)
[error] scala.reflect.internal.Mirrors$RootsBase.getModuleOrClass(Mirrors.scala:66)
[error] scala.reflect.internal.Mirrors$RootsBase.getPackage(Mirrors.scala:172)
[error] scala.reflect.internal.Definitions$DefinitionsClass.ScalaPackage$lzycompute(Definitions.scala:169)
[error] scala.reflect.internal.Definitions$DefinitionsClass.ScalaPackage(Definitions.scala:169)
[error] scala.reflect.internal.Definitions$DefinitionsClass.ScalaPackageClass$lzycompute(Definitions.scala:170)
[error] scala.reflect.internal.Definitions$DefinitionsClass.ScalaPackageClass(Definitions.scala:170)
[error] scala.reflect.internal.Definitions$DefinitionsClass.init(Definitions.scala:1423)
[error] scala.tools.nsc.Global$Run.<init>(Global.scala:1164)
[error] xsbt.ZincCompiler$ZincRun.<init>(CallbackGlobal.scala:63)
[error] xsbt.CachedCompiler0.run(CompilerInterface.scala:129)
[error] xsbt.CachedCompiler0.run(CompilerInterface.scala:106)
[error] xsbt.CompilerInterface.run(CompilerInterface.scala:32)
[error] sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error] sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
...

I think the error is not related to the usage of inline. Maybe the options override the scala dependency definition.

Is it a bug in the compiler or just a bad setting with an unclear feedback?


Solution

  • -Yopt-log-inline expect a parameter. The equivalent to the wild card of -opt-inline-from:** is the underscore _.

    So to correct this error add this parameter to scalacOptions like this.

    scalacOptions ++= Seq("-opt:l:inline","-opt-inline-from:bfd.DateTime$","-Yopt-log-inline", "_")

    edit:

    What hepping here is a problem between scalac and sbt, sbt gives the class pass next to Scala option, so scalac think the classpath is the option of -Yopt-log-inline and start without actual classpath, which make a crach.

    If you are using sbt and don't want to fall in this kind of error you can use "-Y" as your last option.