@@ -7,7 +7,6 @@ import core.Contexts.*
7
7
8
8
import dotty .tools .io .{AbstractFile , Directory , JarArchive , PlainDirectory }
9
9
10
- import annotation .tailrec
11
10
import annotation .internal .unshared
12
11
import collection .mutable .ArrayBuffer
13
12
import collection .mutable
@@ -118,7 +117,8 @@ object Settings:
118
117
119
118
def updateIn (state : SettingsState , x : Any ): SettingsState = x match
120
119
case _ : T => state.update(idx, x)
121
- case _ => throw IllegalArgumentException (s " found: $x of type ${x.getClass.getName}, required: ${classTag[T ]}" )
120
+ case null => throw IllegalArgumentException (s " attempt to set null ${classTag[T ]}" )
121
+ case _ => throw IllegalArgumentException (s " found: $x of type ${x.getClass.getName}, required: ${classTag[T ]}" )
122
122
123
123
def isDefaultIn (state : SettingsState ): Boolean = valueIn(state) == default
124
124
@@ -183,10 +183,10 @@ object Settings:
183
183
if ignoreInvalidArgs then state.warn(s " $msg, the tag was ignored " ) else state.fail(msg)
184
184
185
185
def isEmptyDefault = default == null .asInstanceOf [T ] || classTag[T ].match
186
- case ListTag => default.asInstanceOf [List [? ]].isEmpty
186
+ case ListTag => default.asInstanceOf [List [? ]].isEmpty
187
187
case StringTag => default.asInstanceOf [String ].isEmpty
188
188
case OptionTag => default.asInstanceOf [Option [? ]].isEmpty
189
- case _ => false
189
+ case _ => false
190
190
191
191
def setBoolean (argValue : String , args : List [String ]) =
192
192
if argValue.equalsIgnoreCase(" true" ) || argValue.isEmpty then update(true , argValue, args)
@@ -256,15 +256,17 @@ object Settings:
256
256
else if isEmptyDefault then
257
257
missingArg
258
258
else
259
- doSetArg(arg = null , args)
259
+ doSetArg(arg = null , args) // update with default
260
260
261
- def doSetArg (arg : String , argsLeft : List [String ]) =
261
+ def doSetArg (arg : String | Null , argsLeft : List [String ]) =
262
262
classTag[T ] match
263
263
case ListTag if arg == null =>
264
- update(default, arg , argsLeft)
264
+ update(default, argStringValue = " " , argsLeft)
265
265
case ListTag =>
266
266
val strings = arg.split(" ," ).toList
267
267
appendList(strings, arg, argsLeft)
268
+ case _ if arg == null =>
269
+ missingArg
268
270
case StringTag =>
269
271
setString(arg, argsLeft)
270
272
case OutputTag =>
@@ -280,10 +282,10 @@ object Settings:
280
282
missingArg
281
283
282
284
def matches (argName : String ): Boolean =
283
- ( allFullNames) .exists(_ == argName.takeWhile(_ != ':' )) || prefix.exists(arg.startsWith)
285
+ allFullNames.exists(_ == argName.takeWhile(_ != ':' )) || prefix.exists(arg.startsWith)
284
286
285
287
def argValRest : String =
286
- if ( prefix.isEmpty) arg.dropWhile(_ != ':' ).drop(1 ) else arg.drop(prefix.get.length)
288
+ if prefix.isEmpty then arg.dropWhile(_ != ':' ).drop(1 ) else arg.drop(prefix.get.length)
287
289
288
290
if matches(arg) then
289
291
deprecation match
@@ -372,7 +374,6 @@ object Settings:
372
374
*
373
375
* to get their arguments.
374
376
*/
375
- @ tailrec
376
377
final def processArguments (state : ArgsSummary , processAll : Boolean , skipped : List [String ]): ArgsSummary =
377
378
def stateWithArgs (args : List [String ]) = ArgsSummary (state.sstate, args, state.errors, state.warnings)
378
379
state.arguments match
@@ -381,11 +382,11 @@ object Settings:
381
382
case " --" :: args =>
382
383
checkDependencies(stateWithArgs(skipped ++ args))
383
384
case x :: _ if x startsWith " -" =>
384
- @ tailrec def loop (settings : List [Setting [? ]]): ArgsSummary = settings match
385
- case setting :: settings1 =>
385
+ def loop (settings : List [Setting [? ]]): ArgsSummary = settings match
386
+ case setting :: settings =>
386
387
val state1 = setting.tryToSet(state)
387
388
if state1 ne state then state1
388
- else loop(settings1 )
389
+ else loop(settings )
389
390
case Nil =>
390
391
state.warn(s " bad option ' $x' was ignored " )
391
392
processArguments(loop(allSettings.toList), processAll, skipped)
@@ -395,7 +396,7 @@ object Settings:
395
396
end processArguments
396
397
397
398
def processArguments (arguments : List [String ], processAll : Boolean , settingsState : SettingsState = defaultState): ArgsSummary =
398
- processArguments(ArgsSummary (settingsState, arguments, Nil , Nil ), processAll, Nil )
399
+ processArguments(ArgsSummary (settingsState, arguments, errors = Nil , warnings = Nil ), processAll, skipped = Nil )
399
400
400
401
def publish [T ](settingf : Int => Setting [T ]): Setting [T ] =
401
402
val setting = settingf(_allSettings.length)
0 commit comments