splat any Iterable
This commit is contained in:
1 parent
2b87845a40
commit
397dcaae92
2 files changed
+37
-3
No files matched your search
@@ -8,8 +8,18 @@ suspend fun Collection<ParsedArgument>.toArguments(context: Context): Arguments
|
||||
for (x in this) {
|
||||
val value = x.value.execute(context)
|
||||
if (x.isSplat) {
|
||||
(value as? ObjList) ?: context.raiseClassCastError("expected list of objects for splat argument")
|
||||
for (subitem in value.list) list.add(Arguments.Info(subitem, x.pos))
|
||||
when {
|
||||
value is ObjList -> {
|
||||
for (subitem in value.list) list.add(Arguments.Info(subitem, x.pos))
|
||||
}
|
||||
|
||||
value.isInstanceOf(ObjIterable) -> {
|
||||
val i = (value.invokeInstanceMethod(context, "toList") as ObjList).list
|
||||
i.forEach { list.add(Arguments.Info(it, x.pos)) }
|
||||
}
|
||||
|
||||
else -> context.raiseClassCastError("expected list of objects for splat argument")
|
||||
}
|
||||
} else
|
||||
list.add(Arguments.Info(value, x.pos))
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user