self.carbon 4.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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: %UseSelf.type: type = facet_type <@UseSelf> [concrete]
  17. // CHECK:STDOUT: %Self: %UseSelf.type = bind_symbolic_name Self, 0 [symbolic]
  18. // CHECK:STDOUT: %Self.as_type: type = facet_access_type %Self [symbolic]
  19. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  20. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  21. // CHECK:STDOUT: %UseSelf.assoc_type: type = assoc_entity_type %UseSelf.type [concrete]
  22. // CHECK:STDOUT: %assoc0: %UseSelf.assoc_type = assoc_entity element0, @UseSelf.%F.decl [concrete]
  23. // CHECK:STDOUT: }
  24. // CHECK:STDOUT:
  25. // CHECK:STDOUT: file {
  26. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  27. // CHECK:STDOUT: .UseSelf = %UseSelf.decl
  28. // CHECK:STDOUT: }
  29. // CHECK:STDOUT: %UseSelf.decl: type = interface_decl @UseSelf [concrete = constants.%UseSelf.type] {} {}
  30. // CHECK:STDOUT: }
  31. // CHECK:STDOUT:
  32. // CHECK:STDOUT: interface @UseSelf {
  33. // CHECK:STDOUT: %Self: %UseSelf.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
  34. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  35. // CHECK:STDOUT: %self.patt: @F.%Self.as_type.loc12_14.1 (%Self.as_type) = binding_pattern self
  36. // CHECK:STDOUT: %self.param_patt: @F.%Self.as_type.loc12_14.1 (%Self.as_type) = value_param_pattern %self.patt, runtime_param0
  37. // CHECK:STDOUT: %return.patt: @F.%Self.as_type.loc12_14.1 (%Self.as_type) = return_slot_pattern
  38. // CHECK:STDOUT: %return.param_patt: @F.%Self.as_type.loc12_14.1 (%Self.as_type) = out_param_pattern %return.patt, runtime_param1
  39. // CHECK:STDOUT: } {
  40. // CHECK:STDOUT: %Self.ref.loc12_25: %UseSelf.type = name_ref Self, @UseSelf.%Self [symbolic = %Self (constants.%Self)]
  41. // CHECK:STDOUT: %Self.as_type.loc12_25: type = facet_access_type %Self.ref.loc12_25 [symbolic = %Self.as_type.loc12_14.1 (constants.%Self.as_type)]
  42. // CHECK:STDOUT: %.loc12_25: type = converted %Self.ref.loc12_25, %Self.as_type.loc12_25 [symbolic = %Self.as_type.loc12_14.1 (constants.%Self.as_type)]
  43. // CHECK:STDOUT: %self.param: @F.%Self.as_type.loc12_14.1 (%Self.as_type) = value_param runtime_param0
  44. // CHECK:STDOUT: %.loc12_14.1: type = splice_block %.loc12_14.2 [symbolic = %Self.as_type.loc12_14.1 (constants.%Self.as_type)] {
  45. // CHECK:STDOUT: %Self.ref.loc12_14: %UseSelf.type = name_ref Self, @UseSelf.%Self [symbolic = %Self (constants.%Self)]
  46. // CHECK:STDOUT: %Self.as_type.loc12_14.2: type = facet_access_type %Self.ref.loc12_14 [symbolic = %Self.as_type.loc12_14.1 (constants.%Self.as_type)]
  47. // CHECK:STDOUT: %.loc12_14.2: type = converted %Self.ref.loc12_14, %Self.as_type.loc12_14.2 [symbolic = %Self.as_type.loc12_14.1 (constants.%Self.as_type)]
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT: %self: @F.%Self.as_type.loc12_14.1 (%Self.as_type) = bind_name self, %self.param
  50. // CHECK:STDOUT: %return.param: ref @F.%Self.as_type.loc12_14.1 (%Self.as_type) = out_param runtime_param1
  51. // CHECK:STDOUT: %return: ref @F.%Self.as_type.loc12_14.1 (%Self.as_type) = return_slot %return.param
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT: %assoc0: %UseSelf.assoc_type = assoc_entity element0, %F.decl [concrete = constants.%assoc0]
  54. // CHECK:STDOUT:
  55. // CHECK:STDOUT: !members:
  56. // CHECK:STDOUT: .Self = %Self
  57. // CHECK:STDOUT: .F = %assoc0
  58. // CHECK:STDOUT: witness = (%F.decl)
  59. // CHECK:STDOUT: }
  60. // CHECK:STDOUT:
  61. // CHECK:STDOUT: generic fn @F(@UseSelf.%Self: %UseSelf.type) {
  62. // CHECK:STDOUT: %Self: %UseSelf.type = bind_symbolic_name Self, 0 [symbolic = %Self (constants.%Self)]
  63. // CHECK:STDOUT: %Self.as_type.loc12_14.1: type = facet_access_type %Self [symbolic = %Self.as_type.loc12_14.1 (constants.%Self.as_type)]
  64. // CHECK:STDOUT:
  65. // CHECK:STDOUT: fn[%self.param_patt: @F.%Self.as_type.loc12_14.1 (%Self.as_type)]() -> @F.%Self.as_type.loc12_14.1 (%Self.as_type);
  66. // CHECK:STDOUT: }
  67. // CHECK:STDOUT:
  68. // CHECK:STDOUT: specific @F(constants.%Self) {
  69. // CHECK:STDOUT: %Self => constants.%Self
  70. // CHECK:STDOUT: %Self.as_type.loc12_14.1 => constants.%Self.as_type
  71. // CHECK:STDOUT: }
  72. // CHECK:STDOUT: