Merge pull request #7888 from xuwei-k/Alternative-CommandBuilder

[2.x] use `extension` instead of `implicit`
This commit is contained in:
eugene yokota 2024-11-16 21:03:28 -05:00 committed by GitHub
commit 312f1a0782
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 8 deletions

View File

@ -98,10 +98,10 @@ class FileCommands(baseDirectory: File) extends BasicStatementHandler {
}
}
private type NamedCommand = (String, List[String] => Unit)
// these are for readability of the command list
implicit def commandBuilder(s: String): CommandBuilder = new CommandBuilder(s)
final class CommandBuilder(commandName: String) {
type NamedCommand = (String, List[String] => Unit)
extension (commandName: String) {
def nonEmpty(action: List[String] => Unit): NamedCommand =
commandName -> { paths =>
if (paths.isEmpty)

View File

@ -9,11 +9,8 @@
package sbt
private[sbt] trait IOSyntax0 extends IOSyntax1 {
implicit def alternative[A, B](f: A => Option[B]): Alternative[A, B] = new Alternative[A, B] {
override def |(g: A => Option[B]): A => Option[B] = (a: A) => f(a) orElse g(a)
extension [A, B](f: A => Option[B]) {
def |(g: A => Option[B]): A => Option[B] = (a: A) => f(a) orElse g(a)
}
}
private[sbt] sealed trait IOSyntax1 extends sbt.io.IOSyntax with sbt.nio.file.syntax0
private[sbt] sealed trait Alternative[A, B] {
def |(g: A => Option[B]): A => Option[B]
}