summary refs log tree commit diff stats
path: root/compiler/cgmeth.nim
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2021-01-23 08:06:15 +0100
committerGitHub <noreply@github.com>2021-01-23 08:06:15 +0100
commit8241e55023ee32c9ec0b5443723bbe91f4fe875f (patch)
treed14be71f134b1789db54028704748c4dbed46bfa /compiler/cgmeth.nim
parenteae3bdf8fe554cdd334b8a53de63fd9bf10a7832 (diff)
downloadNim-8241e55023ee32c9ec0b5443723bbe91f4fe875f.tar.gz
IC: next steps (#16729)
* IC: dead code elimination pass
* preparations for a different codegen strategy
* added documentation to the newly written code
* IC: backend code
* IC: backend adjustments
* optimized the compiler a bit
* IC: yet another massive refactoring
* fixes regressions
* cleanups
Diffstat (limited to 'compiler/cgmeth.nim')
-rw-r--r--compiler/cgmeth.nim7
1 files changed, 5 insertions, 2 deletions
diff --git a/compiler/cgmeth.nim b/compiler/cgmeth.nim
index a995804c7..b14465828 100644
--- a/compiler/cgmeth.nim
+++ b/compiler/cgmeth.nim
@@ -107,11 +107,14 @@ proc attachDispatcher(s: PSym, dispatcher: PNode) =
       s.ast[resultPos] = newNodeI(nkEmpty, s.info)
     s.ast[dispatcherPos] = dispatcher
 
-proc createDispatcher(s: PSym; idgen: IdGenerator): PSym =
+proc createDispatcher(s: PSym; g: ModuleGraph; idgen: IdGenerator): PSym =
   var disp = copySym(s, nextSymId(idgen))
   incl(disp.flags, sfDispatcher)
   excl(disp.flags, sfExported)
+  let old = disp.typ
   disp.typ = copyType(disp.typ, nextTypeId(idgen), disp.typ.owner)
+  copyTypeProps(g, idgen.module, disp.typ, old)
+
   # we can't inline the dispatcher itself (for now):
   if disp.typ.callConv == ccInline: disp.typ.callConv = ccNimCall
   disp.ast = copyTree(s.ast)
@@ -177,7 +180,7 @@ proc methodDef*(g: ModuleGraph; idgen: IdGenerator; s: PSym, fromCache: bool) =
     of Invalid:
       if witness.isNil: witness = g.methods[i].methods[0]
   # create a new dispatcher:
-  g.methods.add((methods: @[s], dispatcher: createDispatcher(s, idgen)))
+  g.methods.add((methods: @[s], dispatcher: createDispatcher(s, g, idgen)))
   #echo "adding ", s.info
   #if fromCache:
   #  internalError(s.info, "no method dispatcher found")