@@ -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
@@ -107,7 +106,8 @@ object Settings:
107
106
108
107
def updateIn (state : SettingsState , x : Any ): SettingsState = x match
109
108
case _ : T => state.update(idx, x)
110
- case _ => throw IllegalArgumentException (s " found: $x of type ${x.getClass.getName}, required: ${classTag[T ]}" )
109
+ case null => throw IllegalArgumentException (s " attempt to set null ${classTag[T ]}" )
110
+ case _ => throw IllegalArgumentException (s " found: $x of type ${x.getClass.getName}, required: ${classTag[T ]}" )
111
111
112
112
def isDefaultIn (state : SettingsState ): Boolean = valueIn(state) == default
113
113
@@ -172,10 +172,10 @@ object Settings:
172
172
if ignoreInvalidArgs then state.warn(s " $msg, the tag was ignored " ) else state.fail(msg)
173
173
174
174
def isEmptyDefault = default == null .asInstanceOf [T ] || classTag[T ].match
175
- case ListTag => default.asInstanceOf [List [? ]].isEmpty
175
+ case ListTag => default.asInstanceOf [List [? ]].isEmpty
176
176
case StringTag => default.asInstanceOf [String ].isEmpty
177
177
case OptionTag => default.asInstanceOf [Option [? ]].isEmpty
178
- case _ => false
178
+ case _ => false
179
179
180
180
def setBoolean (argValue : String , args : List [String ]) =
181
181
if argValue.equalsIgnoreCase(" true" ) || argValue.isEmpty then update(true , argValue, args)
@@ -240,15 +240,17 @@ object Settings:
240
240
else if isEmptyDefault then
241
241
missingArg
242
242
else
243
- doSetArg(arg = null , args)
243
+ doSetArg(arg = null , args) // update with default
244
244
245
- def doSetArg (arg : String , argsLeft : List [String ]) =
245
+ def doSetArg (arg : String | Null , argsLeft : List [String ]) =
246
246
classTag[T ] match
247
247
case ListTag if arg == null =>
248
- update(default, arg , argsLeft)
248
+ update(default, argStringValue = " " , argsLeft)
249
249
case ListTag =>
250
250
val strings = arg.split(" ," ).toList
251
251
appendList(strings, arg, argsLeft)
252
+ case _ if arg == null =>
253
+ missingArg
252
254
case StringTag =>
253
255
setString(arg, argsLeft)
254
256
case OutputTag =>
@@ -264,10 +266,10 @@ object Settings:
264
266
missingArg
265
267
266
268
def matches (argName : String ): Boolean =
267
- ( allFullNames) .exists(_ == argName.takeWhile(_ != ':' )) || prefix.exists(arg.startsWith)
269
+ allFullNames.exists(_ == argName.takeWhile(_ != ':' )) || prefix.exists(arg.startsWith)
268
270
269
271
def argValRest : String =
270
- if ( prefix.isEmpty) arg.dropWhile(_ != ':' ).drop(1 ) else arg.drop(prefix.get.length)
272
+ if prefix.isEmpty then arg.dropWhile(_ != ':' ).drop(1 ) else arg.drop(prefix.get.length)
271
273
272
274
if matches(arg) then
273
275
deprecation match
@@ -356,7 +358,6 @@ object Settings:
356
358
*
357
359
* to get their arguments.
358
360
*/
359
- @ tailrec
360
361
final def processArguments (state : ArgsSummary , processAll : Boolean , skipped : List [String ]): ArgsSummary =
361
362
def stateWithArgs (args : List [String ]) = ArgsSummary (state.sstate, args, state.errors, state.warnings)
362
363
state.arguments match
@@ -365,11 +366,11 @@ object Settings:
365
366
case " --" :: args =>
366
367
checkDependencies(stateWithArgs(skipped ++ args))
367
368
case x :: _ if x startsWith " -" =>
368
- @ tailrec def loop (settings : List [Setting [? ]]): ArgsSummary = settings match
369
- case setting :: settings1 =>
369
+ def loop (settings : List [Setting [? ]]): ArgsSummary = settings match
370
+ case setting :: settings =>
370
371
val state1 = setting.tryToSet(state)
371
372
if state1 ne state then state1
372
- else loop(settings1 )
373
+ else loop(settings )
373
374
case Nil =>
374
375
state.warn(s " bad option ' $x' was ignored " )
375
376
processArguments(loop(allSettings.toList), processAll, skipped)
@@ -379,7 +380,7 @@ object Settings:
379
380
end processArguments
380
381
381
382
def processArguments (arguments : List [String ], processAll : Boolean , settingsState : SettingsState = defaultState): ArgsSummary =
382
- processArguments(ArgsSummary (settingsState, arguments, Nil , Nil ), processAll, Nil )
383
+ processArguments(ArgsSummary (settingsState, arguments, errors = Nil , warnings = Nil ), processAll, skipped = Nil )
383
384
384
385
def publish [T ](settingf : Int => Setting [T ]): Setting [T ] =
385
386
val setting = settingf(_allSettings.length)
0 commit comments