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.
This commit is contained in:
parent
bce2d57d95
commit
ce9a57fcfd
3 changed files with 92 additions and 28 deletions
25
tests/method/tmproto.nim
Normal file
25
tests/method/tmproto.nim
Normal file
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue