use extension instead of implicit

This commit is contained in:
xuwei-k 2024-11-17 07:38:40 +09:00
parent d199f86a44
commit 4da8d942ce
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]
}