summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'compiler')
-rw-r--r--compiler/seminst.nim2
-rw-r--r--compiler/semstmts.nim1
-rw-r--r--compiler/semtypinst.nim16
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