diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2019-02-28 22:39:15 +0100 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2019-02-28 22:39:24 +0100 |
commit | 728ff1004a60835c18c44b64830ea08dc805485e (patch) | |
tree | df7c9be34196e4a8c47596ccb6a88fe4c43f84f7 /compiler | |
parent | 9563be37d3dfed1e4bc9e3ee8955497de48b89a1 (diff) | |
download | Nim-728ff1004a60835c18c44b64830ea08dc805485e.tar.gz |
gc:destructors: progress
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/seminst.nim | 2 | ||||
-rw-r--r-- | compiler/semstmts.nim | 1 | ||||
-rw-r--r-- | compiler/semtypinst.nim | 16 |
3 files changed, 19 insertions, 0 deletions
diff --git a/compiler/seminst.nim b/compiler/seminst.nim index 09991048e..51303d1b5 100644 --- a/compiler/seminst.nim +++ b/compiler/seminst.nim @@ -306,7 +306,9 @@ proc instantiateProcType(c: PContext, pt: TIdTable, resetIdTable(cl.symMap) resetIdTable(cl.localCache) + cl.isReturnType = true result.sons[0] = replaceTypeVarsT(cl, result.sons[0]) + cl.isReturnType = false result.n.sons[0] = originalParams[0].copyTree if result.sons[0] != nil: propagateToOwner(result, result.sons[0]) diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index aa0230f2f..c16de0723 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -481,6 +481,7 @@ proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode = if typ == nil: continue typeAllowedCheck(c.config, a.info, typ, symkind, if c.matchedConcept != nil: {taConcept} else: {}) liftTypeBoundOps(c.graph, typ, a.info) + instAllTypeBoundOp(c, a.info) var tup = skipTypes(typ, {tyGenericInst, tyAlias, tySink}) if a.kind == nkVarTuple: if tup.kind != tyTuple: 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 |