deepCopy is instantiated when its corresponding type is instantiated

This commit is contained in:
Araq 2014-09-26 09:36:09 +02:00
commit 1088814e56
10 changed files with 87 additions and 15 deletions

View file

@ -299,6 +299,18 @@ proc handleGenericInvokation(cl: var TReplTypeVars, t: PType): PType =
if newbody.isGenericAlias: newbody = newbody.skipGenericAlias
rawAddSon(result, newbody)
checkPartialConstructedType(cl.info, newbody)
let dc = newbody.deepCopy
if dc != nil and sfFromGeneric notin newbody.deepCopy.flags:
# 'deepCopy' needs to be instantiated for
# generics *when the type is constructed*:
newbody.deepCopy = cl.c.instDeepCopy(cl.c, dc, result, cl.info)
when false:
var bindings: TIdTable
initIdTable(bindings)
debug newbody
bindings.idTablePut(dc.ast[genericParamsPos].sons[0].typ, newbody)
newbody.deepCopy = cl.c.semGenerateInstance(cl.c, dc, bindings, cl.info)
assert sfFromGeneric in newbody.deepCopy.flags
proc eraseVoidParams*(t: PType) =
if t.sons[0] != nil and t.sons[0].kind == tyEmpty: