diff options
Diffstat (limited to 'tests/method/tgeneric_methods.nim')
-rw-r--r-- | tests/method/tgeneric_methods.nim | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/method/tgeneric_methods.nim b/tests/method/tgeneric_methods.nim new file mode 100644 index 000000000..76a68fbb0 --- /dev/null +++ b/tests/method/tgeneric_methods.nim @@ -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) |