dont_call_in_method.carbon 672 B

1234567891011121314151617181920212223242526272829303132333435
  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: TEST
  7. // CHECK:STDOUT: TEST 2
  8. // CHECK:STDOUT: DESTRUCTOR A 1
  9. // CHECK:STDOUT: result: 1
  10. package ExplorerTest api;
  11. class B{
  12. var n : i32;
  13. }
  14. class A{
  15. destructor[self: Self]{
  16. Print("DESTRUCTOR A {0}",self.n);
  17. }
  18. fn test[self: Self](){
  19. Print("TEST");
  20. }
  21. fn test2[self: Self](){
  22. Print("TEST 2");
  23. }
  24. var n: i32;
  25. }
  26. fn Main() -> i32 {
  27. var a: A = {.n = 1 };
  28. a.test();
  29. a.test2();
  30. return 1;
  31. }