issue_477_dynamic_dispatch.nim 340 B

1234567891011121314151617181920
  1. type
  2. TThing = object of TObject
  3. TUnit = object of TThing
  4. x: int
  5. method collide(a, b: TThing) {.inline.} =
  6. quit "to override!"
  7. method collide(a: TThing, b: TUnit) {.inline.} =
  8. echo "collide1"
  9. method collide(a: TUnit, b: TThing) {.inline.} =
  10. echo "collide2"
  11. var
  12. a, b: TUnit
  13. when isMainModule:
  14. collide(a, b) # output: 2