summary refs log tree commit diff stats
path: root/compiler/semtypinst.nim
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2023-08-11 22:18:24 +0800
committerGitHub <noreply@github.com>2023-08-11 22:18:24 +0800
commit469c9cfab487380ba85520c90a2fad7d658c3023 (patch)
treeb7a693643b64539cc7f9c2b83e1dfc797810f33d /compiler/semtypinst.nim
parent72bc72bf9ea470603420a0b56f63dad063f808a9 (diff)
downloadNim-469c9cfab487380ba85520c90a2fad7d658c3023.tar.gz
unpublic the sons field of PType; the precursor to PType refactorings (#22446)
* unpublic the sons field of PType

* tiny fixes

* fixes an omittance

* fixes IC

* fixes
Diffstat (limited to 'compiler/semtypinst.nim')
-rw-r--r--compiler/semtypinst.nim10
1 files changed, 4 insertions, 6 deletions
diff --git a/compiler/semtypinst.nim b/compiler/semtypinst.nim
index e3c8c1c0a..56b922fda 100644
--- a/compiler/semtypinst.nim
+++ b/compiler/semtypinst.nim
@@ -52,7 +52,7 @@ proc searchInstTypes*(g: ModuleGraph; key: PType): PType =
       continue
 
     block matchType:
-      for j in 1..high(key.sons):
+      for j in 1..<len(key):
         # XXX sameType is not really correct for nested generics?
         if not compareTypes(inst[j], key[j],
                             flags = {ExactGenericParams, PickyCAliases}):
@@ -384,10 +384,9 @@ proc handleGenericInvocation(cl: var TReplTypeVars, t: PType): PType =
   else:
     header = instCopyType(cl, t)
 
-  result = newType(tyGenericInst, nextTypeId(cl.c.idgen), t[0].owner)
+  result = newType(tyGenericInst, nextTypeId(cl.c.idgen), t[0].owner, sons = @[header[0]])
   result.flags = header.flags
   # be careful not to propagate unnecessary flags here (don't use rawAddSon)
-  result.sons = @[header[0]]
   # ugh need another pass for deeply recursive generic types (e.g. PActor)
   # we need to add the candidate here, before it's fully instantiated for
   # recursive instantions:
@@ -486,7 +485,7 @@ proc eraseVoidParams*(t: PType) =
           t[pos] = t[j]
           t.n[pos] = t.n[j]
           inc pos
-      setLen t.sons, pos
+      newSons t, pos
       setLen t.n.sons, pos
       break
 
@@ -590,8 +589,7 @@ proc replaceTypeVarsTAux(cl: var TReplTypeVars, t: PType): PType =
         # return tyStatic values to let anyone make
         # use of this knowledge. The patching here
         # won't be necessary then.
-        result = newTypeS(tyStatic, cl.c)
-        result.sons = @[n.typ]
+        result = newTypeS(tyStatic, cl.c, sons = @[n.typ])
         result.n = n
       else:
         result = n.typ