Skip to content

Commit

Permalink
Merge pull request scala#2590 from typeness/fix-#2369
Browse files Browse the repository at this point in the history
Fix scala#2369: Should warn when ignoring command line flags
  • Loading branch information
felixmulder authored Jun 2, 2017
2 parents f7052d4 + 08f1233 commit a1d7db2
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions compiler/src/dotty/tools/dotc/config/Settings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ object Settings {
depends: List[(Setting[_], Any)] = Nil,
propertyClass: Option[Class[_]] = None)(private[Settings] val idx: Int) {

private var changed: Boolean = false

def withAbbreviation(abbrv: String): Setting[T] =
copy(aliases = aliases :+ abbrv)(idx)

Expand Down Expand Up @@ -111,8 +113,14 @@ object Settings {

def tryToSet(state: ArgsSummary): ArgsSummary = {
val ArgsSummary(sstate, arg :: args, errors, warnings) = state
def update(value: Any, args: List[String]) =
ArgsSummary(updateIn(sstate, value), args, errors, warnings)
def update(value: Any, args: List[String]) = {
if (changed) {
ArgsSummary(updateIn(sstate, value), args, errors, warnings :+ s"Flag $name set repeatedly")
} else {
changed = true
ArgsSummary(updateIn(sstate, value), args, errors, warnings)
}
}
def fail(msg: String, args: List[String]) =
ArgsSummary(sstate, args, errors :+ msg, warnings)
def missingArg =
Expand Down

0 comments on commit a1d7db2

Please sign in to comment.