Skip to content

Commit

Permalink
Merge pull request #1012 from eed3si9n/wip/bumputil
Browse files Browse the repository at this point in the history
[1.5.x] updates util and revert #997
  • Loading branch information
eed3si9n authored Dec 15, 2021
2 parents c8c414e + b8710f1 commit 4f07068
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 30 deletions.
32 changes: 5 additions & 27 deletions internal/compiler-bridge/src/main/scala-2.12/xsbt/Compat.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +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 = {
Compat.OriginalTreeTraverser.Instance.traverseOriginal(in)(func)
// 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 {
Expand All @@ -31,32 +35,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[AnyRef](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]]. */
Expand Down
4 changes: 2 additions & 2 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions zinc/src/test/scala/sbt/inc/BaseCompilerSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion zinc/src/test/scala/sbt/inc/IncrementalCompilerSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 }"
Expand Down

0 comments on commit 4f07068

Please sign in to comment.