local.carbon 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/none.carbon
  6. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  7. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  8. //
  9. // AUTOUPDATE
  10. // TIP: To test this file alone, run:
  11. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/interface/local.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interface/local.carbon
  14. fn F() {
  15. interface I {
  16. fn G[self: Self]();
  17. }
  18. impl () as I {
  19. fn G[self: Self]() {}
  20. }
  21. ().(I.G)();
  22. }
  23. // CHECK:STDOUT: --- local.carbon
  24. // CHECK:STDOUT:
  25. // CHECK:STDOUT: constants {
  26. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  27. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  28. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  29. // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
  30. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic]
  31. // CHECK:STDOUT: %Self.binding.as_type: type = symbolic_binding_type Self, 0, %Self [symbolic]
  32. // CHECK:STDOUT: %pattern_type.7db: type = pattern_type %Self.binding.as_type [symbolic]
  33. // CHECK:STDOUT: %I.G.type: type = fn_type @I.G [concrete]
  34. // CHECK:STDOUT: %I.G: %I.G.type = struct_value () [concrete]
  35. // CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type @I [concrete]
  36. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.%I.G.decl [concrete]
  37. // CHECK:STDOUT: %I.impl_witness: <witness> = impl_witness @F.%I.impl_witness_table [concrete]
  38. // CHECK:STDOUT: %pattern_type.cb1: type = pattern_type %empty_tuple.type [concrete]
  39. // CHECK:STDOUT: %empty_tuple.type.as.I.impl.G.type: type = fn_type @empty_tuple.type.as.I.impl.G [concrete]
  40. // CHECK:STDOUT: %empty_tuple.type.as.I.impl.G: %empty_tuple.type.as.I.impl.G.type = struct_value () [concrete]
  41. // CHECK:STDOUT: %I.facet: %I.type = facet_value %empty_tuple.type, (%I.impl_witness) [concrete]
  42. // CHECK:STDOUT: %.3db: type = fn_type_with_self_type %I.G.type, %I.facet [concrete]
  43. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete]
  44. // CHECK:STDOUT: }
  45. // CHECK:STDOUT:
  46. // CHECK:STDOUT: file {
  47. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  48. // CHECK:STDOUT: .F = %F.decl
  49. // CHECK:STDOUT: }
  50. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {} {}
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT:
  53. // CHECK:STDOUT: interface @I {
  54. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
  55. // CHECK:STDOUT: %I.G.decl: %I.G.type = fn_decl @I.G [concrete = constants.%I.G] {
  56. // CHECK:STDOUT: %self.patt: @I.G.%pattern_type (%pattern_type.7db) = binding_pattern self [concrete]
  57. // CHECK:STDOUT: %self.param_patt: @I.G.%pattern_type (%pattern_type.7db) = value_param_pattern %self.patt, call_param0 [concrete]
  58. // CHECK:STDOUT: } {
  59. // CHECK:STDOUT: %self.param: @I.G.%Self.binding.as_type (%Self.binding.as_type) = value_param call_param0
  60. // CHECK:STDOUT: %.loc17_16.1: type = splice_block %.loc17_16.2 [symbolic = %Self.binding.as_type (constants.%Self.binding.as_type)] {
  61. // CHECK:STDOUT: %Self.ref: %I.type = name_ref Self, @I.%Self [symbolic = %Self (constants.%Self)]
  62. // CHECK:STDOUT: %Self.as_type: type = facet_access_type %Self.ref [symbolic = %Self.binding.as_type (constants.%Self.binding.as_type)]
  63. // CHECK:STDOUT: %.loc17_16.2: type = converted %Self.ref, %Self.as_type [symbolic = %Self.binding.as_type (constants.%Self.binding.as_type)]
  64. // CHECK:STDOUT: }
  65. // CHECK:STDOUT: %self: @I.G.%Self.binding.as_type (%Self.binding.as_type) = bind_name self, %self.param
  66. // CHECK:STDOUT: }
  67. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, %I.G.decl [concrete = constants.%assoc0]
  68. // CHECK:STDOUT:
  69. // CHECK:STDOUT: !members:
  70. // CHECK:STDOUT: .Self = %Self
  71. // CHECK:STDOUT: .G = %assoc0
  72. // CHECK:STDOUT: witness = (%I.G.decl)
  73. // CHECK:STDOUT: }
  74. // CHECK:STDOUT:
  75. // CHECK:STDOUT: impl @empty_tuple.type.as.I.impl: %.loc19_9.2 as %I.ref {
  76. // CHECK:STDOUT: %empty_tuple.type.as.I.impl.G.decl: %empty_tuple.type.as.I.impl.G.type = fn_decl @empty_tuple.type.as.I.impl.G [concrete = constants.%empty_tuple.type.as.I.impl.G] {
  77. // CHECK:STDOUT: %self.patt: %pattern_type.cb1 = binding_pattern self [concrete]
  78. // CHECK:STDOUT: %self.param_patt: %pattern_type.cb1 = value_param_pattern %self.patt, call_param0 [concrete]
  79. // CHECK:STDOUT: } {
  80. // CHECK:STDOUT: %self.param: %empty_tuple.type = value_param call_param0
  81. // CHECK:STDOUT: %Self.ref: type = name_ref Self, @empty_tuple.type.as.I.impl.%.loc19_9.2 [concrete = constants.%empty_tuple.type]
  82. // CHECK:STDOUT: %self: %empty_tuple.type = bind_name self, %self.param
  83. // CHECK:STDOUT: }
  84. // CHECK:STDOUT:
  85. // CHECK:STDOUT: !members:
  86. // CHECK:STDOUT: .G = %empty_tuple.type.as.I.impl.G.decl
  87. // CHECK:STDOUT: witness = @F.%I.impl_witness
  88. // CHECK:STDOUT: }
  89. // CHECK:STDOUT:
  90. // CHECK:STDOUT: fn @F() {
  91. // CHECK:STDOUT: !entry:
  92. // CHECK:STDOUT: %I.decl: type = interface_decl @I [concrete = constants.%I.type] {} {}
  93. // CHECK:STDOUT: impl_decl @empty_tuple.type.as.I.impl [concrete] {} {
  94. // CHECK:STDOUT: %.loc19_9.1: %empty_tuple.type = tuple_literal ()
  95. // CHECK:STDOUT: %.loc19_9.2: type = converted %.loc19_9.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  96. // CHECK:STDOUT: %I.ref: type = name_ref I, @F.%I.decl [concrete = constants.%I.type]
  97. // CHECK:STDOUT: }
  98. // CHECK:STDOUT: %I.impl_witness_table = impl_witness_table (@empty_tuple.type.as.I.impl.%empty_tuple.type.as.I.impl.G.decl), @empty_tuple.type.as.I.impl [concrete]
  99. // CHECK:STDOUT: %I.impl_witness: <witness> = impl_witness %I.impl_witness_table [concrete = constants.%I.impl_witness]
  100. // CHECK:STDOUT: %.loc22_4.1: %empty_tuple.type = tuple_literal ()
  101. // CHECK:STDOUT: %I.ref: type = name_ref I, %I.decl [concrete = constants.%I.type]
  102. // CHECK:STDOUT: %G.ref: %I.assoc_type = name_ref G, @I.%assoc0 [concrete = constants.%assoc0]
  103. // CHECK:STDOUT: %impl.elem0: %.3db = impl_witness_access constants.%I.impl_witness, element0 [concrete = constants.%empty_tuple.type.as.I.impl.G]
  104. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %.loc22_4.1, %impl.elem0
  105. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete = constants.%empty_tuple]
  106. // CHECK:STDOUT: %.loc22_4.2: %empty_tuple.type = converted %.loc22_4.1, %empty_tuple [concrete = constants.%empty_tuple]
  107. // CHECK:STDOUT: %empty_tuple.type.as.I.impl.G.call: init %empty_tuple.type = call %bound_method(%.loc22_4.2)
  108. // CHECK:STDOUT: return
  109. // CHECK:STDOUT: }
  110. // CHECK:STDOUT:
  111. // CHECK:STDOUT: generic fn @I.G(@I.%Self: %I.type) {
  112. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = %Self (constants.%Self)]
  113. // CHECK:STDOUT: %Self.binding.as_type: type = symbolic_binding_type Self, 0, %Self [symbolic = %Self.binding.as_type (constants.%Self.binding.as_type)]
  114. // CHECK:STDOUT: %pattern_type: type = pattern_type %Self.binding.as_type [symbolic = %pattern_type (constants.%pattern_type.7db)]
  115. // CHECK:STDOUT:
  116. // CHECK:STDOUT: fn(%self.param: @I.G.%Self.binding.as_type (%Self.binding.as_type));
  117. // CHECK:STDOUT: }
  118. // CHECK:STDOUT:
  119. // CHECK:STDOUT: fn @empty_tuple.type.as.I.impl.G(%self.param: %empty_tuple.type) {
  120. // CHECK:STDOUT: !entry:
  121. // CHECK:STDOUT: return
  122. // CHECK:STDOUT: }
  123. // CHECK:STDOUT:
  124. // CHECK:STDOUT: specific @I.G(constants.%Self) {
  125. // CHECK:STDOUT: %Self => constants.%Self
  126. // CHECK:STDOUT: %Self.binding.as_type => constants.%Self.binding.as_type
  127. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.7db
  128. // CHECK:STDOUT: }
  129. // CHECK:STDOUT:
  130. // CHECK:STDOUT: specific @I.G(constants.%I.facet) {
  131. // CHECK:STDOUT: %Self => constants.%I.facet
  132. // CHECK:STDOUT: %Self.binding.as_type => constants.%empty_tuple.type
  133. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.cb1
  134. // CHECK:STDOUT: }
  135. // CHECK:STDOUT: