@@ -7,7 +7,6 @@ import core.Contexts.*
77
88import dotty .tools .io .{AbstractFile , Directory , JarArchive , PlainDirectory }
99
10- import annotation .tailrec
1110import annotation .internal .unshared
1211import collection .mutable .ArrayBuffer
1312import collection .mutable
@@ -118,7 +117,8 @@ object Settings:
118117
119118 def updateIn (state : SettingsState , x : Any ): SettingsState = x match
120119 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 ]}" )
122122
123123 def isDefaultIn (state : SettingsState ): Boolean = valueIn(state) == default
124124
@@ -183,10 +183,10 @@ object Settings:
183183 if ignoreInvalidArgs then state.warn(s " $msg, the tag was ignored " ) else state.fail(msg)
184184
185185 def isEmptyDefault = default == null .asInstanceOf [T ] || classTag[T ].match
186- case ListTag => default.asInstanceOf [List [? ]].isEmpty
186+ case ListTag => default.asInstanceOf [List [? ]].isEmpty
187187 case StringTag => default.asInstanceOf [String ].isEmpty
188188 case OptionTag => default.asInstanceOf [Option [? ]].isEmpty
189- case _ => false
189+ case _ => false
190190
191191 def setBoolean (argValue : String , args : List [String ]) =
192192 if argValue.equalsIgnoreCase(" true" ) || argValue.isEmpty then update(true , argValue, args)
@@ -256,15 +256,17 @@ object Settings:
256256 else if isEmptyDefault then
257257 missingArg
258258 else
259- doSetArg(arg = null , args)
259+ doSetArg(arg = null , args) // update with default
260260
261- def doSetArg (arg : String , argsLeft : List [String ]) =
261+ def doSetArg (arg : String | Null , argsLeft : List [String ]) =
262262 classTag[T ] match
263263 case ListTag if arg == null =>
264- update(default, arg , argsLeft)
264+ update(default, argStringValue = " " , argsLeft)
265265 case ListTag =>
266266 val strings = arg.split(" ," ).toList
267267 appendList(strings, arg, argsLeft)
268+ case _ if arg == null =>
269+ missingArg
268270 case StringTag =>
269271 setString(arg, argsLeft)
270272 case OutputTag =>
@@ -280,10 +282,10 @@ object Settings:
280282 missingArg
281283
282284 def matches (argName : String ): Boolean =
283- ( allFullNames) .exists(_ == argName.takeWhile(_ != ':' )) || prefix.exists(arg.startsWith)
285+ allFullNames.exists(_ == argName.takeWhile(_ != ':' )) || prefix.exists(arg.startsWith)
284286
285287 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)
287289
288290 if matches(arg) then
289291 deprecation match
@@ -372,7 +374,6 @@ object Settings:
372374 *
373375 * to get their arguments.
374376 */
375- @ tailrec
376377 final def processArguments (state : ArgsSummary , processAll : Boolean , skipped : List [String ]): ArgsSummary =
377378 def stateWithArgs (args : List [String ]) = ArgsSummary (state.sstate, args, state.errors, state.warnings)
378379 state.arguments match
@@ -381,11 +382,11 @@ object Settings:
381382 case " --" :: args =>
382383 checkDependencies(stateWithArgs(skipped ++ args))
383384 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 =>
386387 val state1 = setting.tryToSet(state)
387388 if state1 ne state then state1
388- else loop(settings1 )
389+ else loop(settings )
389390 case Nil =>
390391 state.warn(s " bad option ' $x' was ignored " )
391392 processArguments(loop(allSettings.toList), processAll, skipped)
@@ -395,7 +396,7 @@ object Settings:
395396 end processArguments
396397
397398 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 )
399400
400401 def publish [T ](settingf : Int => Setting [T ]): Setting [T ] =
401402 val setting = settingf(_allSettings.length)
0 commit comments