Skip to content

Commit

Permalink
Rename option -Wnamed-boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
som-snytt committed Mar 11, 2024
1 parent 729badb commit b89ad0c
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
1 change: 0 additions & 1 deletion src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ trait ScalaSettings extends StandardScalaSettings with Warnings { _: MutableSett
* -Y "Private" settings
*/
val Yhelp = BooleanSetting ("-Y", "Print a synopsis of private options.")
val Ylint = BooleanSetting ("-Ylinternal", "Use strict internal lints.")
val breakCycles = BooleanSetting ("-Ybreak-cycles", "Attempt to break cycles encountered during typing")
val check = PhasesSetting ("-Ycheck", "Check the tree at the end of")
val Ycompacttrees = BooleanSetting ("-Ycompact-trees", "Use compact tree printer when displaying trees.")
Expand Down
1 change: 1 addition & 0 deletions src/compiler/scala/tools/nsc/settings/Warnings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ trait Warnings {
val warnNumericWiden = BooleanSetting("-Wnumeric-widen", "Warn when numerics are widened.") withAbbreviation "-Ywarn-numeric-widen"
val warnOctalLiteral = BooleanSetting("-Woctal-literal", "Warn on obsolete octal syntax.") withAbbreviation "-Ywarn-octal-literal"
val warnNamedLiteral = BooleanSetting("-Wnamed-literal", "Warn when unnamed literal arguments may be swapped, unless parameter has @deprecatedName.")
val warnNamedBoolean = BooleanSetting("-Wnamed-boolean", "Boolean literal arguments should be named.").enabling(warnNamedLiteral :: Nil)

object PerformanceWarnings extends MultiChoiceEnumeration {
val Captured = Choice("captured", "Modification of var in closure causes boxing.")
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1747,7 +1747,7 @@ abstract class RefChecks extends Transform {
val params = sym.paramLists(applyDepth)
val numBools = params.count(_.tpe == BooleanTpe)
def onlyLeadingBool = numBools == 1 && params.head.tpe == BooleanTpe
val checkable = if (settings.Ylint.value) numBools > 0 && !onlyLeadingBool else numBools >= 2
val checkable = if (settings.warnNamedBoolean.value) numBools > 0 && !onlyLeadingBool else numBools >= 2
if (checkable) {
val (unnamed, numSuspicious) = args.lazyZip(params).iterator
.foldLeft((List.empty[(Tree, Symbol)], 0)) { (acc, ap) =>
Expand All @@ -1762,7 +1762,7 @@ abstract class RefChecks extends Transform {
case _ => acc
}
}
val warn = !unnamed.isEmpty && (settings.Ylint.value || numSuspicious >= 2)
val warn = !unnamed.isEmpty && (settings.warnNamedBoolean.value || numSuspicious >= 2)
if (warn)
unnamed.reverse.foreach {
case (arg, param) =>
Expand Down
2 changes: 1 addition & 1 deletion test/files/neg/named-booleans.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -Werror -Wnamed-literal -Ylinternal
//> using options -Werror -Wnamed-boolean

class C {
def f(n: Int = 42, x: Boolean, y: Boolean) = if (x && y) n else 0
Expand Down

0 comments on commit b89ad0c

Please sign in to comment.