From 96a0f2b4e9a421dcfcc91d0d6531e1c5ca12412e Mon Sep 17 00:00:00 2001 From: Piotr Chabelski Date: Mon, 3 Oct 2022 15:27:55 +0200 Subject: [PATCH] Ensure the following `scalac` options do not require being passed after `-O`: `-color`, `-feature`, `-deprecation` and `-nowarn` --- .../src/main/scala/scala/cli/commands/ScalacOptions.scala | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/cli-options/src/main/scala/scala/cli/commands/ScalacOptions.scala b/modules/cli-options/src/main/scala/scala/cli/commands/ScalacOptions.scala index 274add2beb..54647d308b 100644 --- a/modules/cli-options/src/main/scala/scala/cli/commands/ScalacOptions.scala +++ b/modules/cli-options/src/main/scala/scala/cli/commands/ScalacOptions.scala @@ -34,8 +34,10 @@ object ScalacOptions { Set("-V", "-W", "-X", "-Y") private val scalacOptionsPrefixes = Set("-g", "-language", "-opt", "-P", "-target") ++ scalacOptionsPurePrefixes - private val scalacAliasedOptions = // these options don't require being passed after -O - Set("-encoding", "-release") + private val scalacAliasedOptions = // these options don't require being passed after -O and accept an arg + Set("-encoding", "-release", "-color") + private val scalacNoArgAliasedOptions = // these options don't require being passed after -O and don't accept an arg + Set("-nowarn", "-feature", "-deprecation") /** This includes all the scalac options which disregard inputs and print a help and/or context * message instead. @@ -75,6 +77,8 @@ object ScalacOptions { args match { case h :: t if scalacOptionsPrefixes.exists(h.startsWith) => Right(Some((Some(h :: acc.getOrElse(Nil)), t))) + case h :: t if scalacNoArgAliasedOptions.contains(h) => + Right(Some((Some(h :: acc.getOrElse(Nil)), t))) case h :: t if scalacAliasedOptions.contains(h) => val maybeOptionArg = t.headOption.filter(!_.startsWith("-")) val newTail = maybeOptionArg.map(_ => t.drop(1)).getOrElse(t)