self.carbon 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 %.1, %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.patt: @F.%Self (%Self) = binding_pattern self
  36. // CHECK:STDOUT: } {
  37. // CHECK:STDOUT: %Self.ref.loc12_14: %.1 = name_ref Self, @UseSelf.%Self [symbolic = %Self (constants.%Self)]
  38. // CHECK:STDOUT: %.loc12_14.1: type = facet_type_access %Self.ref.loc12_14 [symbolic = %Self (constants.%Self)]
  39. // CHECK:STDOUT: %.loc12_14.2: type = converted %Self.ref.loc12_14, %.loc12_14.1 [symbolic = %Self (constants.%Self)]
  40. // CHECK:STDOUT: %self.param: @F.%Self (%Self) = param self, runtime_param0
  41. // CHECK:STDOUT: %self: @F.%Self (%Self) = bind_name self, %self.param
  42. // CHECK:STDOUT: %Self.ref.loc12_25: %.1 = name_ref Self, @UseSelf.%Self [symbolic = %Self (constants.%Self)]
  43. // CHECK:STDOUT: %.loc12_25.1: type = facet_type_access %Self.ref.loc12_25 [symbolic = %Self (constants.%Self)]
  44. // CHECK:STDOUT: %.loc12_25.2: type = converted %Self.ref.loc12_25, %.loc12_25.1 [symbolic = %Self (constants.%Self)]
  45. // CHECK:STDOUT: %return: ref @F.%Self (%Self) = var <return slot>
  46. // CHECK:STDOUT: }
  47. // CHECK:STDOUT: %.loc12: %.3 = assoc_entity element0, %F.decl [template = constants.%.4]
  48. // CHECK:STDOUT:
  49. // CHECK:STDOUT: !members:
  50. // CHECK:STDOUT: .Self = %Self
  51. // CHECK:STDOUT: .F = %.loc12
  52. // CHECK:STDOUT: witness = (%F.decl)
  53. // CHECK:STDOUT: }
  54. // CHECK:STDOUT:
  55. // CHECK:STDOUT: generic fn @F(@UseSelf.%Self: %.1) {
  56. // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self)]
  57. // CHECK:STDOUT:
  58. // CHECK:STDOUT: fn[%self: @F.%Self (%Self)]() -> @F.%Self (%Self);
  59. // CHECK:STDOUT: }
  60. // CHECK:STDOUT:
  61. // CHECK:STDOUT: specific @F(constants.%Self) {
  62. // CHECK:STDOUT: %Self => constants.%Self
  63. // CHECK:STDOUT: }
  64. // CHECK:STDOUT: