self.carbon 5.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  6. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  7. //
  8. // AUTOUPDATE
  9. // TIP: To test this file alone, run:
  10. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/interface/no_prelude/self.carbon
  11. // TIP: To dump output, run:
  12. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interface/no_prelude/self.carbon
  13. interface UseSelf {
  14. fn F[self: Self]() -> Self;
  15. }
  16. // CHECK:STDOUT: --- self.carbon
  17. // CHECK:STDOUT:
  18. // CHECK:STDOUT: constants {
  19. // CHECK:STDOUT: %UseSelf.type: type = facet_type <@UseSelf> [concrete]
  20. // CHECK:STDOUT: %Self: %UseSelf.type = bind_symbolic_name Self, 0 [symbolic]
  21. // CHECK:STDOUT: %Self.as_type: type = facet_access_type %Self [symbolic]
  22. // CHECK:STDOUT: %pattern_type: type = pattern_type %Self.as_type [symbolic]
  23. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  24. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  25. // CHECK:STDOUT: %UseSelf.assoc_type: type = assoc_entity_type @UseSelf [concrete]
  26. // CHECK:STDOUT: %assoc0: %UseSelf.assoc_type = assoc_entity element0, @UseSelf.%F.decl [concrete]
  27. // CHECK:STDOUT: }
  28. // CHECK:STDOUT:
  29. // CHECK:STDOUT: file {
  30. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  31. // CHECK:STDOUT: .UseSelf = %UseSelf.decl
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT: %UseSelf.decl: type = interface_decl @UseSelf [concrete = constants.%UseSelf.type] {} {}
  34. // CHECK:STDOUT: }
  35. // CHECK:STDOUT:
  36. // CHECK:STDOUT: interface @UseSelf {
  37. // CHECK:STDOUT: %Self: %UseSelf.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
  38. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  39. // CHECK:STDOUT: %self.patt: @F.%pattern_type (%pattern_type) = binding_pattern self [concrete]
  40. // CHECK:STDOUT: %self.param_patt: @F.%pattern_type (%pattern_type) = value_param_pattern %self.patt, call_param0 [concrete]
  41. // CHECK:STDOUT: %return.patt: @F.%pattern_type (%pattern_type) = return_slot_pattern [concrete]
  42. // CHECK:STDOUT: %return.param_patt: @F.%pattern_type (%pattern_type) = out_param_pattern %return.patt, call_param1 [concrete]
  43. // CHECK:STDOUT: } {
  44. // CHECK:STDOUT: %Self.ref.loc15_25: %UseSelf.type = name_ref Self, @UseSelf.%Self [symbolic = %Self (constants.%Self)]
  45. // CHECK:STDOUT: %Self.as_type.loc15_25: type = facet_access_type %Self.ref.loc15_25 [symbolic = %Self.as_type.loc15_14.1 (constants.%Self.as_type)]
  46. // CHECK:STDOUT: %.loc15_25: type = converted %Self.ref.loc15_25, %Self.as_type.loc15_25 [symbolic = %Self.as_type.loc15_14.1 (constants.%Self.as_type)]
  47. // CHECK:STDOUT: %self.param: @F.%Self.as_type.loc15_14.1 (%Self.as_type) = value_param call_param0
  48. // CHECK:STDOUT: %.loc15_14.1: type = splice_block %.loc15_14.2 [symbolic = %Self.as_type.loc15_14.1 (constants.%Self.as_type)] {
  49. // CHECK:STDOUT: %Self.ref.loc15_14: %UseSelf.type = name_ref Self, @UseSelf.%Self [symbolic = %Self (constants.%Self)]
  50. // CHECK:STDOUT: %Self.as_type.loc15_14.2: type = facet_access_type %Self.ref.loc15_14 [symbolic = %Self.as_type.loc15_14.1 (constants.%Self.as_type)]
  51. // CHECK:STDOUT: %.loc15_14.2: type = converted %Self.ref.loc15_14, %Self.as_type.loc15_14.2 [symbolic = %Self.as_type.loc15_14.1 (constants.%Self.as_type)]
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT: %self: @F.%Self.as_type.loc15_14.1 (%Self.as_type) = bind_name self, %self.param
  54. // CHECK:STDOUT: %return.param: ref @F.%Self.as_type.loc15_14.1 (%Self.as_type) = out_param call_param1
  55. // CHECK:STDOUT: %return: ref @F.%Self.as_type.loc15_14.1 (%Self.as_type) = return_slot %return.param
  56. // CHECK:STDOUT: }
  57. // CHECK:STDOUT: %assoc0: %UseSelf.assoc_type = assoc_entity element0, %F.decl [concrete = constants.%assoc0]
  58. // CHECK:STDOUT:
  59. // CHECK:STDOUT: !members:
  60. // CHECK:STDOUT: .Self = %Self
  61. // CHECK:STDOUT: .F = %assoc0
  62. // CHECK:STDOUT: witness = (%F.decl)
  63. // CHECK:STDOUT: }
  64. // CHECK:STDOUT:
  65. // CHECK:STDOUT: generic fn @F(@UseSelf.%Self: %UseSelf.type) {
  66. // CHECK:STDOUT: %Self: %UseSelf.type = bind_symbolic_name Self, 0 [symbolic = %Self (constants.%Self)]
  67. // CHECK:STDOUT: %Self.as_type.loc15_14.1: type = facet_access_type %Self [symbolic = %Self.as_type.loc15_14.1 (constants.%Self.as_type)]
  68. // CHECK:STDOUT: %pattern_type: type = pattern_type %Self.as_type.loc15_14.1 [symbolic = %pattern_type (constants.%pattern_type)]
  69. // CHECK:STDOUT:
  70. // CHECK:STDOUT: fn(%self.param: @F.%Self.as_type.loc15_14.1 (%Self.as_type)) -> @F.%Self.as_type.loc15_14.1 (%Self.as_type);
  71. // CHECK:STDOUT: }
  72. // CHECK:STDOUT:
  73. // CHECK:STDOUT: specific @F(constants.%Self) {
  74. // CHECK:STDOUT: %Self => constants.%Self
  75. // CHECK:STDOUT: %Self.as_type.loc15_14.1 => constants.%Self.as_type
  76. // CHECK:STDOUT: %pattern_type => constants.%pattern_type
  77. // CHECK:STDOUT: }
  78. // CHECK:STDOUT: