tgeneric_methods.nim 535 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. discard """
  2. output: '''wow2
  3. X 1
  4. X 3'''
  5. """
  6. type
  7. First[T] = ref object of RootObj
  8. value: T
  9. Second[T] = ref object of First[T]
  10. value2: T
  11. method wow[T](y: int; x: First[T]) {.base.} =
  12. echo "wow1"
  13. method wow[T](y: int; x: Second[T]) =
  14. echo "wow2"
  15. var
  16. x: Second[int]
  17. new(x)
  18. proc takeFirst(x: First[int]) =
  19. wow(2, x)
  20. takeFirst(x)
  21. # bug #5479
  22. type
  23. Base[T: static[int]] = ref object of RootObj
  24. method test[T](t: Base[T]) {.base.} =
  25. echo "X ", t.T
  26. let ab = Base[1]()
  27. ab.test()
  28. let ac = Base[3]()
  29. ac.test()