diff --git a/main-command/src/main/scala/sbt/Command.scala b/main-command/src/main/scala/sbt/Command.scala index 05798ff55..48324aaf5 100644 --- a/main-command/src/main/scala/sbt/Command.scala +++ b/main-command/src/main/scala/sbt/Command.scala @@ -188,8 +188,8 @@ object Command { def spacedC(name: String, c: Parser[Char]): Parser[String] = ((c & opOrIDSpaced(name)) ~ c.+) map { case (f, rem) => (f +: rem).mkString } - implicit class CommandWithName(cmd: Command) { - def commandName: Option[String] = cmd match { + implicit class CommandWithName(val cmd: Command) extends AnyVal { + def nameOption: Option[String] = cmd match { case sc: SimpleCommand => Some(sc.name) case _ => None } diff --git a/sbt/src/sbt-test/actions/command-name/build.sbt b/sbt/src/sbt-test/actions/command-name/build.sbt index 1a04a2dcc..374a7d3cd 100644 --- a/sbt/src/sbt-test/actions/command-name/build.sbt +++ b/sbt/src/sbt-test/actions/command-name/build.sbt @@ -1,5 +1,5 @@ val command = Command.command("noop") { s => s } TaskKey[Unit]("check") := { - assert(command.commandName == Some("noop"), """command.commandName should be "noop"""") + assert(command.nameOption == Some("noop"), """command.commandName should be "noop"""") }