class_fn_body_reorder.carbon 594 B

123456789101112131415161718192021222324
  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. // NOAUTOUPDATE
  6. package ExplorerTest api;
  7. // The bodies of member functions are processed after all immediately enclosing
  8. // classes, impl declarations, and interfaces.
  9. class A {
  10. fn F[self: Self]() -> i32 {
  11. return G() + self.H();
  12. }
  13. fn G() -> i32 { return 1; }
  14. fn H[self: Self]() -> i32 { return 2; }
  15. }
  16. fn Main() -> i32 {
  17. var a: A = {};
  18. return a.F();
  19. }
  20. // CHECK:STDOUT: result: 3