@@ -165,46 +165,50 @@ private sealed trait WarningSettings:
165
165
166
166
val Whelp : Setting [Boolean ] = BooleanSetting (" -W" , " Print a synopsis of warning options." )
167
167
val XfatalWarnings : Setting [Boolean ] = BooleanSetting (" -Werror" , " Fail the compilation if there are any warnings." , aliases = List (" -Xfatal-warnings" ))
168
- val WvalueDiscard : Setting [Boolean ] = BooleanSetting (" -Wvalue-discard" , " Warn when non-Unit expression results are unused." )
169
- val WNonUnitStatement = BooleanSetting (" -Wnonunit-statement" , " Warn when block statements are non-Unit expressions." )
170
- val WenumCommentDiscard = BooleanSetting (" -Wenum-comment-discard" , " Warn when a comment ambiguously assigned to multiple enum cases is discarded." )
171
- val Wunused : Setting [List [ChoiceWithHelp [String ]]] = MultiChoiceHelpSetting (
168
+ val Wall : Setting [Boolean ] = BooleanSetting (" -Wall" , " Enable all warning settings." )
169
+ private val WvalueDiscard : Setting [Boolean ] = BooleanSetting (" -Wvalue-discard" , " Warn when non-Unit expression results are unused." )
170
+ private val WNonUnitStatement = BooleanSetting (" -Wnonunit-statement" , " Warn when block statements are non-Unit expressions." )
171
+ private val WenumCommentDiscard = BooleanSetting (" -Wenum-comment-discard" , " Warn when a comment ambiguously assigned to multiple enum cases is discarded." )
172
+ private val Wunused : Setting [List [ChoiceWithHelp [String ]]] = MultiChoiceHelpSetting (
172
173
name = " -Wunused" ,
173
174
helpArg = " warning" ,
174
175
descr = " Enable or disable specific `unused` warnings" ,
175
- choices = List (
176
+ choices = List (
176
177
ChoiceWithHelp (" nowarn" , " " ),
177
- ChoiceWithHelp (" all" ," " ),
178
+ ChoiceWithHelp (" all" , " " ),
178
179
ChoiceWithHelp (
179
180
name = " imports" ,
180
181
description = " Warn if an import selector is not referenced.\n " +
181
182
" NOTE : overrided by -Wunused:strict-no-implicit-warn" ),
182
- ChoiceWithHelp (" privates" ," Warn if a private member is unused" ),
183
- ChoiceWithHelp (" locals" ," Warn if a local definition is unused" ),
184
- ChoiceWithHelp (" explicits" ," Warn if an explicit parameter is unused" ),
185
- ChoiceWithHelp (" implicits" ," Warn if an implicit parameter is unused" ),
186
- ChoiceWithHelp (" params" ," Enable -Wunused:explicits,implicits" ),
187
- ChoiceWithHelp (" linted" ," Enable -Wunused:imports,privates,locals,implicits" ),
188
- ChoiceWithHelp (
189
- name = " strict-no-implicit-warn" ,
190
- description = " Same as -Wunused:import, only for imports of explicit named members.\n " +
191
- " NOTE : This overrides -Wunused:imports and NOT set by -Wunused:all"
192
- ),
193
- // ChoiceWithHelp("patvars","Warn if a variable bound in a pattern is unused"),
194
- ChoiceWithHelp (
195
- name = " unsafe-warn-patvars" ,
196
- description = " (UNSAFE) Warn if a variable bound in a pattern is unused.\n " +
197
- " This warning can generate false positive, as warning cannot be\n " +
198
- " suppressed yet."
199
- )
183
+ ChoiceWithHelp (" privates" , " Warn if a private member is unused" ),
184
+ ChoiceWithHelp (" locals" , " Warn if a local definition is unused" ),
185
+ ChoiceWithHelp (" explicits" , " Warn if an explicit parameter is unused" ),
186
+ ChoiceWithHelp (" implicits" , " Warn if an implicit parameter is unused" ),
187
+ ChoiceWithHelp (" params" , " Enable -Wunused:explicits,implicits" ),
188
+ ChoiceWithHelp (" linted" , " Enable -Wunused:imports,privates,locals,implicits" ),
189
+ ChoiceWithHelp (
190
+ name = " strict-no-implicit-warn" ,
191
+ description = " Same as -Wunused:import, only for imports of explicit named members.\n " +
192
+ " NOTE : This overrides -Wunused:imports and NOT set by -Wunused:all"
193
+ ),
194
+ // ChoiceWithHelp("patvars","Warn if a variable bound in a pattern is unused"),
195
+ ChoiceWithHelp (
196
+ name = " unsafe-warn-patvars" ,
197
+ description = " (UNSAFE) Warn if a variable bound in a pattern is unused.\n " +
198
+ " This warning can generate false positive, as warning cannot be\n " +
199
+ " suppressed yet."
200
+ )
200
201
),
201
202
default = Nil
202
203
)
203
204
object WunusedHas :
204
205
def isChoiceSet (s : String )(using Context ) = Wunused .value.pipe(us => us.contains(s))
205
- def allOr (s : String )(using Context ) = Wunused .value.pipe(us => us.contains(" all" ) || us.contains(s))
206
+ def allOr (s : String )(using Context ) = Wall .value || Wunused .value.pipe(us => us.contains(" all" ) || us.contains(s))
206
207
def nowarn (using Context ) = allOr(" nowarn" )
207
208
209
+ // Is any choice set for -Wunused?
210
+ def any (using Context ): Boolean = Wall .value || Wunused .value.nonEmpty
211
+
208
212
// overrided by strict-no-implicit-warn
209
213
def imports (using Context ) =
210
214
(allOr(" imports" ) || allOr(" linted" )) && ! (strictNoImplicitWarn)
@@ -278,6 +282,16 @@ private sealed trait WarningSettings:
278
282
|to prevent the shell from expanding patterns. """ .stripMargin,
279
283
)
280
284
285
+ val YcheckInit : Setting [Boolean ] = BooleanSetting (" -Ysafe-init" , " Ensure safe initialization of objects." )
286
+
287
+ object Whas :
288
+ def allOr (s : Setting [Boolean ])(using Context ): Boolean =
289
+ Wall .value || s.value
290
+ def valueDiscard (using Context ): Boolean = allOr(WvalueDiscard )
291
+ def nonUnitStatement (using Context ): Boolean = allOr(WNonUnitStatement )
292
+ def enumCommentDiscard (using Context ): Boolean = allOr(WenumCommentDiscard )
293
+ def checkInit (using Context ): Boolean = allOr(YcheckInit )
294
+
281
295
/** -X "Extended" or "Advanced" settings */
282
296
private sealed trait XSettings :
283
297
self : SettingGroup =>
@@ -415,7 +429,6 @@ private sealed trait YSettings:
415
429
// Experimental language features
416
430
val YnoKindPolymorphism : Setting [Boolean ] = BooleanSetting (" -Yno-kind-polymorphism" , " Disable kind polymorphism." )
417
431
val YexplicitNulls : Setting [Boolean ] = BooleanSetting (" -Yexplicit-nulls" , " Make reference types non-nullable. Nullable types can be expressed with unions: e.g. String|Null." )
418
- val YcheckInit : Setting [Boolean ] = BooleanSetting (" -Ysafe-init" , " Ensure safe initialization of objects." )
419
432
val YrequireTargetName : Setting [Boolean ] = BooleanSetting (" -Yrequire-targetName" , " Warn if an operator is defined without a @targetName annotation." )
420
433
val YrecheckTest : Setting [Boolean ] = BooleanSetting (" -Yrecheck-test" , " Run basic rechecking (internal test only)." )
421
434
val YccDebug : Setting [Boolean ] = BooleanSetting (" -Ycc-debug" , " Used in conjunction with captureChecking language import, debug info for captured references." )
0 commit comments