tgeneric_methods.nim 709 B

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