mirror of https://github.com/sbt/sbt.git
[2.x] refactor: Add tailrec annotation (#9591)
This commit is contained in:
parent
354dbf515b
commit
d9f60b6cfd
|
|
@ -10,6 +10,7 @@ package sbt
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.nio.file.Path as NioPath
|
import java.nio.file.Path as NioPath
|
||||||
import java.net.URI
|
import java.net.URI
|
||||||
|
import scala.annotation.tailrec
|
||||||
// import Project._
|
// import Project._
|
||||||
import Keys.{
|
import Keys.{
|
||||||
stateBuildStructure,
|
stateBuildStructure,
|
||||||
|
|
@ -616,6 +617,7 @@ trait ProjectExtra extends Scoped.Syntax:
|
||||||
projectRef: ProjectRef
|
projectRef: ProjectRef
|
||||||
): Seq[ProjectRef] = {
|
): Seq[ProjectRef] = {
|
||||||
def dependencies(map: Map[ProjectRef, Seq[ProjectRef]], id: ProjectRef): Set[ProjectRef] = {
|
def dependencies(map: Map[ProjectRef, Seq[ProjectRef]], id: ProjectRef): Set[ProjectRef] = {
|
||||||
|
@tailrec
|
||||||
def helper(map: Map[ProjectRef, Seq[ProjectRef]], acc: Set[ProjectRef]): Set[ProjectRef] =
|
def helper(map: Map[ProjectRef, Seq[ProjectRef]], acc: Set[ProjectRef]): Set[ProjectRef] =
|
||||||
if (acc.exists(map.contains)) {
|
if (acc.exists(map.contains)) {
|
||||||
val (kept, rem) = map.partition { case (k, _) => acc(k) }
|
val (kept, rem) = map.partition { case (k, _) => acc(k) }
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ import java.io.File
|
||||||
import java.net.URI
|
import java.net.URI
|
||||||
import java.nio.file.{ Files, Paths }
|
import java.nio.file.{ Files, Paths }
|
||||||
import java.util.concurrent.TimeoutException
|
import java.util.concurrent.TimeoutException
|
||||||
|
import scala.annotation.tailrec
|
||||||
import scala.concurrent.duration.*
|
import scala.concurrent.duration.*
|
||||||
import scala.util.{ Failure, Success }
|
import scala.util.{ Failure, Success }
|
||||||
|
|
||||||
|
|
@ -303,6 +304,7 @@ class BuildServerTest extends AbstractServerTest {
|
||||||
"diagnostics for Diagnostics.scala after a failed compile (#9345)"
|
"diagnostics for Diagnostics.scala after a failed compile (#9345)"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@tailrec
|
||||||
def drainQueuedNotificationsAndFailOnForbiddenReset(): Unit =
|
def drainQueuedNotificationsAndFailOnForbiddenReset(): Unit =
|
||||||
svr.session.waitForNotificationMsg(Duration.Zero)(_ => true) match {
|
svr.session.waitForNotificationMsg(Duration.Zero)(_ => true) match {
|
||||||
case Success(n) =>
|
case Success(n) =>
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ import sbt.nio.file.{ **, FileTreeView }
|
||||||
import sbt.nio.file.syntax.*
|
import sbt.nio.file.syntax.*
|
||||||
import sbt.util.CacheImplicits
|
import sbt.util.CacheImplicits
|
||||||
import scala.reflect.ClassTag
|
import scala.reflect.ClassTag
|
||||||
import scala.annotation.{ meta, StaticAnnotation }
|
import scala.annotation.{ meta, tailrec, StaticAnnotation }
|
||||||
import scala.collection.mutable
|
import scala.collection.mutable
|
||||||
import scala.util.control.NonFatal
|
import scala.util.control.NonFatal
|
||||||
import sjsonnew.{ HashWriter, JsonFormat }
|
import sjsonnew.{ HashWriter, JsonFormat }
|
||||||
|
|
@ -329,6 +329,7 @@ object ActionCache:
|
||||||
)
|
)
|
||||||
|
|
||||||
/** Walks `t`'s cause chain for a `NoSuchFileException`, returning the missing file's path. */
|
/** Walks `t`'s cause chain for a `NoSuchFileException`, returning the missing file's path. */
|
||||||
|
@tailrec
|
||||||
private[sbt] def findMissingFile(t: Throwable): Option[String] =
|
private[sbt] def findMissingFile(t: Throwable): Option[String] =
|
||||||
t match
|
t match
|
||||||
case null => None
|
case null => None
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ package sbt.internal.util
|
||||||
import org.scalacheck.*
|
import org.scalacheck.*
|
||||||
import Prop.*
|
import Prop.*
|
||||||
|
|
||||||
|
import scala.annotation.tailrec
|
||||||
import scala.collection.mutable.HashSet
|
import scala.collection.mutable.HashSet
|
||||||
|
|
||||||
object DagSpecification extends Properties("Dag") {
|
object DagSpecification extends Properties("Dag") {
|
||||||
|
|
@ -41,6 +42,7 @@ object DagSpecification extends Properties("Dag") {
|
||||||
private def isSet[T](c: Seq[T]) = Set(c*).size == c.size
|
private def isSet[T](c: Seq[T]) = Set(c*).size == c.size
|
||||||
private def dependenciesPrecedeNodes(sort: List[TestDag]) = {
|
private def dependenciesPrecedeNodes(sort: List[TestDag]) = {
|
||||||
val seen = new HashSet[TestDag]
|
val seen = new HashSet[TestDag]
|
||||||
|
@tailrec
|
||||||
def iterate(remaining: List[TestDag]): Boolean = {
|
def iterate(remaining: List[TestDag]): Boolean = {
|
||||||
remaining match {
|
remaining match {
|
||||||
case Nil => true
|
case Nil => true
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue