fixes #797; generic procs can be used in places expecting matching concrete proc types

This commit is contained in:
Zahary Karadjov 2014-02-11 01:14:57 +02:00
commit a158053ae9
5 changed files with 80 additions and 29 deletions

View file

@ -204,7 +204,14 @@ proc semConv(c: PContext, n: PNode): PNode =
if not isSymChoice(op):
let status = checkConvertible(c, result.typ, op.typ)
case status
of convOK: discard
of convOK:
# handle SomeProcType(SomeGenericProc)
# XXX: This needs fixing. checkConvertible uses typeRel internally, but
# doesn't bother to perform the work done in paramTypeMatchAux/fitNode
# so we are redoing the typeRel work here. Why does semConv exist as a
# separate proc from fitNode?
if op.kind == nkSym and op.sym.isGenericRoutine:
result.sons[1] = fitNode(c, result.typ, result.sons[1])
of convNotNeedeed:
message(n.info, hintConvFromXtoItselfNotNeeded, result.typ.typeToString)
of convNotLegal: