diff options
Diffstat (limited to 'compiler/semtypinst.nim')
-rw-r--r-- | compiler/semtypinst.nim | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/compiler/semtypinst.nim b/compiler/semtypinst.nim index 002f4f402..483588e6b 100644 --- a/compiler/semtypinst.nim +++ b/compiler/semtypinst.nim @@ -88,6 +88,7 @@ type allowMetaTypes*: bool # allow types such as seq[Number] # i.e. the result contains unresolved generics skipTypedesc*: bool # wether we should skip typeDescs + isReturnType*: bool owner*: PSym # where this instantiation comes from recursionLimit: int @@ -594,6 +595,21 @@ proc replaceTypeVarsTAux(cl: var TReplTypeVars, t: PType): PType = eraseVoidParams(result) skipIntLiteralParams(result) + of tySequence: + if cl.isReturnType and cl.c.config.selectedGc == gcDestructors and result.destructor.isNil and + result[0].kind != tyEmpty: + let s = cl.c.graph.sysTypes[tySequence] + var old = copyType(s, s.owner, keepId=false) + # Remove the 'T' parameter from tySequence: + old.sons.setLen 0 + old.n = nil + old.flags = {tfHasAsgn} + old.addSonSkipIntLit result[0] + result.destructor = old.destructor + result.assignment = old.assignment + result.sink = old.sink + cl.c.typesWithOps.add((result, old)) + else: discard else: # If this type doesn't refer to a generic type we may still want to run it |