From 90ada3d4d00faa6d54c3e31f05d1efb88b402a56 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 15 Dec 2021 02:47:33 -0500 Subject: [PATCH 1/4] Update util --- project/Dependencies.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index eb32fe66c2..ceead04ca8 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -14,7 +14,7 @@ object Dependencies { val scala212_213 = Seq(defaultScalaVersion, scala213) private val ioVersion = nightlyVersion.getOrElse("1.5.1") - private val utilVersion = nightlyVersion.getOrElse("1.5.6") + private val utilVersion = nightlyVersion.getOrElse("1.5.7") private val sbtIO = "org.scala-sbt" %% "io" % ioVersion @@ -84,7 +84,7 @@ object Dependencies { } val zeroAllocationHashing = "net.openhft" % "zero-allocation-hashing" % "0.10.1" - def log4jVersion = "2.11.2" + def log4jVersion = "2.16.0" val log4jApi = "org.apache.logging.log4j" % "log4j-api" % log4jVersion val log4jCore = "org.apache.logging.log4j" % "log4j-core" % log4jVersion val log4jSlf4jImpl = "org.apache.logging.log4j" % "log4j-slf4j-impl" % log4jVersion From 347ccf47377268601da1fde4c7315f2a5623579e Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 15 Dec 2021 02:49:56 -0500 Subject: [PATCH 2/4] Revert "Fix ClassCastException in reflective original tree lookup" This reverts commit e0aff5d1ae1ef662dddb164095b9ac631fc112ac. --- internal/compiler-bridge/src/main/scala-2.12/xsbt/Compat.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/compiler-bridge/src/main/scala-2.12/xsbt/Compat.scala b/internal/compiler-bridge/src/main/scala-2.12/xsbt/Compat.scala index 48a691e6f8..49c35d79d6 100644 --- a/internal/compiler-bridge/src/main/scala-2.12/xsbt/Compat.scala +++ b/internal/compiler-bridge/src/main/scala-2.12/xsbt/Compat.scala @@ -42,7 +42,7 @@ object Compat { } catch { case _: Throwable => null } private object Reflective extends OriginalTreeTraverser { - private[this] val ct = scala.reflect.ClassTag[AnyRef](cls) + private[this] val ct = scala.reflect.ClassTag(cls) private[this] val meth = cls.getMethod("original") def traverseOriginal[T <: Global#Tree](t: T)(f: T => Unit): Unit = t.attachments.get(ct) match { From 05d188981466ebbe0812573266a0e7bdd4c837bc Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 15 Dec 2021 02:50:19 -0500 Subject: [PATCH 3/4] Revert "Make accessing OriginalTree noop on Scala 2.12.0-2" This reverts commit 8c5e395c8c1d704501b3e5a27e91b3716f288792. --- .../src/main/scala-2.12/xsbt/Compat.scala | 31 +++---------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/internal/compiler-bridge/src/main/scala-2.12/xsbt/Compat.scala b/internal/compiler-bridge/src/main/scala-2.12/xsbt/Compat.scala index 49c35d79d6..13c9d77249 100644 --- a/internal/compiler-bridge/src/main/scala-2.12/xsbt/Compat.scala +++ b/internal/compiler-bridge/src/main/scala-2.12/xsbt/Compat.scala @@ -22,7 +22,10 @@ abstract class Compat { /** If given tree contains object tree attachment calls func on tree from attachment. */ protected def processOriginalTreeAttachment(in: Tree)(func: Tree => Unit): Unit = { - Compat.OriginalTreeTraverser.Instance.traverseOriginal(in)(func) + import analyzer._ + in.attachments.get[OriginalTreeAttachment].foreach { a => + func(a.original) + } } } object Compat { @@ -31,32 +34,6 @@ object Compat { // IMain in 2.13 accepts ReplReporter def replReporter(settings: Settings, writer: PrintWriter) = writer - - sealed abstract class OriginalTreeTraverser private { - def traverseOriginal[T <: Global#Tree](t: T)(f: T => Unit): Unit - } - - object OriginalTreeTraverser { - private[this] val cls = try { - Class.forName("scala.tools.nsc.typechecker.StdAttachments$OriginalTreeAttachment") - } catch { case _: Throwable => null } - - private object Reflective extends OriginalTreeTraverser { - private[this] val ct = scala.reflect.ClassTag(cls) - private[this] val meth = cls.getMethod("original") - def traverseOriginal[T <: Global#Tree](t: T)(f: T => Unit): Unit = - t.attachments.get(ct) match { - case Some(attachment) => f(meth.invoke(attachment).asInstanceOf[T]) - case None => - } - } - - private object NoOp extends OriginalTreeTraverser { - def traverseOriginal[T <: Global#Tree](t: T)(f: T => Unit): Unit = () - } - - val Instance = if (cls == null) NoOp else Reflective - } } /** Defines compatibility utils for [[ZincCompiler]]. */ From b8710f11eb578a786f6b77f81a04dbb44f466220 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 15 Dec 2021 02:50:34 -0500 Subject: [PATCH 4/4] Revert "Revert "Remove reference to OriginalTreeAttachment in Scala 2.12 bridge"" This reverts commit a57185fa94dee1e434e59bb7f9a6ae47d322f38e. --- .../src/main/scala-2.12/xsbt/Compat.scala | 9 +++++---- .../source-dependencies/constants/{test => disabled} | 0 zinc/src/test/scala/sbt/inc/BaseCompilerSpec.scala | 2 ++ .../src/test/scala/sbt/inc/IncrementalCompilerSpec.scala | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) rename zinc/src/sbt-test/source-dependencies/constants/{test => disabled} (100%) diff --git a/internal/compiler-bridge/src/main/scala-2.12/xsbt/Compat.scala b/internal/compiler-bridge/src/main/scala-2.12/xsbt/Compat.scala index 13c9d77249..a9c129a13b 100644 --- a/internal/compiler-bridge/src/main/scala-2.12/xsbt/Compat.scala +++ b/internal/compiler-bridge/src/main/scala-2.12/xsbt/Compat.scala @@ -22,10 +22,11 @@ abstract class Compat { /** If given tree contains object tree attachment calls func on tree from attachment. */ protected def processOriginalTreeAttachment(in: Tree)(func: Tree => Unit): Unit = { - import analyzer._ - in.attachments.get[OriginalTreeAttachment].foreach { a => - func(a.original) - } + // We can't until we figure out how to conditionally do this for Scala 2.12.3+ + // import analyzer._ + // in.attachments.get[OriginalTreeAttachment].foreach { a => + // func(a.original) + // } } } object Compat { diff --git a/zinc/src/sbt-test/source-dependencies/constants/test b/zinc/src/sbt-test/source-dependencies/constants/disabled similarity index 100% rename from zinc/src/sbt-test/source-dependencies/constants/test rename to zinc/src/sbt-test/source-dependencies/constants/disabled diff --git a/zinc/src/test/scala/sbt/inc/BaseCompilerSpec.scala b/zinc/src/test/scala/sbt/inc/BaseCompilerSpec.scala index 8fafc985bc..7a332ab9ac 100644 --- a/zinc/src/test/scala/sbt/inc/BaseCompilerSpec.scala +++ b/zinc/src/test/scala/sbt/inc/BaseCompilerSpec.scala @@ -49,6 +49,8 @@ class BaseCompilerSpec extends BridgeProviderSpecification { implicit class ProjectSetupOps(setup: ProjectSetup) { def createCompiler(): CompilerSetup = setup.createCompiler(scalaVersion, incOptions) + def createCompiler(scalaVersion: String): CompilerSetup = + setup.createCompiler(scalaVersion, incOptions) private def createCompiler(sv: String, incOptions: IncOptions): CompilerSetup = { val si = scalaInstance(sv, setup.baseDir, Logger.Null) diff --git a/zinc/src/test/scala/sbt/inc/IncrementalCompilerSpec.scala b/zinc/src/test/scala/sbt/inc/IncrementalCompilerSpec.scala index 90501bf5b9..eb4afca004 100644 --- a/zinc/src/test/scala/sbt/inc/IncrementalCompilerSpec.scala +++ b/zinc/src/test/scala/sbt/inc/IncrementalCompilerSpec.scala @@ -192,7 +192,7 @@ class IncrementalCompilerSpec extends BaseCompilerSpec { it should "track dependencies on constants" in withTmpDir { tmp => val project = VirtualSubproject(tmp.toPath / "p1") - val comp = project.setup.createCompiler() + val comp = project.setup.createCompiler("2.13.6") try { val s1 = "object A { final val i = 1 }" val s1b = "object A { final val i = 2 }"