generic multi-methods should work now
This commit is contained in:
parent
34afaeeedd
commit
f5fa5dae85
9 changed files with 67 additions and 21 deletions
24
tests/method/tgeneric_methods.nim
Normal file
24
tests/method/tgeneric_methods.nim
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
discard """
|
||||
output: "wow2"
|
||||
"""
|
||||
type
|
||||
First[T] = ref object of RootObj
|
||||
value: T
|
||||
|
||||
Second[T] = ref object of First[T]
|
||||
value2: T
|
||||
|
||||
method wow[T](y: int; x: First[T]) {.base.} =
|
||||
echo "wow1"
|
||||
|
||||
method wow[T](y: int; x: Second[T]) =
|
||||
echo "wow2"
|
||||
|
||||
var
|
||||
x: Second[int]
|
||||
new(x)
|
||||
|
||||
proc takeFirst(x: First[int]) =
|
||||
wow(2, x)
|
||||
|
||||
takeFirst(x)
|
||||
Loading…
Add table
Add a link
Reference in a new issue