summary refs log tree commit diff stats
path: root/compiler/seminst.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2014-07-15 09:30:58 +0200
committerAraq <rumpf_a@web.de>2014-07-15 09:30:58 +0200
commit0743f78012e954f5295df7923ccabd472a5a7502 (patch)
tree5d681c9835f01019e8ae83e14c0cd49d1a6c0d38 /compiler/seminst.nim
parent7fa399f51c39e6661876223009d5003cd2e0cf99 (diff)
parent18ded6c23d72cd21fa0aa10ff61dc6f9af40832c (diff)
downloadNim-0743f78012e954f5295df7923ccabd472a5a7502.tar.gz
Merge branch 'master' of https://github.com/Araq/Nimrod
Diffstat (limited to 'compiler/seminst.nim')
-rw-r--r--compiler/seminst.nim8
1 files changed, 5 insertions, 3 deletions
diff --git a/compiler/seminst.nim b/compiler/seminst.nim
index f7d5fa6f8..b93d7ca15 100644
--- a/compiler/seminst.nim
+++ b/compiler/seminst.nim
@@ -190,6 +190,9 @@ proc instantiateProcType(c: PContext, pt: TIdTable,
 
 proc generateInstance(c: PContext, fn: PSym, pt: TIdTable,
                       info: TLineInfo): PSym =
+  ## Generates a new instance of a generic procedure.
+  ## The `pt` parameter is a type-unsafe mapping table used to link generic
+  ## parameters to their concrete types within the generic instance.
   # no need to instantiate generic templates/macros:
   if fn.kind in {skTemplate, skMacro}: return fn
   # generates an instantiated proc
@@ -199,8 +202,7 @@ proc generateInstance(c: PContext, fn: PSym, pt: TIdTable,
   var n = copyTree(fn.ast)
   # NOTE: for access of private fields within generics from a different module
   # we set the friend module:
-  var oldFriend = c.friendModule
-  c.friendModule = getModule(fn)
+  c.friendModules.add(getModule(fn))
   #let oldScope = c.currentScope
   #c.currentScope = fn.scope
   result = copySym(fn, false)
@@ -236,6 +238,6 @@ proc generateInstance(c: PContext, fn: PSym, pt: TIdTable,
   closeScope(c)           # close scope for parameters
   popOwner()
   #c.currentScope = oldScope
-  c.friendModule = oldFriend
+  discard c.friendModules.pop()
   dec(c.instCounter)
   if result.kind == skMethod: finishMethod(c, result)