Strange error message on scala 2.10 / sbt 0.13 upgrade - scala

We're trying to upgrade https://github.com/linkedin/play-testng-plugin to scala 2.10 / sbt 0.13, also using the new version (3.0.0 vs 2.0.3) of https://bitbucket.org/jmhofer/sbt-testng-interface/wiki/Home
However, I am getting a strange error on sbt compile which we have not been able to figure out but seems to be caused by the following code snipper:
class WrappedTestNGRunner(testClassLoader: ClassLoader, loggers: Array[Logger], state: TestRunState) extends TestNGRunner(testClassLoader: ClassLoader, loggers: Array[Logger], state: TestRunState) {
override def run(testClassname: String, fingerprint: Fingerprint, eventHandler: EventHandler, testOptions: Array[String]) = {
super.run(testClassname, fingerprint, eventHandler, testOptions)
}
}
error message:
[error]
[error] while compiling: /home/bliang/Projects/play-testng-plugin/plugin/src/main/scala/NGPlugin.scala
[error] during phase: erasure
[error] library version: version 2.10.1
[error] compiler version: version 2.10.1
[error] reconstructed args: -bootclasspath /export/apps/jdk/JDK-1_6_0_27/jre/lib/resources.jar:/export/apps/jdk/JDK-1_6_0_27/jre/lib/rt.jar:/export/apps/jdk/JDK-1_6_0_27/jre/lib/sunrsasign.jar:/export/apps/jdk/JDK-1_6_0_27/jre/lib/jsse.jar:/export/apps/jdk/JDK-1_6_0_27/jre/lib/jce.jar:/export/apps/jdk/JDK-1_6_0_27/jre/lib/charsets.jar:/export/apps/jdk/JDK-1_6_0_27/jre/lib/modules/jdk.boot.jar:/export/apps/jdk/JDK-1_6_0_27/jre/classes:/home/bliang/Projects/play-2.2.0-M2/repository/cache/org.scala-lang/scala-library/jars/scala-library-2.10.1.jar -classpath /home/bliang/Projects/play-testng-plugin/plugin/target/scala-2.10/sbt-0.13/classes:/home/bliang/Projects/play-2.2.0-M2/repository/cache/scala_2.10/sbt_0.13/de.johoop/sbt-testng-plugin/jars/sbt-testng-plugin-3.0.0.jar:/home/bliang/Projects/play-2.2.0-M2/repository/cache/de.johoop/sbt-testng-interface_2.10/jars/sbt-testng-interface_2.10-3.0.0.jar:/home/bliang/Projects/play-2.2.0-M2/repository/cache/org.scala-sbt/sbt/jars/sbt-0.13.0.jar:/home/bliang/Projects/play-2.2.0-M2/repository/cache/org.scala-sbt/main/jars/main-0.13.0.jar:/home/bliang/Projects/play-2.2.0-M2/repository/cache/org.scala-sbt/actions/jars/actions-0.13.0.jar:/home/bliang/Projects/play-2.2.0-M2/repository/cache/org.scala-sbt/classpath/jars/classpath-0.13.0.jar:/home/bliang/Projects/play-2.2.0-M2/repository/cache/org.scala-sbt/launcher-interface/jars/launcher-interface-0.13.0.jar:/home/bliang/Projects/play-2.2.0-M2/repository/cache/org.scala-sbt/interface/jars/interface-0.13.0.jar:/home/bliang/Projects/play-2.2.0-M2/repository/cache/org.scala-sbt/io/jars/io-0.13.0.jar:/home/bliang/Projects/play-2.2.0-M2/repository/cache/org.scala-sbt/control/jars/control-0.13.0.jar:/home/bliang/.sbt/boot/scala-2.10.2/lib/scala-compiler.jar:/home/bliang/.sbt/boot/scala-2.10.2/lib/scala-reflect.jar:/home/bliang/Projects/play-2.2.0-M2/repository/cache/org.scala-sbt/completion/jars/completion-0.13.0.jar:/home/bliang/Projects/play-2.2.0-M2/repository/cache/org.scala-sbt/collections/jars/collections-0.13.0.jar:/home/bliang/Projects/play-2.2.0-M2/repository/local/jline/jline/2.11/jars/jline.jar:/home/bliang/Projects/play-2.2.0-M2/repository/cache/org.scala-sbt/api/jars/api-0.13.0.jar:/home/bliang/Projects/play-2.2.0-M2/repository/cache/org.scala-sbt/compiler-integration/jars/compiler-integration-0.13.0.jar:/home/bliang/Projects/play-2.2.0-M2/repository/cache/org.scala-sbt/incremental-compiler/jars/incremental-compiler-0.13.0.jar:/home/bliang/Projects/play-2.2.0-M2/repository/cache/org.scala-sbt/logging/jars/logging-0.13.0.jar:/home/bliang/Projects/play-2.2.0-M2/repository/cache/org.scala-sbt/process/jars/process-0.13.0.jar:/home/bliang/Projects/play-2.2.0-M2/repository/cache/org.scala-sbt/relation/jars/relation-0.13.0.jar:/home/bliang/Projects/play-2.2.0-M2/repository/cache/org.scala-sbt/compile/jars/compile-0.13.0.jar:/home/bliang/Projects/play-2.2.0-M2/repository/cache/org.scala-sbt/persist/jars/persist-0.13.0.jar:/home/bliang/Projects/play-2.2.0-M2/repository/cache/org.scala-tools.sbinary/sbinary_2.10/jars/sbinary_2.10-0.4.2.jar:/home/bliang/Projects/play-2.2.0-M2/repository/cache/org.scala-sbt/classfile/jars/classfile-0.13.0.jar:/home/bliang/Projects/play-2.2.0-M2/repository/cache/org.scala-sbt/compiler-ivy-integration/jars/compiler-ivy-integration-0.13.0.jar:/home/bliang/Projects/play-2.2.0-M2/repository/cache/org.scala-sbt/ivy/jars/ivy-0.13.0.jar:/home/bliang/Projects/play-2.2.0-M2/repository/cache/org.scala-sbt/cross/jars/cross-0.13.0.jar:/home/bliang/Projects/play-2.2.0-M2/repository/local/org.apache.ivy/ivy/2.3.0-rc1/jars/ivy.jar:/home/bliang/Projects/play-2.2.0-M2/repository/local/com.jcraft/jsch/0.1.46/jars/jsch.jar:/home/bliang/Projects/play-2.2.0-M2/repository/cache/org.scala-sbt/run/jars/run-0.13.0.jar:/home/bliang/Projects/play-2.2.0-M2/repository/cache/org.scala-sbt/task-system/jars/task-system-0.13.0.jar:/home/bliang/Projects/play-2.2.0-M2/repository/cache/org.scala-sbt/tasks/jars/tasks-0.13.0.jar:/home/bliang/Projects/play-2.2.0-M2/repository/cache/org.scala-sbt/tracking/jars/tracking-0.13.0.jar:/home/bliang/Projects/play-2.2.0-M2/repository/cache/org.scala-sbt/cache/jars/cache-0.13.0.jar:/home/bliang/Projects/play-2.2.0-M2/repository/cache/org.scala-sbt/testing/jars/testing-0.13.0.jar:/home/bliang/Projects/play-2.2.0-M2/repository/cache/org.scala-sbt/test-agent/jars/test-agent-0.13.0.jar:/home/bliang/Projects/play-2.2.0-M2/repository/local/org.scala-sbt/test-interface/1.0/jars/test-interface.jar:/home/bliang/Projects/play-2.2.0-M2/repository/cache/org.scala-sbt/main-settings/jars/main-settings-0.13.0.jar:/home/bliang/Projects/play-2.2.0-M2/repository/cache/org.scala-sbt/apply-macro/jars/apply-macro-0.13.0.jar:/home/bliang/Projects/play-2.2.0-M2/repository/cache/org.scala-sbt/command/jars/command-0.13.0.jar:/home/bliang/Projects/play-2.2.0-M2/repository/cache/org.scala-sbt/compiler-interface/jars/compiler-interface-src-0.13.0.jar:/home/bliang/Projects/play-2.2.0-M2/repository/cache/org.scala-sbt/compiler-interface/jars/compiler-interface-bin-0.13.0.jar:/home/bliang/Projects/play-2.2.0-M2/repository/cache/org.scala-sbt/precompiled-2_8_2/jars/compiler-interface-bin-0.13.0.jar:/home/bliang/Projects/play-2.2.0-M2/repository/cache/org.scala-sbt/precompiled-2_9_2/jars/compiler-interface-bin-0.13.0.jar:/home/bliang/Projects/play-2.2.0-M2/repository/cache/org.scala-sbt/precompiled-2_9_3/jars/compiler-interface-bin-0.13.0.jar
[error]
[error] last tree to typer: This(anonymous class $anonfun)
[error] symbol: anonymous class $anonfun (flags: final <synthetic>)
[error] symbol definition: final class $anonfun extends AbstractFunction1[ClassLoader,Unit] with Serializable
[error] symbol owners: anonymous class $anonfun -> method apply -> anonymous class $anonfun -> method ngSettings -> object NGPlugin -> package plugin
[error] context owners: value sharedState -> class WrappedTestNGFramework -> package plugin
[error]
[error] == Enclosing template or block ==
[error]
[error] Template( // val <local WrappedTestNGFramework>: <notype> in class WrappedTestNGFramework, tree.tpe=com.linkedin.plugin.WrappedTestNGFramework
[error] "java.lang.Object", "org.scalatools.testing.Framework" // parents
[error] ValDef(
[error] private
[error] "_"
[error] <tpt>
[error] <empty>
[error] )
[error] // 8 statements
[error] DefDef( // def <init>(): com.linkedin.plugin.WrappedTestNGFramework in class WrappedTestNGFramework
[error] <method>
[error] "<init>"
[error] []
[error] List(Nil)
[error] <tpt> // tree.tpe=com.linkedin.plugin.WrappedTestNGFramework
[error] Block(
[error] Apply( // def <init>(): Object in class Object
[error] WrappedTestNGFramework.super."<init>" // def <init>(): Object in class Object
[error] Nil
[error] )
[error] ()
[error] )
[error] )
[error] ValDef( // private[this] val name: String in class WrappedTestNGFramework
[error] private <local> <triedcooking>
[error] "name "
[error] <tpt> // tree.tpe=String
[error] "TestNGFakeApp"
[error] )
[error] DefDef( // val name(): String in class WrappedTestNGFramework
[error] <method> <stable> <accessor>
[error] "name"
[error] []
[error] List(Nil)
[error] <tpt> // tree.tpe=String
[error] WrappedTestNGFramework.this."name " // private[this] val name: String in class WrappedTestNGFramework
[error] )
[error] ValDef( // private[this] val tests: Array[org.scalatools.testing.Fingerprint] in class WrappedTestNGFramework
[error] private <local> <triedcooking>
[error] "tests "
[error] <tpt> // tree.tpe=Array[org.scalatools.testing.Fingerprint]
[error] Apply( // def apply[T](xs: Seq[T],implicit evidence$2: scala.reflect.ClassTag[T]): Array[T] in object Array, tree.tpe=Array[org.scalatools.testing.Fingerprint]
[error] TypeApply( // def apply[T](xs: Seq[T],implicit evidence$2: scala.reflect.ClassTag[T]): Array[T] in object Array, tree.tpe=(xs: Seq[org.scalatools.testing.Fingerprint], implicit evidence$2: scala.reflect.ClassTag[org.scalatools.testing.Fingerprint])Array[org.scalatools.testing.Fingerprint]
[error] "scala"."Array"."apply" // def apply[T](xs: Seq[T],implicit evidence$2: scala.reflect.ClassTag[T]): Array[T] in object Array
[error] <tpt> // tree.tpe=org.scalatools.testing.Fingerprint
[error] )
[error] // 2 arguments
[error] Apply( // implicit def wrapRefArray[T <: Object](xs: Array[T]): scala.collection.mutable.WrappedArray[T] in class LowPriorityImplicits, tree.tpe=Seq[org.scalatools.testing.Fingerprint]
[error] TypeApply( // implicit def wrapRefArray[T <: Object](xs: Array[T]): scala.collection.mutable.WrappedArray[T] in class LowPriorityImplicits, tree.tpe=(xs: Array[org.scalatools.testing.Fingerprint])scala.collection.mutable.WrappedArray[org.scalatools.testing.Fingerprint]
[error] scala.this."Predef"."wrapRefArray" // implicit def wrapRefArray[T <: Object](xs: Array[T]): scala.collection.mutable.WrappedArray[T] in class LowPriorityImplicits
[error] <tpt> // tree.tpe=org.scalatools.testing.Fingerprint
[error] )
[error] ArrayValue(
[error] <tpt> // tree.tpe=org.scalatools.testing.Fingerprint
[error] List(
[error] Apply( // def <init>(annotationName: String,isModule: Boolean): de.johoop.testnginterface.Annotated in class Annotated
[error] new de.johoop.testnginterface.Annotated."<init>" // def <init>(annotationName: String,isModule: Boolean): de.johoop.testnginterface.Annotated in class Annotated
[error] // 2 arguments
[error] "com.linkedin.plugin.FakeApplication"
[error] Apply( // def apply$default$2(): Boolean #scala.annotation.unchecked.uncheckedVariance in object Annotated
[error] "de"."johoop"."testnginterface"."Annotated"."apply$default$2" // def apply$default$2(): Boolean #scala.annotation.unchecked.uncheckedVariance in object Annotated
[error] Nil
[error] )
[error] )
[error] )
[error] )
[error] )
[error] Apply( // def apply[T](runtimeClass1: Class[_]): scala.reflect.ClassTag[T] in object ClassTag, tree.tpe=scala.reflect.ClassTag[org.scalatools.testing.Fingerprint]
[error] TypeApply( // def apply[T](runtimeClass1: Class[_]): scala.reflect.ClassTag[T] in object ClassTag, tree.tpe=(runtimeClass1: Class[_])scala.reflect.ClassTag[org.scalatools.testing.Fingerprint]
[error] "ClassTag"."apply" // def apply[T](runtimeClass1: Class[_]): scala.reflect.ClassTag[T] in object ClassTag
[error] <tpt> // tree.tpe=org.scalatools.testing.Fingerprint
[error] )
[error] classOf[org.scalatools.testing.Fingerprint]
[error] )
[error] )
[error] )
[error] DefDef( // val tests(): Array[org.scalatools.testing.Fingerprint] in class WrappedTestNGFramework
[error] <method> <stable> <accessor>
[error] "tests"
[error] []
[error] List(Nil)
[error] <tpt> // tree.tpe=Array[org.scalatools.testing.Fingerprint]
[error] WrappedTestNGFramework.this."tests " // private[this] val tests: Array[org.scalatools.testing.Fingerprint] in class WrappedTestNGFramework
[error] )
[error] DefDef( // def testRunner(testClassLoader: ClassLoader,loggers: Array[org.scalatools.testing.Logger]): com.linkedin.plugin.WrappedTestNGRunner in class WrappedTestNGFramework
[error] <method>
[error] "testRunner"
[error] []
[error] // 1 parameter list
[error] ValDef( // testClassLoader: ClassLoader
[error] <param> <triedcooking>
[error] "testClassLoader"
[error] <tpt> // tree.tpe=ClassLoader
[error] <empty>
[error] )
[error] ValDef( // loggers: Array[org.scalatools.testing.Logger]
[error] <param> <triedcooking>
[error] "loggers"
[error] <tpt> // tree.tpe=Array[org.scalatools.testing.Logger]
[error] <empty>
[error] )
[error] <tpt> // tree.tpe=com.linkedin.plugin.WrappedTestNGRunner
[error] Apply( // def <init>(testClassLoader: ClassLoader,loggers: Array[org.scalatools.testing.Logger],state: de.johoop.testnginterface.TestRunState): com.linkedin.plugin.WrappedTestNGRunner in class WrappedTestNGRunner
[error] new com.linkedin.plugin.WrappedTestNGRunner."<init>" // def <init>(testClassLoader: ClassLoader,loggers: Array[org.scalatools.testing.Logger],state: de.johoop.testnginterface.TestRunState): com.linkedin.plugin.WrappedTestNGRunner in class WrappedTestNGRunner
[error] // 3 arguments
[error] "testClassLoader" // testClassLoader: ClassLoader
[error] "loggers" // loggers: Array[org.scalatools.testing.Logger]
[error] WrappedTestNGFramework.this."sharedState" // private[this] val sharedState: de.johoop.testnginterface.TestRunState in class WrappedTestNGFramework
[error] )
[error] )
[error] ValDef( // private[this] val sharedState: de.johoop.testnginterface.TestRunState in class WrappedTestNGFramework
[error] private <local> <triedcooking>
[error] "sharedState"
[error] <tpt> // tree.tpe=de.johoop.testnginterface.TestRunState
[error] Apply( // def <init>(): de.johoop.testnginterface.TestRunState in class TestRunState, tree.tpe=de.johoop.testnginterface.TestRunState
[error] new de.johoop.testnginterface.TestRunState."<init>" // def <init>(): de.johoop.testnginterface.TestRunState in class TestRunState, tree.tpe=()de.johoop.testnginterface.TestRunState
[error] Nil
[error] )
[error] )
[error] DefDef( // def testRunner(x$1: ClassLoader,x$2: Array[org.scalatools.testing.Logger]): org.scalatools.testing.Runner in class WrappedTestNGFramework
[error] <method> <bridge>
[error] "testRunner"
[error] []
[error] // 1 parameter list
[error] ValDef( // x$1: ClassLoader
[error] <param> <synthetic>
[error] "x$1"
[error] <tpt> // tree.tpe=ClassLoader
[error] <empty>
[error] )
[error] ValDef( // x$2: Array[org.scalatools.testing.Logger]
[error] <param> <synthetic>
[error] "x$2"
[error] <tpt> // tree.tpe=Array[org.scalatools.testing.Logger]
[error] <empty>
[error] )
[error] <tpt> // tree.tpe=org.scalatools.testing.Runner
[error] Apply( // def testRunner(testClassLoader: ClassLoader,loggers: Array[org.scalatools.testing.Logger]): com.linkedin.plugin.WrappedTestNGRunner in class WrappedTestNGFramework
[error] WrappedTestNGFramework.this."testRunner" // def testRunner(testClassLoader: ClassLoader,loggers: Array[org.scalatools.testing.Logger]): com.linkedin.plugin.WrappedTestNGRunner in class WrappedTestNGFramework
[error] // 2 arguments
[error] "x$1" // x$1: ClassLoader
[error] "x$2" // x$2: Array[org.scalatools.testing.Logger]
[error] )
[error] )
[error] )
[error]
[error] uncaught exception during compilation: scala.reflect.internal.Types$TypeError
[error] /home/bliang/Projects/play-testng-plugin/helpers/src/main/java/com/linkedin/plugin/NGTests.java:119: cannot find symbol
[error] symbol : constructor FakeApplication(java.io.File,java.lang.ClassLoader,java.util.Map<java.lang.String,java.lang.String>,java.util.List<java.lang.String>)
[error] location: class play.test.FakeApplication
[error] return new FakeApplication(new File(path), Helpers.class.getClassLoader(), getConf(), getPlugins());
[error] ^
[error] Note: /home/bliang/Projects/play-testng-plugin/helpers/src/main/java/com/linkedin/plugin/NGTests.java uses unchecked or unsafe operations.
[error] Note: Recompile with -Xlint:unchecked for details.
[error] 1 error
[trace] Stack trace suppressed: run last play-plugins-testng/compile:compile for the full output.
[error] (play-plugins-testng/compile:compile) scala.reflect.internal.Types$TypeError: bad symbolic reference. A signature in EventRecorder.class refers to term testng
[error] in package org which is not available.
[error] It may be completely missing from the current classpath, or the version on
[error] the classpath might be incompatible with the version used when compiling EventRecorder.class.
[error] (play-testng-helpers/compile:compile) javac returned nonzero exit code
[error] Total time: 4 s, completed Aug 28, 2013 5:36:20 PM
diff is below:
diff --git a/plugin/src/main/scala/NGPlugin.scala b/plugin/src/main/scala/NGPlugin.scala
index e3f7c67d5386c3737ea5c4c31c30e83a47111471..89ae5687d371e0b353dd39f869d31afb81844085 100644
--- a/plugin/src/main/scala/NGPlugin.scala
+++ b/plugin/src/main/scala/NGPlugin.scala
## -44,7 +44,7 ## object NGPlugin extends Plugin {
libraryDependencies <++= (testNGVersion in Test)(v => Seq(
"org.testng" % "testng" % v % "test->default",
// If changing this, be sure to change in Build.scala also.
- "de.johoop" %% "sbt-testng-interface" % "2.0.3" % "test"))
+ "de.johoop" % "sbt-testng-interface_2.10" % "3.0.0" % "test"))
)
private def playLoggerClass(loader: ClassLoader) = {
## -74,4 +74,4 ## class WrappedTestNGRunner(testClassLoader: ClassLoader, loggers: Array[Logger],
override def run(testClassname: String, fingerprint: Fingerprint, eventHandler: EventHandler, testOptions: Array[String]) = {
super.run(testClassname, fingerprint, eventHandler, testOptions)
}
-}
+}
\ No newline at end of file
diff --git a/project/Build.scala b/project/Build.scala
index aee26f3af24644fa9bdb39f1d317a91b60d2618c..2a62dd04be0a68aab11c0b07edaf8e0c283afcf7 100644
--- a/project/Build.scala
+++ b/project/Build.scala
## -21,6 +21,7 ## object NGPluginBuild extends Build {
url(ArtifactoryBaseUrl + "CORE"))(LinkedInPatterns)
val typeSafeReleases = "TypeSafeRelease" at "http://repo.typesafe.com/typesafe/releases/"
+ val sonaTypeReleases = "Sonatype OSS Releases" at "https://oss.sonatype.org/content/repositories/releases/"
}
lazy val root = Project("root", file("."),
## -34,7 +35,7 ## object NGPluginBuild extends Build {
settings = commonSettings ++ Seq(
libraryDependencies ++= Seq(
"org.testng" % "testng" % "6.4", // % "provided"
- "play" %% "play-test" % "2012.09.20.1886ca6" //% "provided"
+ "play" % "play-test_2.10" % "2.2-SNAPSHOT" //% "provided"
)))
lazy val NGPlugin = Project(
## -45,16 +46,16 ## object NGPluginBuild extends Build {
libraryDependencies <++= (scalaVersion, sbtVersion) {
case (scalaVersion, sbtVersion) => Seq(
// If changing this, be sure to change in NGPlugin.scala also.
- sbtPluginExtra("de.johoop" % "sbt-testng-plugin" % "2.0.3", "0.12", scalaVersion),
- "de.johoop" %% "sbt-testng-interface" % "2.0.3"
+ sbtPluginExtra("de.johoop" % "sbt-testng-plugin" % "3.0.0", "0.13", "2.10"),
+ "de.johoop" % "sbt-testng-interface_2.10" % "3.0.0"
)
}))
lazy val commonSettings: Seq[Setting[_]] = Project.defaultSettings ++ publishSettings ++ Seq(
organization := "com.linkedin",
- scalaVersion := "2.9.2",
+ scalaVersion := "2.10.1",
version := "2012.09.20.1886ca6-v5",
- resolvers ++= Seq(Repos.localRepo, Repos.sandbox, Repos.typeSafeReleases))
+ resolvers ++= Seq(Repos.localRepo, Repos.sandbox, Repos.typeSafeReleases, Repos.sonaTypeReleases))
lazy val publishSettings: Seq[Setting[_]] = Seq(
// publishTo <<= version { (v: String) =>
diff --git a/project/build.properties b/project/build.properties
index a8c2f849be3cf976d18427f666d9e6d433d189b2..0974fce44da5f8a84f7e1efe6aff9ebb25d128f6 100755
--- a/project/build.properties
+++ b/project/build.properties
## -1 +1 ##
-sbt.version=0.12.0
+sbt.version=0.13.0
diff --git a/sample/project/build.properties b/sample/project/build.properties
index a8c2f849be3cf976d18427f666d9e6d433d189b2..0974fce44da5f8a84f7e1efe6aff9ebb25d128f6 100644
--- a/sample/project/build.properties
+++ b/sample/project/build.properties
## -1 +1 ##
-sbt.version=0.12.0
+sbt.version=0.13.0

the compile error is caused by a change in the signature of FakeApplication(...).
Uncaught exception during compilation: scala.reflect.internal.Types$TypeError
[error] /home/bliang/Projects/play-testng-plugin/helpers/src/main/java/com/linkedin/plugin/NGTests.java:119: cannot find symbol
[error] symbol : constructor FakeApplication(java.io.File,java.lang.ClassLoader,java.util.Map<java.lang.String,java.lang.String>,java.util.List<java.lang.String>)
[error] location: class play.test.FakeApplication
[error] return new FakeApplication(new File(path), Helpers.class.getClassLoader(), getConf(), getPlugins());
You need to change
return new FakeApplication(new File(path), Helpers.class.getClassLoader(), getConf(), getPlugins());
to
return new FakeApplication(new File(path), Helpers.class.getClassLoader(), getConf(), getPlugins(), null);
in NGTest.java: 119
You may also encounter classpath issues due to different versions of play in the classpath.
The groupId of Play was changed 2.2.x from "play" to "com.typesafe.play", which may be a problem since sbt will consider diffferent versions of play-* to be different artifacts, and therefore will NOT detect conflicting versions.

Ahh, figured out how to get around this. I had to add
"org.testng" % "testng" % "6.4", // both 6.4 and 6.8.5 seem to work
to the NGPlugin libaryDependencies. In retrospect, this only makes sense, since EventRecorder in sbt-testng-interface has a compile dependency on org.testng . However, I have no idea how this was working before, since the previous version of sbt-testng-interface we depended on (2.0.3) also has that dependency as far as I could tell.

Related

Scala 3 Method Too large when using Mirror

When I use Mirror of scala 3 to generate a typeclass list, the exception occurs. I know it's the hard limit of jvm of method size, but how can I circumvent this issue.
ps: When delete some fields of Data class it works, but any other solution?
info
sbt: 1.6.0
scala: 3.1.0
error
scala.tools.asm.MethodTooLargeException: Method too large: parse/Main$. ()V while compiling
stack trace
[error] scala.tools.asm.MethodTooLargeException: Method too large: parse/Main$.<clinit> ()V
[error] scala.tools.asm.MethodWriter.computeMethodInfoSize(MethodWriter.java:2087)
[error] scala.tools.asm.ClassWriter.toByteArray(ClassWriter.java:489)
[error] dotty.tools.backend.jvm.GenBCodePipeline$Worker2.getByteArray$1(GenBCode.scala:478)
[error] dotty.tools.backend.jvm.GenBCodePipeline$Worker2.addToQ3(GenBCode.scala:484)
[error] dotty.tools.backend.jvm.GenBCodePipeline$Worker2.run(GenBCode.scala:461)
[error] dotty.tools.backend.jvm.GenBCodePipeline.buildAndSendToDisk(GenBCode.scala:562)
[error] dotty.tools.backend.jvm.GenBCodePipeline.run(GenBCode.scala:525)
[error] dotty.tools.backend.jvm.GenBCode.run(GenBCode.scala:63)
[error] dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:308)
[error] scala.collection.immutable.List.map(List.scala:246)
[error] dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:309)
[error] dotty.tools.backend.jvm.GenBCode.runOn(GenBCode.scala:71)
[error] dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:261)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323)
[error] dotty.tools.dotc.Run.runPhases$5(Run.scala:272)
[error] dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:280)
[error] scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
[error] dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:68)
[error] dotty.tools.dotc.Run.compileUnits(Run.scala:289)
[error] dotty.tools.dotc.Run.compileSources(Run.scala:222)
[error] dotty.tools.dotc.Run.compile(Run.scala:206)
[error] dotty.tools.dotc.Driver.doCompile(Driver.scala:39)
[error] dotty.tools.xsbt.CompilerBridgeDriver.run(CompilerBridgeDriver.java:88)
[error] dotty.tools.xsbt.CompilerBridge.run(CompilerBridge.java:22)
[error] sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:91)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$7(MixedAnalyzingCompiler.scala:192)
[error] scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
[error] sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:247)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:182)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4$adapted(MixedAnalyzingCompiler.scala:163)
[error] sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:239)
[error] sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:163)
[error] sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:210)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:528)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:528)
[error] sbt.internal.inc.Incremental$.$anonfun$apply$5(Incremental.scala:177)
[error] sbt.internal.inc.Incremental$.$anonfun$apply$5$adapted(Incremental.scala:175)
[error] sbt.internal.inc.Incremental$$anon$2.run(Incremental.scala:461)
[error] sbt.internal.inc.IncrementalCommon$CycleState.next(IncrementalCommon.scala:116)
[error] sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:56)
[error] sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:52)
[error] sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:263)
[error] sbt.internal.inc.Incremental$.$anonfun$incrementalCompile$8(Incremental.scala:416)
[error] sbt.internal.inc.Incremental$.withClassfileManager(Incremental.scala:503)
[error] sbt.internal.inc.Incremental$.incrementalCompile(Incremental.scala:403)
[error] sbt.internal.inc.Incremental$.apply(Incremental.scala:169)
[error] sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:528)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:482)
[error] sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:332)
[error] sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:420)
[error] sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:137)
[error] sbt.Defaults$.compileIncrementalTaskImpl(Defaults.scala:2366)
[error] sbt.Defaults$.$anonfun$compileIncrementalTask$2(Defaults.scala:2316)
[error] sbt.internal.server.BspCompileTask$.$anonfun$compute$1(BspCompileTask.scala:30)
[error] sbt.internal.io.Retry$.apply(Retry.scala:46)
[error] sbt.internal.io.Retry$.apply(Retry.scala:28)
[error] sbt.internal.io.Retry$.apply(Retry.scala:23)
[error] sbt.internal.server.BspCompileTask$.compute(BspCompileTask.scala:30)
[error] sbt.Defaults$.$anonfun$compileIncrementalTask$1(Defaults.scala:2314)
[error] scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62)
[error] sbt.std.Transform$$anon$4.work(Transform.scala:68)
[error] sbt.Execute.$anonfun$submit$2(Execute.scala:282)
[error] sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:23)
[error] sbt.Execute.work(Execute.scala:291)
[error] sbt.Execute.$anonfun$submit$1(Execute.scala:282)
[error] sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error] sbt.CompletionService$$anon$2.call(CompletionService.scala:64)
[error] java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error] java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[error] java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error] java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[error] java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[error] java.lang.Thread.run(Thread.java:748)
[error]
[error] stack trace is suppressed; run last Compile / compileIncremental for the full output
[error] (Compile / compileIncremental) scala.tools.asm.MethodTooLargeException: Method too large: parse/Main$.<clinit> ()V
[error] Total time: 2 s, completed 2022-1-5 14:11:19
code
import scala.compiletime.*
import scala.deriving.Mirror
object Main extends App {
trait FromString[A] {
def convert(str: String): A
}
object FromString {
given FromString[Int] = (str) => str.toInt
given FromString[Double] = (str) => str.toDouble
given FromString[String] = (str) => str
}
inline def getTypeclassInstances[F[_], A <: Tuple]: List[F[Any]] =
inline erasedValue[A] match {
case _: EmptyTuple => Nil
case _: (head *: tail) =>
val headTypeClass =
summonInline[F[head]]
val tailTypeClasses =
getTypeclassInstances[F, tail]
headTypeClass.asInstanceOf[F[Any]] :: getTypeclassInstances[F, tail]
}
inline def summonInstancesHelper[F[_], A](using
m: Mirror.Of[A]
): List[F[Any]] =
getTypeclassInstances[F, m.MirroredElemTypes]
case class Data(
ip: String,
method: String,
uri: String,
protocal: String,
httpStatus: Int,
byteSent: Double,
reqLength: Double,
reqTime: Double,
respTime: Double,
referer: String,
device: String
)
val types =
summonInstancesHelper[FromString, Data]
println(types.mkString("\r\n"))
}
Thanks to #bishabosha, it figures out:
reference: https://github.com/lampepfl/dotty/issues/14213
Hope it help others.
inline def getTypeclassInstances[F[_], A <: Tuple]: List[F[Any]] =
inline erasedValue[A] match {
case _: EmptyTuple => Nil
case _: (head *: tail) =>
val headTypeClass =
summonInline[F[head]]
val tailTypeClasses =
getTypeclassInstances[F, tail]
- headTypeClass.asInstanceOf[F[Any]] :: getTypeclassInstances[F, tail]
+ headTypeClass.asInstanceOf[F[Any]] :: tailTypeClasses
}
in general though this could still crash with a very large case class - perhaps you can change headTypeClass and tailTypeClasses to def instead of val.
inline def getTypeclassInstances[F[_], A <: Tuple]: List[F[Any]] =
inline erasedValue[A] match {
case _: EmptyTuple => Nil
case _: (head *: tail) =>
//use def rather than val
def headTypeClass =
summonInline[F[head]]
def tailTypeClasses =
getTypeclassInstances[F, tail]
headTypeClass.asInstanceOf[F[Any]] :: tailTypeClasses
}

