Merge pull request #6712 from vegansk/6708-fix-multisync
Fix parameter types splitting in multisync macro #6708
This commit is contained in:
commit
e4fd52b223
1 changed files with 7 additions and 21 deletions
|
|
@ -472,27 +472,13 @@ proc stripAwait(node: NimNode): NimNode =
|
||||||
proc splitParamType(paramType: NimNode, async: bool): NimNode =
|
proc splitParamType(paramType: NimNode, async: bool): NimNode =
|
||||||
result = paramType
|
result = paramType
|
||||||
if paramType.kind == nnkInfix and $paramType[0].ident in ["|", "or"]:
|
if paramType.kind == nnkInfix and $paramType[0].ident in ["|", "or"]:
|
||||||
let firstType = paramType[1]
|
let firstAsync = "async" in ($paramType[1].ident).normalize
|
||||||
let firstTypeName = $firstType.ident
|
let secondAsync = "async" in ($paramType[2].ident).normalize
|
||||||
let secondType = paramType[2]
|
|
||||||
let secondTypeName = $secondType.ident
|
|
||||||
|
|
||||||
# Make sure that at least one has the name `async`, otherwise we shouldn't
|
if firstAsync:
|
||||||
# touch it.
|
result = paramType[if async: 1 else: 2]
|
||||||
if not ("async" in firstTypeName.normalize or
|
elif secondAsync:
|
||||||
"async" in secondTypeName.normalize):
|
result = paramType[if async: 2 else: 1]
|
||||||
return
|
|
||||||
|
|
||||||
if async:
|
|
||||||
if firstTypeName.normalize.startsWith("async"):
|
|
||||||
result = paramType[1]
|
|
||||||
elif secondTypeName.normalize.startsWith("async"):
|
|
||||||
result = paramType[2]
|
|
||||||
else:
|
|
||||||
if not firstTypeName.normalize.startsWith("async"):
|
|
||||||
result = paramType[1]
|
|
||||||
elif not secondTypeName.normalize.startsWith("async"):
|
|
||||||
result = paramType[2]
|
|
||||||
|
|
||||||
proc stripReturnType(returnType: NimNode): NimNode =
|
proc stripReturnType(returnType: NimNode): NimNode =
|
||||||
# Strip out the 'Future' from 'Future[T]'.
|
# Strip out the 'Future' from 'Future[T]'.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue