diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2017-02-24 13:02:36 +0100 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2017-02-24 13:02:36 +0100 |
commit | f8914cc3b002916c2b9a9cc548eae610d14ef666 (patch) | |
tree | b5ab9dade22a60973e022907c12d857755d45a52 /compiler/cgmeth.nim | |
parent | 46f33515d7ec32215122547bce535e4c91894da3 (diff) | |
download | Nim-f8914cc3b002916c2b9a9cc548eae610d14ef666.tar.gz |
fixes a multimethod regression
Diffstat (limited to 'compiler/cgmeth.nim')
-rw-r--r-- | compiler/cgmeth.nim | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/compiler/cgmeth.nim b/compiler/cgmeth.nim index 52fd8ab49..3a945ae0a 100644 --- a/compiler/cgmeth.nim +++ b/compiler/cgmeth.nim @@ -35,15 +35,18 @@ proc genConv(n: PNode, d: PType, downcast: bool): PNode = else: result = n +proc getDispatcher*(s: PSym): PSym = + ## can return nil if is has no dispatcher. + let dispn = lastSon(s.ast) + if dispn.kind == nkSym: + let disp = dispn.sym + if sfDispatcher in disp.flags: result = disp + proc methodCall*(n: PNode): PNode = result = n # replace ordinary method by dispatcher method: - let dispn = lastSon(result.sons[0].sym.ast) - if dispn.kind == nkSym: - let disp = dispn.sym - if sfDispatcher notin disp.flags: - localError(n.info, "'" & $result & "' lacks a dispatcher") - return + let disp = getDispatcher(result.sons[0].sym) + if disp != nil: result.sons[0].sym = disp # change the arguments to up/downcasts to fit the dispatcher's parameters: for i in countup(1, sonsLen(result)-1): |