summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorParashurama <Rhagdamaziel@ymail.com>2017-05-12 11:21:43 +0200
committerAndreas Rumpf <rumpf_a@web.de>2017-05-12 11:21:43 +0200
commit2e420dfa382dc5af3a225a7b073da2d0eb3d899f (patch)
tree0051f1a00334d141fb98a06c58eef3718ba6155f /compiler
parent29507d2491939d2979fbdfc4704142bc6ef2565c (diff)
downloadNim-2e420dfa382dc5af3a225a7b073da2d0eb3d899f.tar.gz
fixes multiple nil-checks for methods (#5806)
Diffstat (limited to 'compiler')
-rw-r--r--compiler/cgmeth.nim9
1 files changed, 6 insertions, 3 deletions
diff --git a/compiler/cgmeth.nim b/compiler/cgmeth.nim
index e14306e56..1165ec932 100644
--- a/compiler/cgmeth.nim
+++ b/compiler/cgmeth.nim
@@ -233,6 +233,12 @@ proc genDispatcher(methods: TSymSeq, relevantCols: IntSet): PSym =
   var disp = newNodeI(nkIfStmt, base.info)
   var ands = getSysSym("and")
   var iss = getSysSym("of")
+  for col in countup(1, paramLen - 1):
+    if contains(relevantCols, col):
+      let param = base.typ.n.sons[col].sym
+      if param.typ.skipTypes(abstractInst).kind in {tyRef, tyPtr}:
+        addSon(nilchecks, newTree(nkCall,
+            newSymNode(getCompilerProc"chckNilDisp"), newSymNode(param)))
   for meth in countup(0, high(methods)):
     var curr = methods[meth]      # generate condition:
     var cond: PNode = nil
@@ -242,9 +248,6 @@ proc genDispatcher(methods: TSymSeq, relevantCols: IntSet): PSym =
         addSon(isn, newSymNode(iss))
         let param = base.typ.n.sons[col].sym
         addSon(isn, newSymNode(param))
-        if param.typ.skipTypes(abstractInst).kind in {tyRef, tyPtr}:
-          addSon(nilchecks, newTree(nkCall,
-                newSymNode(getCompilerProc"chckNilDisp"), newSymNode(param)))
         addSon(isn, newNodeIT(nkType, base.info, curr.typ.sons[col]))
         if cond != nil:
           var a = newNodeIT(nkCall, base.info, getSysType(tyBool))