Files
Nim/tests/method/tmproto.nim
Reimer Behrends ce9a57fcfd 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.
2014-11-02 23:35:41 +01:00

26 lines
439 B
Nim

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