tcompilegenerics.nim 432 B

123456789101112131415161718192021222324
  1. discard """
  2. matrix: "--mm:arc; --mm:refc"
  3. output: '''
  4. newDNode base
  5. '''
  6. """
  7. type
  8. SNodeAny = ref object of RootObj
  9. SNode[T] = ref object of SNodeAny
  10. m: T
  11. DNode[T] = ref object
  12. method getStr(s: SNode[float]): string {.base.} = "blahblah"
  13. method newDNode(s: SNodeAny) {.base.} =
  14. echo "newDNode base"
  15. method newDNode[T](s: SNode[T]) =
  16. echo "newDNode generic"
  17. let m = SNode[float]()
  18. let s = SNodeAny(m)
  19. newDnode(s)