Skip to content

Commit

Permalink
Ensure the following scalac options do not require being passed aft…
Browse files Browse the repository at this point in the history
…er `-O`: `-color`, `-feature`, `-deprecation` and `-nowarn`
  • Loading branch information
Gedochao committed Oct 4, 2022
1 parent f67fda9 commit 96a0f2b
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 96a0f2b

Please sign in to comment.