Self.k 333 B

123456789101112131415161718
  1. invoke {
  2. class A {
  3. init (x: Int) {
  4. do nothing
  5. }
  6. foo () -> Int {
  7. return x
  8. }
  9. bar () -> Int {
  10. assert self is Instance
  11. assert self is A
  12. return self->foo() + 1
  13. }
  14. }
  15. assert A(2)->foo() == 2
  16. assert A(2)->bar() == 3
  17. }