dont_call_in_method.carbon 748 B

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