self.carbon 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/interface/no_prelude/self.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interface/no_prelude/self.carbon
  10. interface UseSelf {
  11. fn F[self: Self]() -> Self;
  12. }
  13. // CHECK:STDOUT: --- self.carbon
  14. // CHECK:STDOUT:
  15. // CHECK:STDOUT: constants {
  16. // CHECK:STDOUT: %.1: type = interface_type @UseSelf [template]
  17. // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic]
  18. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  19. // CHECK:STDOUT: %.2: type = tuple_type () [template]
  20. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  21. // CHECK:STDOUT: %.3: type = assoc_entity_type @UseSelf, %F.type [template]
  22. // CHECK:STDOUT: %.4: %.3 = assoc_entity element0, @UseSelf.%F.decl [template]
  23. // CHECK:STDOUT: }
  24. // CHECK:STDOUT:
  25. // CHECK:STDOUT: file {
  26. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  27. // CHECK:STDOUT: .UseSelf = %UseSelf.decl
  28. // CHECK:STDOUT: }
  29. // CHECK:STDOUT: %UseSelf.decl: type = interface_decl @UseSelf [template = constants.%.1] {}
  30. // CHECK:STDOUT: }
  31. // CHECK:STDOUT:
  32. // CHECK:STDOUT: interface @UseSelf {
  33. // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic = constants.%Self]
  34. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  35. // CHECK:STDOUT: %Self.ref.loc12_14: %.1 = name_ref Self, %Self [symbolic = constants.%Self]
  36. // CHECK:STDOUT: %.loc12_14.1: type = facet_type_access %Self.ref.loc12_14 [symbolic = constants.%Self]
  37. // CHECK:STDOUT: %.loc12_14.2: type = converted %Self.ref.loc12_14, %.loc12_14.1 [symbolic = constants.%Self]
  38. // CHECK:STDOUT: %self.loc12_8.1: %Self = param self
  39. // CHECK:STDOUT: %self.loc12_8.2: %Self = bind_name self, %self.loc12_8.1
  40. // CHECK:STDOUT: %Self.ref.loc12_25: %.1 = name_ref Self, %Self [symbolic = constants.%Self]
  41. // CHECK:STDOUT: %.loc12_25.1: type = facet_type_access %Self.ref.loc12_25 [symbolic = constants.%Self]
  42. // CHECK:STDOUT: %.loc12_25.2: type = converted %Self.ref.loc12_25, %.loc12_25.1 [symbolic = constants.%Self]
  43. // CHECK:STDOUT: %return.var: ref %Self = var <return slot>
  44. // CHECK:STDOUT: }
  45. // CHECK:STDOUT: %.loc12_29: %.3 = assoc_entity element0, %F.decl [template = constants.%.4]
  46. // CHECK:STDOUT:
  47. // CHECK:STDOUT: !members:
  48. // CHECK:STDOUT: .Self = %Self
  49. // CHECK:STDOUT: .F = %.loc12_29
  50. // CHECK:STDOUT: witness = (%F.decl)
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT:
  53. // CHECK:STDOUT: fn @F[@UseSelf.%self.loc12_8.2: %Self]() -> %Self
  54. // CHECK:STDOUT: generic [@UseSelf.%Self: %.1];
  55. // CHECK:STDOUT: