tmixin.nim 271 B

12345678910111213141516171819202122232425262728
  1. discard """
  2. output: "1\n2"
  3. """
  4. type
  5. TFoo1 = object of TObject
  6. v: int
  7. TFoo2 = object of TFoo1
  8. v2: int
  9. proc test(f: TFoo1) =
  10. echo "1"
  11. proc Foo[T](f: T) =
  12. mixin test
  13. test(f)
  14. var
  15. a: TFoo1
  16. b: TFoo2
  17. proc test(f: TFoo2) =
  18. echo "2"
  19. Foo(a)
  20. Foo(b)