diff options
author | Reimer Behrends <behrends@gmail.com> | 2014-11-02 23:35:41 +0100 |
---|---|---|
committer | Reimer Behrends <behrends@gmail.com> | 2014-11-02 23:35:41 +0100 |
commit | ce9a57fcfd21a1a3cb17087107c246f0492bec7f (patch) | |
tree | e6ddce20df948ac7fba95c876a9d29d1ad735757 /tests/method | |
parent | bce2d57d95b71f3e4a5d4585ea735870251d1caa (diff) | |
download | Nim-ce9a57fcfd21a1a3cb17087107c246f0492bec7f.tar.gz |
Fix dispatcher creation for method prototypes.
When method prototypes were involved (e.g. forward declarations for mutual recursion), calls were sometimes dispatched to the wrong method implementation. One of the reasons was that method dispatchers were then not always attached to method ASTs in the correct place.
Diffstat (limited to 'tests/method')
-rw-r--r-- | tests/method/tmproto.nim | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/method/tmproto.nim b/tests/method/tmproto.nim new file mode 100644 index 000000000..5d75cff1a --- /dev/null +++ b/tests/method/tmproto.nim @@ -0,0 +1,25 @@ +type + Obj1 = ref object {.inheritable.} + Obj2 = ref object of Obj1 + +method beta(x: Obj1): int + +proc delta(x: Obj2): int = + beta(x) + +method beta(x: Obj2): int + +proc alpha(x: Obj1): int = + beta(x) + +method beta(x: Obj1): int = 1 +method beta(x: Obj2): int = 2 + +proc gamma(x: Obj1): int = + beta(x) + +doAssert alpha(Obj1()) == 1 +doAssert gamma(Obj1()) == 1 +doAssert alpha(Obj2()) == 2 +doAssert gamma(Obj2()) == 2 +doAssert delta(Obj2()) == 2 |