Overload.k 776 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. invoke {
  2. interface I {
  3. foo (x: Int) -> Int
  4. foo (x: Int, y: Int) -> Int
  5. bar () -> Int
  6. baz (x: Int) -> Int {
  7. return foo(x) + bar()
  8. }
  9. baz () -> Int {
  10. return bar()
  11. }
  12. }
  13. class A is I {
  14. init () {
  15. do nothing
  16. }
  17. foo (x: Int) -> Int {
  18. return x + 1
  19. }
  20. foo (x: Int, y: Int) -> Int {
  21. return x * y
  22. }
  23. bar () -> Int {
  24. return 999
  25. }
  26. bar (x: Int) -> String {
  27. return str(x)
  28. }
  29. }
  30. let a = A()
  31. assert a->foo(5) == 6
  32. assert a->foo(5,7) == 35
  33. assert a->bar() == 999
  34. assert a->bar(9) == '9'
  35. assert a->baz() == 999
  36. assert a->baz(1) == 1001
  37. }