Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
fail(s"Flag $name set repeatedly", args)
} 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