support for external types with covariant generic params

This commit is contained in:
Zahary Karadjov 2017-05-08 21:45:37 +03:00
commit 5e368f3639
8 changed files with 62 additions and 3 deletions

View file

@ -1523,6 +1523,13 @@ proc parseGenericParam(p: var TParser): PNode =
# progress guaranteed
while true:
case p.tok.tokType
of tkIn, tkOut:
let kind = if p.tok.tokType == tkIn: nkInTy
else: nkOutTy
a = newNodeP(kind, p)
getTok(p)
expectIdent(p)
a.addSon(parseSymbol(p))
of tkSymbol, tkAccent:
a = parseSymbol(p)
if a.kind == nkEmpty: return
@ -1551,7 +1558,7 @@ proc parseGenericParamList(p: var TParser): PNode =
getTok(p)
optInd(p, result)
# progress guaranteed
while p.tok.tokType in {tkSymbol, tkAccent}:
while p.tok.tokType in {tkSymbol, tkAccent, tkIn, tkOut}:
var a = parseGenericParam(p)
addSon(result, a)
if p.tok.tokType notin {tkComma, tkSemiColon}: break