tsingle_methods.nim 830 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. discard """
  2. matrix: "--mm:arc --multimethods:off; --mm:refc --multimethods:off"
  3. output: '''base
  4. base
  5. base
  6. base
  7. base
  8. base
  9. '''
  10. """
  11. # bug #10912
  12. type
  13. X = ref object of RootObj
  14. type
  15. A* = ref object of RootObj
  16. B* = ref object of A
  17. C* = ref object of A
  18. D* = ref object of A
  19. E* = ref object of A
  20. F* = ref object of A
  21. method resolve(self: var X, stmt: A) {.base.} = echo "base"
  22. proc resolveSeq*(self: var X, statements: seq[A]) =
  23. for statement in statements:
  24. resolve(self, statement)
  25. method resolve(self: var X, stmt: B) =
  26. echo "B"
  27. method resolve(self: var X, stmt: D) =
  28. echo "D"
  29. method resolve(self: var X, stmt: E) =
  30. echo "E"
  31. method resolve(self: var X, stmt: C) =
  32. echo "C"
  33. method resolve(self: var X, stmt: F) =
  34. echo "F"
  35. var x = X()
  36. var a = @[A(), B(), C(), D(), E(), F()]
  37. resolveSeq(x, a)