File: tgeneric_methods.nim

package info (click to toggle)
nim 0.19.4-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 462,356 kB
  • sloc: sh: 11,089; ansic: 4,699; makefile: 706; python: 309; sql: 297; asm: 141; xml: 13
file content (41 lines) | stat: -rw-r--r-- 535 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
discard """
  output: '''wow2
X 1
X 3'''
"""
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)


# bug #5479
type
  Base[T: static[int]] = ref object of RootObj

method test[T](t: Base[T]) {.base.} =
  echo "X ", t.T

let ab = Base[1]()

ab.test()

let ac = Base[3]()
ac.test()