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