Sbt test errors with java.lang.AssertionError: assertion failed

I've converted a boolean attribute of 3 case classes with following
import slick.ast.BaseTypedType
import slick.jdbc.JdbcType
import slick.jdbc.MySQLProfile.api._
import spray.json._
sealed trait Activeness {
def unary_! : Activeness = Activeness(!this.value)
override def toString: String = value.toString
def value: Boolean
}
object Activeness extends DefaultJsonProtocol {
case object Active extends Activeness {
override def value: Boolean = true
}
case object Inactive extends Activeness {
override def value: Boolean = false
}
def apply(value: Boolean): Activeness = if (value) Active else Inactive
val active: Activeness = Active
val inactive: Activeness = Inactive
implicit val activenessColumnType: JdbcType[Activeness] with BaseTypedType[Activeness] =
MappedColumnType.base[Activeness, Boolean](_.value, Activeness.apply)
implicit lazy val activenessFormat: RootJsonFormat[Activeness] = new RootJsonFormat[Activeness] {
override def write(obj: Activeness): JsValue = JsBoolean(obj.value)
override def read(json: JsValue): Activeness = {
apply(
json match {
case JsNumber(n) if n == 1 => true
case JsNumber(n) if n == 0 => false
case JsString("1") => true
case JsString("0") => false
case JsBoolean(true) => true
case JsBoolean(false) => false
case JsString("true") => true
case JsString("false") => false
case _ => deserializationError("Not a boolean")
}
)
}
}
}
code compiles fine but running sbt test I get following
[error] java.lang.AssertionError: assertion failed:
[error] static
[error] while compiling: /Users/user/project/modules/api/src/test/scala/visits/validation/VisitsValidatorTest.scala
[error] during phase: delambdafy
[error] library version: version 2.13.4
[error] compiler version: version 2.13.4
[error] reconstructed args: -bootclasspath ...
[error]
[error] last tree to typer: TypeTree(class OrderIndex)
[error] tree position: line 357 of /Users/user/project/modules/api/src/test/scala/visits/service/VisitScheduleStudyEnvironmentServiceTest.scala
[error] tree tpe: com.mdsol.strategicmonitoring.visits.model.OrderIndex
[error] symbol: (final case) class OrderIndex in package model
[error] symbol definition: final case class OrderIndex extends Product with Serializable (a ClassSymbol)
[error] symbol package: com.mdsol.strategicmonitoring.visits.model
[error] symbol owners: class OrderIndex
[error] call site: method constructMonadic in package validation
[error]
[error] == Source file context for tree position ==
[error]
[error] 354 it should "create a visit schedule for shared study" in {
[error] 355 val visitSchedule = aVisitSchedule()
[error] 356 val risk =
[error] 357 random[RiskCategoryClientDivisionScheme].copy(uuid = visitSchedule.riskCategoryCdsUuid, clientDivisionSchemeUuid = visitSchedule.clientDivisionSchemeUuid)
[error] 358 val se = random[CachedPlinthStudyEnvironment]
[error] 359 val sap = random[CachedPlinthStudyAppPartnership].copy(receiverClientDivisionSchemeUuid = visitSchedule.clientDivisionSchemeUuid)
[error] 360 mockWriteSeVisitSettingsAuth(userUri, se1Uuid)
[error] at scala.reflect.internal.SymbolTable.throwAssertionError(SymbolTable.scala:170)
[error] at scala.tools.nsc.transform.Delambdafy$DelambdafyTransformer.transformFunction(Delambdafy.scala:257)
[error] at scala.tools.nsc.transform.Delambdafy$DelambdafyTransformer.transform(Delambdafy.scala:292)
[error] at scala.tools.nsc.transform.Delambdafy$DelambdafyTransformer.transform(Delambdafy.scala:68)
[error] at scala.reflect.internal.Trees$Block.transform(Trees.scala:556)
[error] at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.transform(TypingTransformers.scala:57)
[error] at scala.tools.nsc.transform.Delambdafy$DelambdafyTransformer.transform(Delambdafy.scala:321)
[error] at scala.tools.nsc.transform.Delambdafy$DelambdafyTransformer.transform(Delambdafy.scala:68)
[error] at scala.reflect.api.Trees$Transformer.transformTrees(Trees.scala:2591)
[error] at scala.reflect.internal.Trees$Apply.transform(Trees.scala:786)
[error] at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.transform(TypingTransformers.scala:57)
[error] at scala.tools.nsc.transform.Delambdafy$DelambdafyTransformer.transform(Delambdafy.scala:321)
[error] at scala.tools.nsc.transform.Delambdafy$DelambdafyTransformer.transform(Delambdafy.scala:68)
[error] at scala.reflect.internal.Trees$DefDef.$anonfun$transform$5(Trees.scala:453)
[error] at scala.reflect.api.Trees$Transformer.atOwner(Trees.scala:2633)
[error] at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:43)
[error] at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:38)
[error] at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:32)
[error] at scala.reflect.internal.Trees$DefDef.transform(Trees.scala:451)
[error] at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.transform(TypingTransformers.scala:57)
[error] at scala.tools.nsc.transform.Delambdafy$DelambdafyTransformer.transform(Delambdafy.scala:321)
[error] at scala.tools.nsc.transform.Delambdafy$DelambdafyTransformer.transform(Delambdafy.scala:68)
[error] at scala.reflect.api.Trees$Transformer.$anonfun$transformStats$1(Trees.scala:2622)
[error] at scala.reflect.api.Trees$Transformer.transformStats(Trees.scala:2620)
[error] at scala.reflect.internal.Trees$Template.transform(Trees.scala:544)
[error] at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.$anonfun$transform$1(TypingTransformers.scala:53)
[error] at scala.reflect.api.Trees$Transformer.atOwner(Trees.scala:2633)
[error] at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:43)
[error] at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.transform(TypingTransformers.scala:38)
[error] at scala.tools.nsc.transform.Delambdafy$DelambdafyTransformer.transform(Delambdafy.scala:306)
[error] at scala.tools.nsc.transform.Delambdafy$DelambdafyTransformer.transform(Delambdafy.scala:68)
[error] at scala.reflect.api.Trees$Transformer.transformTemplate(Trees.scala:2595)
[error] at scala.reflect.internal.Trees$ClassDef.$anonfun$transform$2(Trees.scala:361)
[error] at scala.reflect.api.Trees$Transformer.atOwner(Trees.scala:2633)
[error] at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:43)
[error] at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:38)
[error] at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:32)
[error] at scala.reflect.internal.Trees$ClassDef.transform(Trees.scala:360)
[error] at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.transform(TypingTransformers.scala:57)
[error] at scala.tools.nsc.transform.Delambdafy$DelambdafyTransformer.transform(Delambdafy.scala:321)
[error] at scala.tools.nsc.transform.Delambdafy$DelambdafyTransformer.transform(Delambdafy.scala:68)
[error] at scala.reflect.api.Trees$Transformer.$anonfun$transformStats$1(Trees.scala:2622)
[error] at scala.reflect.api.Trees$Transformer.transformStats(Trees.scala:2620)
[error] at scala.reflect.internal.Trees$PackageDef.$anonfun$transform$1(Trees.scala:342)
[error] at scala.reflect.api.Trees$Transformer.atOwner(Trees.scala:2633)
[error] at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:43)
[error] at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:38)
[error] at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:32)
[error] at scala.reflect.internal.Trees$PackageDef.transform(Trees.scala:342)
[error] at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.$anonfun$transform$2(TypingTransformers.scala:55)
[error] at scala.reflect.api.Trees$Transformer.atOwner(Trees.scala:2633)
[error] at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:43)
[error] at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.transform(TypingTransformers.scala:38)
[error] at scala.tools.nsc.transform.Delambdafy$DelambdafyTransformer.transform(Delambdafy.scala:321)
[error] at scala.tools.nsc.ast.Trees$Transformer.transformUnit(Trees.scala:182)
[error] at scala.tools.nsc.transform.Transform$Phase.apply(Transform.scala:32)
[error] at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:454)
[error] at scala.tools.nsc.Global$GlobalPhase.run(Global.scala:401)
[error] at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1515)
[error] at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1499)
[error] at scala.tools.nsc.Global$Run.compileSources(Global.scala:1491)
[error] at scala.tools.nsc.Global$Run.compileFiles(Global.scala:1605)
[error] at xsbt.CachedCompiler0.run(CompilerBridge.scala:163)
[error] at xsbt.CachedCompiler0.run(CompilerBridge.scala:134)
[error] at xsbt.CompilerBridge.run(CompilerBridge.scala:39)
[error] at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:92)
[error] at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$7(MixedAnalyzingCompiler.scala:186)
[error] at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
[error] at sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:241)
[error] at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:176)
[error] at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4$adapted(MixedAnalyzingCompiler.scala:157)
[error] at sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:239)
[error] at sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:157)
[error] at sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:204)
[error] at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:573)
[error] at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:573)
[error] at sbt.internal.inc.Incremental$.$anonfun$apply$5(Incremental.scala:174)
[error] at sbt.internal.inc.Incremental$.$anonfun$apply$5$adapted(Incremental.scala:172)
[error] at sbt.internal.inc.Incremental$$anon$2.run(Incremental.scala:459)
[error] at sbt.internal.inc.IncrementalCommon$CycleState.next(IncrementalCommon.scala:116)
[error] at sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:56)
[error] at sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:52)
[error] at sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:261)
[error] at sbt.internal.inc.Incremental$.$anonfun$incrementalCompile$8(Incremental.scala:414)
[error] at sbt.internal.inc.Incremental$.withClassfileManager(Incremental.scala:499)
[error] at sbt.internal.inc.Incremental$.incrementalCompile(Incremental.scala:401)
[error] at sbt.internal.inc.Incremental$.apply(Incremental.scala:166)
[error] at sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:573)
[error] at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:491)
[error] at sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:332)
[error] at sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:420)
[error] at sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:137)
[error] at sbt.Defaults$.compileIncrementalTaskImpl(Defaults.scala:2177)
[error] at sbt.Defaults$.$anonfun$compileIncrementalTask$2(Defaults.scala:2134)
[error] at sbt.internal.io.Retry$.apply(Retry.scala:40)
[error] at sbt.internal.io.Retry$.apply(Retry.scala:23)
[error] at sbt.internal.server.BspCompileTask$.compute(BspCompileTask.scala:31)
[error] at sbt.Defaults$.$anonfun$compileIncrementalTask$1(Defaults.scala:2130)
[error] at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62)
[error] at sbt.std.Transform$$anon$4.work(Transform.scala:68)
[error] at sbt.Execute.$anonfun$submit$2(Execute.scala:282)
[error] at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:23)
[error] at sbt.Execute.work(Execute.scala:291)
[error] at sbt.Execute.$anonfun$submit$1(Execute.scala:282)
[error] at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error] at sbt.CompletionService$$anon$2.call(CompletionService.scala:64)
[error] at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[error] at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[error] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[error] at java.lang.Thread.run(Thread.java:748)
[error] (api / Test / compileIncremental) java.lang.AssertionError: assertion failed:
[error] static
[error] while compiling: /Users/user/project/modules/api/src/test/scala/visits/validation/VisitsValidatorTest.scala
[error] during phase: delambdafy
[error] library version: version 2.13.4
[error] compiler version: version 2.13.4
[error] reconstructed args: -bootclasspath ...
[error]
[error] last tree to typer: TypeTree(class OrderIndex)
[error] tree position: line 357 of /Users/user/project/modules/api/src/test/scala/visits/service/VisitScheduleStudyEnvironmentServiceTest.scala
[error] tree tpe: com.mdsol.strategicmonitoring.visits.model.OrderIndex
[error] symbol: (final case) class OrderIndex in package model
[error] symbol definition: final case class OrderIndex extends Product with Serializable (a ClassSymbol)
[error] symbol package: com.mdsol.strategicmonitoring.visits.model
[error] symbol owners: class OrderIndex
[error] call site: method constructMonadic in package validation
[error]
[error] == Source file context for tree position ==
[error]
[error] 354 it should "create a visit schedule for shared study" in {
[error] 355 val visitSchedule = aVisitSchedule()
[error] 356 val risk =
[error] 357 random[RiskCategoryClientDivisionScheme].copy(uuid = visitSchedule.riskCategoryCdsUuid, clientDivisionSchemeUuid = visitSchedule.clientDivisionSchemeUuid)
[error] 358 val se = random[CachedPlinthStudyEnvironment]
[error] 359 val sap = random[CachedPlinthStudyAppPartnership].copy(receiverClientDivisionSchemeUuid = visitSchedule.clientDivisionSchemeUuid)
[error] 360 mockWriteSeVisitSettingsAuth(userUri, se1Uuid)
[error] (api-test / Test / test) sbt.TestsFailedException: Tests unsuccessful
[error] Total time: 251 s (04:11), completed Jan 31, 2021 8:11:19 PM
✔ ~/project [develop|●1✚ 46]
20:11 $
Any ideas/pointers?

Creating a Scala macro that expands into a class definition

As the title suggests, I am trying to create a Scala macro that generates a class definition. Basically I want to eventually do the following:
classify("StandardEvent", Map("name" -> String, "id" -> Int))
// should at compile-time expand to
case class StandardEvent(name: String, id: Int) extends Event
Is that even possible? And if so, could anyone point me into the right direction on how to do so? Actually, I cannot even get the following simple macro to work:
// Macro definition:
def classify(): Unit =
macro classifyImpl
def classifyImpl(c: Context)(): c.Tree = {
import c.universe._
q"class SomeClass"
}
// Macro usage in seperate compilation unit
classify()
val s = new SomeClass
This gets me the following error message:
[error] ClassifyTest.scala:6: not found: type SomeClass
[error] val s = new SomeClass
[error] ^
[trace] Stack trace suppressed: run last app/compile:compileIncremental for the full output.
[error] (app/compile:compileIncremental) java.lang.AssertionError: assertion failed:
[error] class SomeClass extends scala.AnyRef {
[error] def <init>() = {
[error] super.<init>();
[error] ()
[error] }
[error] }
[error] while compiling: ClassifyTest.scala
[error] during phase: typer
[error] library version: version 2.11.8
[error] compiler version: version 2.11.8
[error] reconstructed args: -bootclasspath // ...
[error]
[error] last tree to typer: type SomeClass
[error] tree position: line 5 of ClassifyTest.scala
[error] symbol: <none>
[error] symbol definition: <none> (a NoSymbol)
[error] symbol package: <none>
[error] symbol owners:
[error] call site: <none> in <none>
[error]
[error] == Source file context for tree position ==
[error]
[error] 2 object ClassifyTest extends App {
[error] 3
[error] 4 classify()
[error] 5 val s = new SomeClass
[error] 6
[error] 7 }
Can anyone make sense of this? Help is much appreciated.

Macro annotations and type parameter

I'm not sure whether its duplicate of Type Parameters on Scala Macro Annotations or not.
I'm trying to get type parameter on macro annotation:
class builder extends StaticAnnotation {
def macroTransform(annottees: Any*) = macro builderMacro.impl
}
//....
val q"new $_[$tpt]().macroTransform(..$_)" = c.macroApplication
val tpe = c.typecheck(tpt).tpe
// also tried
// val tpe = c.typecheck(q"None.asInstanceOf[$tpt]").tpe
Code that uses macro:
object Test2 {
trait TestBuilders
#builder[TestBuilders]
case class TestClass(x: Int, opt1: Option[String], opt2: Option[String]) {
val opts = (opt1, opt2)
}
}
and exception i get:
[error] scala.reflect.macros.TypecheckException: not found: type TestBuilders
[error] at scala.reflect.macros.contexts.Typers$$anonfun$typecheck$2$$anonfun$apply$1.apply(Typers.scala:34)
[error] at scala.reflect.macros.contexts.Typers$$anonfun$typecheck$2$$anonfun$apply$1.apply(Typers.scala:28)
[error] at scala.tools.nsc.typechecker.Contexts$Context.withMode(Contexts.scala:374)
[error] at scala.reflect.macros.contexts.Typers$$anonfun$3.apply(Typers.scala:24)
[error] at scala.reflect.macros.contexts.Typers$$anonfun$3.apply(Typers.scala:24)
[error] at scala.reflect.macros.contexts.Typers$$anonfun$withContext$1$1.apply(Typers.scala:25)
[error] at scala.reflect.macros.contexts.Typers$$anonfun$withContext$1$1.apply(Typers.scala:25)
[error] at scala.tools.nsc.typechecker.Contexts$Context.withMode(Contexts.scala:374)
[error] at scala.reflect.macros.contexts.Typers$$anonfun$1.apply(Typers.scala:23)
[error] at scala.reflect.macros.contexts.Typers$$anonfun$1.apply(Typers.scala:23)
[error] at scala.reflect.macros.contexts.Typers$class.withContext$1(Typers.scala:25)
[error] at scala.reflect.macros.contexts.Typers$$anonfun$typecheck$2.apply(Typers.scala:28)
[error] at scala.reflect.macros.contexts.Typers$$anonfun$typecheck$2.apply(Typers.scala:28)
[error] at scala.reflect.internal.Trees$class.wrappingIntoTerm(Trees.scala:1691)
[error] at scala.reflect.internal.SymbolTable.wrappingIntoTerm(SymbolTable.scala:16)
[error] at scala.reflect.macros.contexts.Typers$class.withWrapping$1(Typers.scala:26)
[error] at scala.reflect.macros.contexts.Typers$class.typecheck(Typers.scala:28)
[error] at scala.reflect.macros.contexts.Context.typecheck(Context.scala:6)
[error] at scala.reflect.macros.contexts.Context.typecheck(Context.scala:6)
[error] at builderMacro$.impl(Macros.scala:55)
what am i doing wrong?
This is a known issue in current macro paradise: https://github.com/scalamacros/paradise/issues/14. Note that if TestBuilders is declared in a different scope, everything should work out.

Getting "how can getCommonSuperclass() do its job if different class symbols get the same bytecode-level internal name" compile error

My Play 2.1.1 project uses SBT 0.12.3, and when compiling it on my dev machine, everything's fine, I get no errors, and the app runs without any issues. When I try to compile it on an EC2 instance used for testing, I get the superlong error message below. The only possibly relevant difference between the two environments is that I have java 6 (1.6.0_45) on my dev machine, and java 7 (1.7.0_19) on EC2, but I can't currently change neither. Have you ever seen something like this? What can this be about? Thanks!
[error] uncaught exception during compilation: java.lang.AssertionError
[error] (compile:compile) java.lang.AssertionError: assertion failed:
[error] while compiling: /home/ec2-user/chat/target/scala-2.10/src_managed/main/routes_routing.scala
[error] during phase: jvm
[error] library version: version 2.10.0
[error] compiler version: version 2.10.0
[error] reconstructed args: -classpath /home/ec2-user/chat/target/scala-2.10/classes:/home/ec2-user/play-2.1.1/repository/local/play/play_2.10/2.1.1/jars/play_2.10.jar:/home/ec2-user/play-2.1.1/repository/local/play/sbt-link/2.1.1/jars/sbt-link.jar:/home/ec2-user/play-2.1.1/repository/local/org.javassist/javassist/3.16.1-GA/jars/javassist.jar:/home/ec2-user/play-2.1.1/repository/local/play/play-exceptions/2.1.1/jars/play-exceptions.jar:/home/ec2-user/play-2.1.1/repository/local/play/templates_2.10/2.1.1/jars/templates_2.10.jar:/home/ec2-user/play-2.1.1/repository/local/com.github.scala-incubator.io/scala-io-file_2.10/0.4.2/jars/scala-io-file_2.10.jar:/home/ec2-user/play-2.1.1/repository/local/com.github.scala-incubator.io/scala-io-core_2.10/0.4.2/jars/scala-io-core_2.10.jar:/home/ec2-user/play-2.1.1/repository/local/com.jsuereth/scala-arm_2.10/1.3/jars/scala-arm_2.10.jar:/home/ec2-user/play-2.1.1/repository/local/play/play-iteratees_2.10/2.1.1/jars/play-iteratees_2.10.jar:/home/ec2-user/play-2.1.1/repository/local/org.scala-stm/scala-stm_2.10.0/0.6/jars/scala-stm_2.10.0.jar:/home/ec2-user/play-2.1.1/repository/local/com.typesafe/config/1.0.0/bundles/config.jar:/home/ec2-user/play-2.1.1/repository/local/org.slf4j/jul-to-slf4j/1.6.6/jars/jul-to-slf4j.jar:/home/ec2-user/play-2.1.1/repository/local/org.slf4j/jcl-over-slf4j/1.6.6/jars/jcl-over-slf4j.jar:/home/ec2-user/play-2.1.1/repository/local/com.typesafe.akka/akka-actor_2.10/2.1.0/bundles/akka-actor_2.10.jar:/home/ec2-user/play-2.1.1/repository/local/com.typesafe.akka/akka-slf4j_2.10/2.1.0/bundles/akka-slf4j_2.10.jar:/home/ec2-user/play-2.1.1/repository/local/joda-time/joda-time/2.1/jars/joda-time.jar:/home/ec2-user/play-2.1.1/repository/local/org.joda/joda-convert/1.2/jars/joda-convert.jar:/home/ec2-user/play-2.1.1/repository/local/org.apache.commons/commons-lang3/3.1/jars/commons-lang3.jar:/home/ec2-user/play-2.1.1/repository/local/com.ning/async-http-client/1.7.6/jars/async-http-client.jar:/home/ec2-user/play-2.1.1/repository/local/oauth.signpost/signpost-core/1.2.1.2/jars/signpost-core.jar:/home/ec2-user/play-2.1.1/repository/local/oauth.signpost/signpost-commonshttp4/1.2.1.2/jars/signpost-commonshttp4.jar:/home/ec2-user/play-2.1.1/repository/local/org.apache.httpcomponents/httpcore/4.0.1/jars/httpcore.jar:/home/ec2-user/play-2.1.1/repository/local/org.apache.httpcomponents/httpclient/4.0.1/jars/httpclient.jar:/home/ec2-user/play-2.1.1/repository/local/commons-logging/commons-logging/1.1.1/jars/commons-logging.jar:/home/ec2-user/play-2.1.1/repository/local/org.codehaus.jackson/jackson-core-asl/1.9.10/jars/jackson-core-asl.jar:/home/ec2-user/play-2.1.1/repository/local/org.codehaus.jackson/jackson-mapper-asl/1.9.10/jars/jackson-mapper-asl.jar:/home/ec2-user/play-2.1.1/repository/local/net.sf.ehcache/ehcache-core/2.6.0/jars/ehcache-core.jar:/home/ec2-user/play-2.1.1/repository/local/javax.transaction/jta/1.1/jars/jta.jar:/home/ec2-user/play-2.1.1/repository/local/org.scala-lang/scala-reflect/2.10.0/jars/scala-reflect.jar:/home/ec2-user/play-2.1.1/repository/local/play/play-jdbc_2.10/2.1.1/jars/play-jdbc_2.10.jar:/home/ec2-user/play-2.1.1/repository/local/play/play-java_2.10/2.1.1/jars/play-java_2.10.jar:/home/ec2-user/play-2.1.1/repository/local/org.yaml/snakeyaml/1.10/bundles/snakeyaml.jar:/home/ec2-user/play-2.1.1/repository/local/org.hibernate/hibernate-validator/4.3.0.Final/jars/hibernate-validator.jar:/home/ec2-user/play-2.1.1/repository/local/javax.validation/validation-api/1.0.0.GA/jars/validation-api.jar:/home/ec2-user/play-2.1.1/repository/local/org.jboss.logging/jboss-logging/3.1.0.CR2/jars/jboss-logging.jar:/home/ec2-user/play-2.1.1/repository/local/org.springframework/spring-context/3.1.2.RELEASE/jars/spring-context.jar:/home/ec2-user/play-2.1.1/repository/local/org.springframework/spring-core/3.1.2.RELEASE/jars/spring-core.jar:/home/ec2-user/play-2.1.1/repository/local/org.springframework/spring-beans/3.1.2.RELEASE/jars/spring-beans.jar:/home/ec2-user/play-2.1.1/repository/local/org.reflections/reflections/0.9.8/jars/reflections.jar:/home/ec2-user/play-2.1.1/repository/local/com.google.guava/guava/13.0.1/jars/guava.jar:/home/ec2-user/play-2.1.1/repository/local/com.google.code.findbugs/jsr305/2.0.1/jars/jsr305.jar:/home/ec2-user/play-2.1.1/repository/local/javax.servlet/javax.servlet-api/3.0.1/jars/javax.servlet-api.jar:/home/ec2-user/play-2.1.1/repository/local/com.jolbox/bonecp/0.7.1.RELEASE/bundles/bonecp.jar:/home/ec2-user/play-2.1.1/repository/local/com.h2database/h2/1.3.168/jars/h2.jar:/home/ec2-user/play-2.1.1/repository/local/tyrex/tyrex/1.0.1/jars/tyrex.jar:/home/ec2-user/play-2.1.1/repository/local/play/anorm_2.10/2.1.1/jars/anorm_2.10.jar:/home/ec2-user/play-2.1.1/repository/cache/org.reactivemongo/play2-reactivemongo_2.10/jars/play2-reactivemongo_2.10-0.9.jar:/home/ec2-user/play-2.1.1/repository/cache/org.reactivemongo/reactivemongo_2.10/jars/reactivemongo_2.10-0.9.jar:/home/ec2-user/play-2.1.1/repository/cache/org.reactivemongo/reactivemongo-bson-macros_2.10/jars/reactivemongo-bson-macros_2.10-0.9.jar:/home/ec2-user/play-2.1.1/repository/cache/org.reactivemongo/reactivemongo-bson_2.10/jars/reactivemongo-bson_2.10-0.9.jar:/home/ec2-user/play-2.1.1/framework/sbt/boot/scala-2.10.0/lib/scala-compiler.jar:/home/ec2-user/play-2.1.1/repository/cache/io.netty/netty/bundles/netty-3.6.5.Final.jar:/home/ec2-user/play-2.1.1/repository/cache/ch.qos.logback/logback-core/jars/logback-core-1.0.11.jar:/home/ec2-user/play-2.1.1/repository/cache/ch.qos.logback/logback-classic/jars/logback-classic-1.0.11.jar:/home/ec2-user/play-2.1.1/repository/cache/org.slf4j/slf4j-api/jars/slf4j-api-1.7.4.jar:/home/ec2-user/play-2.1.1/repository/cache/org.scribe/scribe/jars/scribe-1.3.3.jar:/home/ec2-user/play-2.1.1/repository/local/commons-codec/commons-codec/1.4/jars/commons-codec.jar -encoding utf8 -deprecation -bootclasspath /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.19.x86_64/jre/lib/resources.jar:/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.19.x86_64/jre/lib/rt.jar:/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.19.x86_64/jre/lib/sunrsasign.jar:/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.19.x86_64/jre/lib/jsse.jar:/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.19.x86_64/jre/lib/jce.jar:/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.19.x86_64/jre/lib/charsets.jar:/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.19.x86_64/jre/lib/netx.jar:/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.19.x86_64/jre/lib/plugin.jar:/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.19.x86_64/jre/lib/rhino.jar:/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.19.x86_64/jre/lib/jfr.jar:/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.19.x86_64/jre/classes:/home/ec2-user/play-2.1.1/framework/sbt/boot/scala-2.10.0/lib/scala-library.jar -unchecked -d /home/ec2-user/chat/target/scala-2.10/classes
[error]
[error] last tree to typer: Literal(Constant(String))
[error] symbol: null
[error] symbol definition: null
[error] tpe: Class(classOf[java.lang.String])
[error] symbol owners:
[error] context owners: anonymous class anonfun$routes$1 -> package <empty>
[error]
[error] == Enclosing template or block ==
[error]
[error] Template( // val <local $anonfun>: <notype>, tree.tpe=anonfun$routes$1
[error] "scala.runtime.AbstractPartialFunction", "scala.Serializable" // parents
[error] ValDef(
[error] private
[error] "_"
[error] <tpt>
[error] <empty>
[error] )
[error] // 5 statements
[error] DefDef( // final override def applyOrElse(x$1: play.api.mvc.RequestHeader,default: Function1): Object
[error] <method> final override <triedcooking>
[error] "applyOrElse"
[error] []
[error] // 1 parameter list
[error] ValDef( // x$1: play.api.mvc.RequestHeader
[error] <param> <synthetic> <triedcooking>
[error] "x$1"
[error] <tpt> // tree.tpe=play.api.mvc.RequestHeader
[error] <empty>
[error] )
...fifteen hundred lines more of such gibberish, and finally...
[error] )
[error] )
[error] DefDef( // def <init>(): anonfun$routes$1
[error] <method> <triedcooking>
[error] "<init>"
[error] []
[error] List(Nil)
[error] <tpt> // tree.tpe=anonfun$routes$1
[error] Block( // tree.tpe=Unit
[error] Apply( // def <init>(): scala.runtime.AbstractPartialFunction in class AbstractPartialFunction, tree.tpe=scala.runtime.AbstractPartialFunction
[error] Routes$$anonfun$routes$1.super."<init>" // def <init>(): scala.runtime.AbstractPartialFunction in class AbstractPartialFunction, tree.tpe=()scala.runtime.AbstractPartialFunction
[error] Nil
[error] )
[error] ()
[error] )
[error] )
[error] )
[error]
[error] == Expanded type of tree ==
[error]
[error] ConstantType(value = Constant(String))
[error]
[error] how can getCommonSuperclass() do its job if different class symbols get the same bytecode-level internal name: models/messages/package$Open
The reason of such behaviour described a bit here.
In my case I've just move some classes from package object to normal object, and this is solved the problem. I think you should consider transformation of models/messages/package.scala to normal object.