properly remove intLiterals from proc signatures; fixes trettypeinference
This commit is contained in:
parent
7e24cf26de
commit
af7c3251cd
1 changed files with 13 additions and 5 deletions
|
|
@ -229,15 +229,13 @@ proc handleGenericInvokation(cl: var TReplTypeVars, t: PType): PType =
|
||||||
rawAddSon(result, newbody)
|
rawAddSon(result, newbody)
|
||||||
checkPartialConstructedType(cl.info, newbody)
|
checkPartialConstructedType(cl.info, newbody)
|
||||||
|
|
||||||
proc normalizeProcType(t: PType) =
|
proc eraseVoidParams(t: PType) =
|
||||||
if t.sons[0] != nil and t.sons[0].kind == tyEmpty:
|
if t.sons[0] != nil and t.sons[0].kind == tyEmpty:
|
||||||
t.sons[0] = nil
|
t.sons[0] = nil
|
||||||
|
|
||||||
for i in 1 .. <t.sonsLen:
|
for i in 1 .. <t.sonsLen:
|
||||||
|
# don't touch any memory unless necessary
|
||||||
if t.sons[i].kind == tyEmpty:
|
if t.sons[i].kind == tyEmpty:
|
||||||
# the nested loops are here in order to avoid
|
|
||||||
# touching any memory and callign setLen unless
|
|
||||||
# it's really necessary
|
|
||||||
var pos = i
|
var pos = i
|
||||||
for j in i+1 .. <t.sonsLen:
|
for j in i+1 .. <t.sonsLen:
|
||||||
if t.sons[j].kind != tyEmpty:
|
if t.sons[j].kind != tyEmpty:
|
||||||
|
|
@ -248,6 +246,15 @@ proc normalizeProcType(t: PType) =
|
||||||
setLen t.n.sons, pos
|
setLen t.n.sons, pos
|
||||||
return
|
return
|
||||||
|
|
||||||
|
proc skipIntLiteralParams(t: PType) =
|
||||||
|
for i in 0 .. <t.sonsLen:
|
||||||
|
let p = t.sons[i]
|
||||||
|
if p == nil: continue
|
||||||
|
let skipped = p.skipIntLit
|
||||||
|
if skipped != p:
|
||||||
|
t.sons[i] = skipped
|
||||||
|
if i > 0: t.n.sons[i].sym.typ = skipped
|
||||||
|
|
||||||
proc propagateFieldFlags(t: PType, n: PNode) =
|
proc propagateFieldFlags(t: PType, n: PNode) =
|
||||||
# This is meant for objects and tuples
|
# This is meant for objects and tuples
|
||||||
# The type must be fully instantiated!
|
# The type must be fully instantiated!
|
||||||
|
|
@ -320,7 +327,8 @@ proc replaceTypeVarsTAux(cl: var TReplTypeVars, t: PType): PType =
|
||||||
of tyObject, tyTuple:
|
of tyObject, tyTuple:
|
||||||
propagateFieldFlags(result, result.n)
|
propagateFieldFlags(result, result.n)
|
||||||
of tyProc:
|
of tyProc:
|
||||||
normalizeProcType(result)
|
eraseVoidParams(result)
|
||||||
|
skipIntLiteralParams(result)
|
||||||
else: discard
|
else: discard
|
||||||
|
|
||||||
proc generateTypeInstance*(p: PContext, pt: TIdTable, info: TLineInfo,
|
proc generateTypeInstance*(p: PContext, pt: TIdTable, info: TLineInfo,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue