68aebf293bd4ae573c514613325fcf490c8d98c4 587 B

1234567891011121314151617181920212223
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // AUTOUPDATE
  6. // CHECK:STDOUT: result: 3
  7. package ExplorerTest;
  8. // The bodies of member functions are processed after all immediately enclosing
  9. // classes, impl declarations, and interfaces.
  10. class A {
  11. fn F[self: Self]() -> i32 {
  12. return G() + self.H();
  13. }
  14. fn G() -> i32 { return 1; }
  15. fn H[self: Self]() -> i32 { return 2; }
  16. }
  17. fn Main() -> i32 {
  18. var a: A = {};
  19. return a.F();
  20. }