toverloading_typedesc.nim 626 B

1234567891011121314151617181920
  1. import moverloading_typedesc
  2. import tables
  3. type
  4. LFoo = object
  5. LBar = object
  6. when true:
  7. doAssert FBar.new() == 3
  8. proc new(_: typedesc[LFoo]): int = 0
  9. proc new[T](_: typedesc[T]): int = 1
  10. proc new*(_: typedesc[seq[Table[int, seq[Table[int, typedesc]]]]]): int = 7
  11. doAssert LFoo.new() == 0 # Tests selecting more precise type
  12. doAssert LBar.new() == 1 # Tests preferring function from local scope
  13. doAssert FBar.new() == 1
  14. doAssert FFoo.new() == 2 # Tests selecting more precise type from other module
  15. doAssert seq[Table[int, seq[Table[int, string]]]].new() == 5 # Truly complex type test