member_lookup.carbon 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  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/int.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/member_lookup.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interface/member_lookup.carbon
  14. // --- member_access.carbon
  15. library "[[@TEST_NAME]]";
  16. interface Interface(T:! type) {
  17. let X:! T;
  18. }
  19. fn AccessGeneric[T:! type](I:! Interface(T)) -> T {
  20. return I.X;
  21. }
  22. fn AccessConcrete(I:! Interface(i32)) -> i32 {
  23. return I.X;
  24. }
  25. // --- fail_no_member.carbon
  26. library "[[@TEST_NAME]]";
  27. interface Interface(T:! type) {
  28. let X:! T;
  29. }
  30. fn AccessMissingGeneric[T:! type](I:! Interface(T)) -> T {
  31. // CHECK:STDERR: fail_no_member.carbon:[[@LINE+4]]:10: error: member name `nonesuch` not found in `Interface(T)` [MemberNameNotFoundInSpecificScope]
  32. // CHECK:STDERR: return I.nonesuch;
  33. // CHECK:STDERR: ^~~~~~~~~~
  34. // CHECK:STDERR:
  35. return I.nonesuch;
  36. }
  37. fn AccessMissingConcrete(I:! Interface(i32)) -> i32 {
  38. // CHECK:STDERR: fail_no_member.carbon:[[@LINE+4]]:10: error: member name `nonesuch` not found in `Interface(i32)` [MemberNameNotFoundInSpecificScope]
  39. // CHECK:STDERR: return I.nonesuch;
  40. // CHECK:STDERR: ^~~~~~~~~~
  41. // CHECK:STDERR:
  42. return I.nonesuch;
  43. }
  44. // CHECK:STDOUT: --- member_access.carbon
  45. // CHECK:STDOUT:
  46. // CHECK:STDOUT: constants {
  47. // CHECK:STDOUT: %type: type = facet_type <type> [concrete]
  48. // CHECK:STDOUT: %.Self: %type = bind_symbolic_name .Self [symbolic_self]
  49. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  50. // CHECK:STDOUT: %pattern_type.98f: type = pattern_type type [concrete]
  51. // CHECK:STDOUT: %Interface.type.e32: type = generic_interface_type @Interface [concrete]
  52. // CHECK:STDOUT: %Interface.generic: %Interface.type.e32 = struct_value () [concrete]
  53. // CHECK:STDOUT: %Interface.type.1a8: type = facet_type <@Interface, @Interface(%T)> [symbolic]
  54. // CHECK:STDOUT: %Self.c05: %Interface.type.1a8 = bind_symbolic_name Self, 1 [symbolic]
  55. // CHECK:STDOUT: %require_complete.4ae: <witness> = require_complete_type %T [symbolic]
  56. // CHECK:STDOUT: %Interface.assoc_type.0d9: type = assoc_entity_type @Interface, @Interface(%T) [symbolic]
  57. // CHECK:STDOUT: %assoc0.dbe: %Interface.assoc_type.0d9 = assoc_entity element0, @Interface.%X [symbolic]
  58. // CHECK:STDOUT: %I.c05: %Interface.type.1a8 = bind_symbolic_name I, 1 [symbolic]
  59. // CHECK:STDOUT: %pattern_type.eaa: type = pattern_type %Interface.type.1a8 [symbolic]
  60. // CHECK:STDOUT: %pattern_type.7dc: type = pattern_type %T [symbolic]
  61. // CHECK:STDOUT: %AccessGeneric.type: type = fn_type @AccessGeneric [concrete]
  62. // CHECK:STDOUT: %AccessGeneric: %AccessGeneric.type = struct_value () [concrete]
  63. // CHECK:STDOUT: %require_complete.376: <witness> = require_complete_type %Interface.type.1a8 [symbolic]
  64. // CHECK:STDOUT: %I.as_type.fe1: type = facet_access_type %I.c05 [symbolic]
  65. // CHECK:STDOUT: %Interface.lookup_impl_witness.301: <witness> = lookup_impl_witness %I.c05, @Interface, @Interface(%T) [symbolic]
  66. // CHECK:STDOUT: %Interface.facet.b19: %Interface.type.1a8 = facet_value %I.as_type.fe1, (%Interface.lookup_impl_witness.301) [symbolic]
  67. // CHECK:STDOUT: %impl.elem0.245: %T = impl_witness_access %Interface.lookup_impl_witness.301, element0 [symbolic]
  68. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  69. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  70. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  71. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  72. // CHECK:STDOUT: %Interface.type.bcd: type = facet_type <@Interface, @Interface(%i32)> [concrete]
  73. // CHECK:STDOUT: %I.910: %Interface.type.bcd = bind_symbolic_name I, 0 [symbolic]
  74. // CHECK:STDOUT: %pattern_type.1c1: type = pattern_type %Interface.type.bcd [concrete]
  75. // CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
  76. // CHECK:STDOUT: %AccessConcrete.type: type = fn_type @AccessConcrete [concrete]
  77. // CHECK:STDOUT: %AccessConcrete: %AccessConcrete.type = struct_value () [concrete]
  78. // CHECK:STDOUT: %i32.builtin: type = int_type signed, %int_32 [concrete]
  79. // CHECK:STDOUT: %complete_type.f8a: <witness> = complete_type_witness %i32.builtin [concrete]
  80. // CHECK:STDOUT: %Self.e75: %Interface.type.bcd = bind_symbolic_name Self, 1 [symbolic]
  81. // CHECK:STDOUT: %Interface.assoc_type.aaa: type = assoc_entity_type @Interface, @Interface(%i32) [concrete]
  82. // CHECK:STDOUT: %assoc0.69f: %Interface.assoc_type.aaa = assoc_entity element0, @Interface.%X [concrete]
  83. // CHECK:STDOUT: %I.as_type.85e: type = facet_access_type %I.910 [symbolic]
  84. // CHECK:STDOUT: %Interface.lookup_impl_witness.73f: <witness> = lookup_impl_witness %I.910, @Interface, @Interface(%i32) [symbolic]
  85. // CHECK:STDOUT: %Interface.facet.c5c: %Interface.type.bcd = facet_value %I.as_type.85e, (%Interface.lookup_impl_witness.73f) [symbolic]
  86. // CHECK:STDOUT: %impl.elem0.f4f: %i32 = impl_witness_access %Interface.lookup_impl_witness.73f, element0 [symbolic]
  87. // CHECK:STDOUT: }
  88. // CHECK:STDOUT:
  89. // CHECK:STDOUT: imports {
  90. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  91. // CHECK:STDOUT: .Int = %Core.Int
  92. // CHECK:STDOUT: import Core//prelude
  93. // CHECK:STDOUT: import Core//prelude/...
  94. // CHECK:STDOUT: }
  95. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/parts/int, Int, loaded [concrete = constants.%Int.generic]
  96. // CHECK:STDOUT: }
  97. // CHECK:STDOUT:
  98. // CHECK:STDOUT: file {
  99. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  100. // CHECK:STDOUT: .Core = imports.%Core
  101. // CHECK:STDOUT: .Interface = %Interface.decl
  102. // CHECK:STDOUT: .AccessGeneric = %AccessGeneric.decl
  103. // CHECK:STDOUT: .AccessConcrete = %AccessConcrete.decl
  104. // CHECK:STDOUT: }
  105. // CHECK:STDOUT: %Core.import = import Core
  106. // CHECK:STDOUT: %Interface.decl: %Interface.type.e32 = interface_decl @Interface [concrete = constants.%Interface.generic] {
  107. // CHECK:STDOUT: %T.patt: %pattern_type.98f = symbolic_binding_pattern T, 0 [concrete]
  108. // CHECK:STDOUT: } {
  109. // CHECK:STDOUT: %.Self: %type = bind_symbolic_name .Self [symbolic_self = constants.%.Self]
  110. // CHECK:STDOUT: %T.loc4_21.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc4_21.1 (constants.%T)]
  111. // CHECK:STDOUT: }
  112. // CHECK:STDOUT: %AccessGeneric.decl: %AccessGeneric.type = fn_decl @AccessGeneric [concrete = constants.%AccessGeneric] {
  113. // CHECK:STDOUT: %T.patt: %pattern_type.98f = symbolic_binding_pattern T, 0 [concrete]
  114. // CHECK:STDOUT: %I.patt: @AccessGeneric.%pattern_type.loc8_28 (%pattern_type.eaa) = symbolic_binding_pattern I, 1 [concrete]
  115. // CHECK:STDOUT: %return.patt: @AccessGeneric.%pattern_type.loc8_46 (%pattern_type.7dc) = return_slot_pattern [concrete]
  116. // CHECK:STDOUT: %return.param_patt: @AccessGeneric.%pattern_type.loc8_46 (%pattern_type.7dc) = out_param_pattern %return.patt, call_param0 [concrete]
  117. // CHECK:STDOUT: } {
  118. // CHECK:STDOUT: %T.ref.loc8_49: type = name_ref T, %T.loc8_18.2 [symbolic = %T.loc8_18.1 (constants.%T)]
  119. // CHECK:STDOUT: %.Self.1: %type = bind_symbolic_name .Self [symbolic_self = constants.%.Self]
  120. // CHECK:STDOUT: %T.loc8_18.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc8_18.1 (constants.%T)]
  121. // CHECK:STDOUT: %.loc8: type = splice_block %Interface.type.loc8_43.2 [symbolic = %Interface.type.loc8_43.1 (constants.%Interface.type.1a8)] {
  122. // CHECK:STDOUT: %.Self.2: %type = bind_symbolic_name .Self [symbolic_self = constants.%.Self]
  123. // CHECK:STDOUT: %Interface.ref: %Interface.type.e32 = name_ref Interface, file.%Interface.decl [concrete = constants.%Interface.generic]
  124. // CHECK:STDOUT: %T.ref.loc8_42: type = name_ref T, %T.loc8_18.2 [symbolic = %T.loc8_18.1 (constants.%T)]
  125. // CHECK:STDOUT: %Interface.type.loc8_43.2: type = facet_type <@Interface, @Interface(constants.%T)> [symbolic = %Interface.type.loc8_43.1 (constants.%Interface.type.1a8)]
  126. // CHECK:STDOUT: }
  127. // CHECK:STDOUT: %I.loc8_28.2: @AccessGeneric.%Interface.type.loc8_43.1 (%Interface.type.1a8) = bind_symbolic_name I, 1 [symbolic = %I.loc8_28.1 (constants.%I.c05)]
  128. // CHECK:STDOUT: %return.param: ref @AccessGeneric.%T.loc8_18.1 (%T) = out_param call_param0
  129. // CHECK:STDOUT: %return: ref @AccessGeneric.%T.loc8_18.1 (%T) = return_slot %return.param
  130. // CHECK:STDOUT: }
  131. // CHECK:STDOUT: %AccessConcrete.decl: %AccessConcrete.type = fn_decl @AccessConcrete [concrete = constants.%AccessConcrete] {
  132. // CHECK:STDOUT: %I.patt: %pattern_type.1c1 = symbolic_binding_pattern I, 0 [concrete]
  133. // CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern [concrete]
  134. // CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern %return.patt, call_param0 [concrete]
  135. // CHECK:STDOUT: } {
  136. // CHECK:STDOUT: %int_32.loc12_42: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  137. // CHECK:STDOUT: %i32.loc12_42: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  138. // CHECK:STDOUT: %.loc12: type = splice_block %Interface.type [concrete = constants.%Interface.type.bcd] {
  139. // CHECK:STDOUT: %.Self: %type = bind_symbolic_name .Self [symbolic_self = constants.%.Self]
  140. // CHECK:STDOUT: %Interface.ref: %Interface.type.e32 = name_ref Interface, file.%Interface.decl [concrete = constants.%Interface.generic]
  141. // CHECK:STDOUT: %int_32.loc12_33: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  142. // CHECK:STDOUT: %i32.loc12_33: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  143. // CHECK:STDOUT: %Interface.type: type = facet_type <@Interface, @Interface(constants.%i32)> [concrete = constants.%Interface.type.bcd]
  144. // CHECK:STDOUT: }
  145. // CHECK:STDOUT: %I.loc12_19.2: %Interface.type.bcd = bind_symbolic_name I, 0 [symbolic = %I.loc12_19.1 (constants.%I.910)]
  146. // CHECK:STDOUT: %return.param: ref %i32 = out_param call_param0
  147. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  148. // CHECK:STDOUT: }
  149. // CHECK:STDOUT: }
  150. // CHECK:STDOUT:
  151. // CHECK:STDOUT: generic interface @Interface(%T.loc4_21.2: type) {
  152. // CHECK:STDOUT: %T.loc4_21.1: type = bind_symbolic_name T, 0 [symbolic = %T.loc4_21.1 (constants.%T)]
  153. // CHECK:STDOUT:
  154. // CHECK:STDOUT: !definition:
  155. // CHECK:STDOUT: %Interface.type: type = facet_type <@Interface, @Interface(%T.loc4_21.1)> [symbolic = %Interface.type (constants.%Interface.type.1a8)]
  156. // CHECK:STDOUT: %Self.2: @Interface.%Interface.type (%Interface.type.1a8) = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self.c05)]
  157. // CHECK:STDOUT: %Interface.assoc_type: type = assoc_entity_type @Interface, @Interface(%T.loc4_21.1) [symbolic = %Interface.assoc_type (constants.%Interface.assoc_type.0d9)]
  158. // CHECK:STDOUT: %assoc0: @Interface.%Interface.assoc_type (%Interface.assoc_type.0d9) = assoc_entity element0, %X [symbolic = %assoc0 (constants.%assoc0.dbe)]
  159. // CHECK:STDOUT:
  160. // CHECK:STDOUT: interface {
  161. // CHECK:STDOUT: %Self.1: @Interface.%Interface.type (%Interface.type.1a8) = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self.c05)]
  162. // CHECK:STDOUT: %X: @X.%T (%T) = assoc_const_decl @X [concrete] {
  163. // CHECK:STDOUT: %assoc0: @Interface.%Interface.assoc_type (%Interface.assoc_type.0d9) = assoc_entity element0, @Interface.%X [symbolic = @Interface.%assoc0 (constants.%assoc0.dbe)]
  164. // CHECK:STDOUT: }
  165. // CHECK:STDOUT:
  166. // CHECK:STDOUT: !members:
  167. // CHECK:STDOUT: .Self = %Self.1
  168. // CHECK:STDOUT: .T = <poisoned>
  169. // CHECK:STDOUT: .X = @X.%assoc0
  170. // CHECK:STDOUT: witness = (%X)
  171. // CHECK:STDOUT: }
  172. // CHECK:STDOUT: }
  173. // CHECK:STDOUT:
  174. // CHECK:STDOUT: generic assoc_const @X(@Interface.%T.loc4_21.2: type, @Interface.%Self.1: @Interface.%Interface.type (%Interface.type.1a8)) {
  175. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T)]
  176. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type %T [symbolic = %require_complete (constants.%require_complete.4ae)]
  177. // CHECK:STDOUT:
  178. // CHECK:STDOUT: assoc_const X:! @X.%T (%T);
  179. // CHECK:STDOUT: }
  180. // CHECK:STDOUT:
  181. // CHECK:STDOUT: generic fn @AccessGeneric(%T.loc8_18.2: type, %I.loc8_28.2: @AccessGeneric.%Interface.type.loc8_43.1 (%Interface.type.1a8)) {
  182. // CHECK:STDOUT: %T.loc8_18.1: type = bind_symbolic_name T, 0 [symbolic = %T.loc8_18.1 (constants.%T)]
  183. // CHECK:STDOUT: %Interface.type.loc8_43.1: type = facet_type <@Interface, @Interface(%T.loc8_18.1)> [symbolic = %Interface.type.loc8_43.1 (constants.%Interface.type.1a8)]
  184. // CHECK:STDOUT: %I.loc8_28.1: @AccessGeneric.%Interface.type.loc8_43.1 (%Interface.type.1a8) = bind_symbolic_name I, 1 [symbolic = %I.loc8_28.1 (constants.%I.c05)]
  185. // CHECK:STDOUT: %pattern_type.loc8_28: type = pattern_type %Interface.type.loc8_43.1 [symbolic = %pattern_type.loc8_28 (constants.%pattern_type.eaa)]
  186. // CHECK:STDOUT: %pattern_type.loc8_46: type = pattern_type %T.loc8_18.1 [symbolic = %pattern_type.loc8_46 (constants.%pattern_type.7dc)]
  187. // CHECK:STDOUT:
  188. // CHECK:STDOUT: !definition:
  189. // CHECK:STDOUT: %require_complete.loc9_10: <witness> = require_complete_type %Interface.type.loc8_43.1 [symbolic = %require_complete.loc9_10 (constants.%require_complete.376)]
  190. // CHECK:STDOUT: %Interface.assoc_type: type = assoc_entity_type @Interface, @Interface(%T.loc8_18.1) [symbolic = %Interface.assoc_type (constants.%Interface.assoc_type.0d9)]
  191. // CHECK:STDOUT: %assoc0: @AccessGeneric.%Interface.assoc_type (%Interface.assoc_type.0d9) = assoc_entity element0, @Interface.%X [symbolic = %assoc0 (constants.%assoc0.dbe)]
  192. // CHECK:STDOUT: %I.as_type.loc9_11.2: type = facet_access_type %I.loc8_28.1 [symbolic = %I.as_type.loc9_11.2 (constants.%I.as_type.fe1)]
  193. // CHECK:STDOUT: %Interface.lookup_impl_witness: <witness> = lookup_impl_witness %I.loc8_28.1, @Interface, @Interface(%T.loc8_18.1) [symbolic = %Interface.lookup_impl_witness (constants.%Interface.lookup_impl_witness.301)]
  194. // CHECK:STDOUT: %impl.elem0.loc9_11.2: @AccessGeneric.%T.loc8_18.1 (%T) = impl_witness_access %Interface.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc9_11.2 (constants.%impl.elem0.245)]
  195. // CHECK:STDOUT: %require_complete.loc9_13: <witness> = require_complete_type %T.loc8_18.1 [symbolic = %require_complete.loc9_13 (constants.%require_complete.4ae)]
  196. // CHECK:STDOUT:
  197. // CHECK:STDOUT: fn() -> @AccessGeneric.%T.loc8_18.1 (%T) {
  198. // CHECK:STDOUT: !entry:
  199. // CHECK:STDOUT: %I.ref: @AccessGeneric.%Interface.type.loc8_43.1 (%Interface.type.1a8) = name_ref I, %I.loc8_28.2 [symbolic = %I.loc8_28.1 (constants.%I.c05)]
  200. // CHECK:STDOUT: %.loc9_11.1: @AccessGeneric.%Interface.assoc_type (%Interface.assoc_type.0d9) = specific_constant @X.%assoc0, @Interface(constants.%T) [symbolic = %assoc0 (constants.%assoc0.dbe)]
  201. // CHECK:STDOUT: %X.ref: @AccessGeneric.%Interface.assoc_type (%Interface.assoc_type.0d9) = name_ref X, %.loc9_11.1 [symbolic = %assoc0 (constants.%assoc0.dbe)]
  202. // CHECK:STDOUT: %I.as_type.loc9_11.1: type = facet_access_type %I.ref [symbolic = %I.as_type.loc9_11.2 (constants.%I.as_type.fe1)]
  203. // CHECK:STDOUT: %.loc9_11.2: type = converted %I.ref, %I.as_type.loc9_11.1 [symbolic = %I.as_type.loc9_11.2 (constants.%I.as_type.fe1)]
  204. // CHECK:STDOUT: %impl.elem0.loc9_11.1: @AccessGeneric.%T.loc8_18.1 (%T) = impl_witness_access constants.%Interface.lookup_impl_witness.301, element0 [symbolic = %impl.elem0.loc9_11.2 (constants.%impl.elem0.245)]
  205. // CHECK:STDOUT: return %impl.elem0.loc9_11.1
  206. // CHECK:STDOUT: }
  207. // CHECK:STDOUT: }
  208. // CHECK:STDOUT:
  209. // CHECK:STDOUT: generic fn @AccessConcrete(%I.loc12_19.2: %Interface.type.bcd) {
  210. // CHECK:STDOUT: %I.loc12_19.1: %Interface.type.bcd = bind_symbolic_name I, 0 [symbolic = %I.loc12_19.1 (constants.%I.910)]
  211. // CHECK:STDOUT:
  212. // CHECK:STDOUT: !definition:
  213. // CHECK:STDOUT: %I.as_type.loc13_11.2: type = facet_access_type %I.loc12_19.1 [symbolic = %I.as_type.loc13_11.2 (constants.%I.as_type.85e)]
  214. // CHECK:STDOUT: %Interface.lookup_impl_witness: <witness> = lookup_impl_witness %I.loc12_19.1, @Interface, @Interface(constants.%i32) [symbolic = %Interface.lookup_impl_witness (constants.%Interface.lookup_impl_witness.73f)]
  215. // CHECK:STDOUT: %impl.elem0.loc13_11.2: %i32 = impl_witness_access %Interface.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc13_11.2 (constants.%impl.elem0.f4f)]
  216. // CHECK:STDOUT:
  217. // CHECK:STDOUT: fn() -> %i32 {
  218. // CHECK:STDOUT: !entry:
  219. // CHECK:STDOUT: %I.ref: %Interface.type.bcd = name_ref I, %I.loc12_19.2 [symbolic = %I.loc12_19.1 (constants.%I.910)]
  220. // CHECK:STDOUT: %.loc13_11.1: %Interface.assoc_type.aaa = specific_constant @X.%assoc0, @Interface(constants.%i32) [concrete = constants.%assoc0.69f]
  221. // CHECK:STDOUT: %X.ref: %Interface.assoc_type.aaa = name_ref X, %.loc13_11.1 [concrete = constants.%assoc0.69f]
  222. // CHECK:STDOUT: %I.as_type.loc13_11.1: type = facet_access_type %I.ref [symbolic = %I.as_type.loc13_11.2 (constants.%I.as_type.85e)]
  223. // CHECK:STDOUT: %.loc13_11.2: type = converted %I.ref, %I.as_type.loc13_11.1 [symbolic = %I.as_type.loc13_11.2 (constants.%I.as_type.85e)]
  224. // CHECK:STDOUT: %impl.elem0.loc13_11.1: %i32 = impl_witness_access constants.%Interface.lookup_impl_witness.73f, element0 [symbolic = %impl.elem0.loc13_11.2 (constants.%impl.elem0.f4f)]
  225. // CHECK:STDOUT: return %impl.elem0.loc13_11.1
  226. // CHECK:STDOUT: }
  227. // CHECK:STDOUT: }
  228. // CHECK:STDOUT:
  229. // CHECK:STDOUT: specific @Interface(constants.%T) {
  230. // CHECK:STDOUT: %T.loc4_21.1 => constants.%T
  231. // CHECK:STDOUT:
  232. // CHECK:STDOUT: !definition:
  233. // CHECK:STDOUT: %Interface.type => constants.%Interface.type.1a8
  234. // CHECK:STDOUT: %Self.2 => constants.%Self.c05
  235. // CHECK:STDOUT: %Interface.assoc_type => constants.%Interface.assoc_type.0d9
  236. // CHECK:STDOUT: %assoc0 => constants.%assoc0.dbe
  237. // CHECK:STDOUT: }
  238. // CHECK:STDOUT:
  239. // CHECK:STDOUT: specific @X(constants.%T, constants.%Self.c05) {
  240. // CHECK:STDOUT: %T => constants.%T
  241. // CHECK:STDOUT: %require_complete => constants.%require_complete.4ae
  242. // CHECK:STDOUT: }
  243. // CHECK:STDOUT:
  244. // CHECK:STDOUT: specific @AccessGeneric(constants.%T, constants.%I.c05) {
  245. // CHECK:STDOUT: %T.loc8_18.1 => constants.%T
  246. // CHECK:STDOUT: %Interface.type.loc8_43.1 => constants.%Interface.type.1a8
  247. // CHECK:STDOUT: %I.loc8_28.1 => constants.%I.c05
  248. // CHECK:STDOUT: %pattern_type.loc8_28 => constants.%pattern_type.eaa
  249. // CHECK:STDOUT: %pattern_type.loc8_46 => constants.%pattern_type.7dc
  250. // CHECK:STDOUT: }
  251. // CHECK:STDOUT:
  252. // CHECK:STDOUT: specific @X(constants.%T, constants.%Interface.facet.b19) {
  253. // CHECK:STDOUT: %T => constants.%T
  254. // CHECK:STDOUT: %require_complete => constants.%require_complete.4ae
  255. // CHECK:STDOUT: }
  256. // CHECK:STDOUT:
  257. // CHECK:STDOUT: specific @Interface(constants.%i32) {
  258. // CHECK:STDOUT: %T.loc4_21.1 => constants.%i32
  259. // CHECK:STDOUT:
  260. // CHECK:STDOUT: !definition:
  261. // CHECK:STDOUT: %Interface.type => constants.%Interface.type.bcd
  262. // CHECK:STDOUT: %Self.2 => constants.%Self.e75
  263. // CHECK:STDOUT: %Interface.assoc_type => constants.%Interface.assoc_type.aaa
  264. // CHECK:STDOUT: %assoc0 => constants.%assoc0.69f
  265. // CHECK:STDOUT: }
  266. // CHECK:STDOUT:
  267. // CHECK:STDOUT: specific @AccessConcrete(constants.%I.910) {
  268. // CHECK:STDOUT: %I.loc12_19.1 => constants.%I.910
  269. // CHECK:STDOUT: }
  270. // CHECK:STDOUT:
  271. // CHECK:STDOUT: specific @X(constants.%i32, constants.%Interface.facet.c5c) {
  272. // CHECK:STDOUT: %T => constants.%i32
  273. // CHECK:STDOUT: %require_complete => constants.%complete_type.f8a
  274. // CHECK:STDOUT: }
  275. // CHECK:STDOUT:
  276. // CHECK:STDOUT: --- fail_no_member.carbon
  277. // CHECK:STDOUT:
  278. // CHECK:STDOUT: constants {
  279. // CHECK:STDOUT: %type: type = facet_type <type> [concrete]
  280. // CHECK:STDOUT: %.Self: %type = bind_symbolic_name .Self [symbolic_self]
  281. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  282. // CHECK:STDOUT: %pattern_type.98f: type = pattern_type type [concrete]
  283. // CHECK:STDOUT: %Interface.type.e32: type = generic_interface_type @Interface [concrete]
  284. // CHECK:STDOUT: %Interface.generic: %Interface.type.e32 = struct_value () [concrete]
  285. // CHECK:STDOUT: %Interface.type.1a8: type = facet_type <@Interface, @Interface(%T)> [symbolic]
  286. // CHECK:STDOUT: %Self.c05: %Interface.type.1a8 = bind_symbolic_name Self, 1 [symbolic]
  287. // CHECK:STDOUT: %require_complete.4ae: <witness> = require_complete_type %T [symbolic]
  288. // CHECK:STDOUT: %Interface.assoc_type.0d9: type = assoc_entity_type @Interface, @Interface(%T) [symbolic]
  289. // CHECK:STDOUT: %assoc0.dbe: %Interface.assoc_type.0d9 = assoc_entity element0, @Interface.%X [symbolic]
  290. // CHECK:STDOUT: %I.c05: %Interface.type.1a8 = bind_symbolic_name I, 1 [symbolic]
  291. // CHECK:STDOUT: %pattern_type.eaa: type = pattern_type %Interface.type.1a8 [symbolic]
  292. // CHECK:STDOUT: %pattern_type.7dc: type = pattern_type %T [symbolic]
  293. // CHECK:STDOUT: %AccessMissingGeneric.type: type = fn_type @AccessMissingGeneric [concrete]
  294. // CHECK:STDOUT: %AccessMissingGeneric: %AccessMissingGeneric.type = struct_value () [concrete]
  295. // CHECK:STDOUT: %require_complete.376: <witness> = require_complete_type %Interface.type.1a8 [symbolic]
  296. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  297. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  298. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  299. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  300. // CHECK:STDOUT: %Interface.type.bcd: type = facet_type <@Interface, @Interface(%i32)> [concrete]
  301. // CHECK:STDOUT: %I.910: %Interface.type.bcd = bind_symbolic_name I, 0 [symbolic]
  302. // CHECK:STDOUT: %pattern_type.1c1: type = pattern_type %Interface.type.bcd [concrete]
  303. // CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
  304. // CHECK:STDOUT: %AccessMissingConcrete.type: type = fn_type @AccessMissingConcrete [concrete]
  305. // CHECK:STDOUT: %AccessMissingConcrete: %AccessMissingConcrete.type = struct_value () [concrete]
  306. // CHECK:STDOUT: %Self.e75: %Interface.type.bcd = bind_symbolic_name Self, 1 [symbolic]
  307. // CHECK:STDOUT: %Interface.assoc_type.aaa: type = assoc_entity_type @Interface, @Interface(%i32) [concrete]
  308. // CHECK:STDOUT: %assoc0.69f: %Interface.assoc_type.aaa = assoc_entity element0, @Interface.%X [concrete]
  309. // CHECK:STDOUT: }
  310. // CHECK:STDOUT:
  311. // CHECK:STDOUT: imports {
  312. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  313. // CHECK:STDOUT: .Int = %Core.Int
  314. // CHECK:STDOUT: import Core//prelude
  315. // CHECK:STDOUT: import Core//prelude/...
  316. // CHECK:STDOUT: }
  317. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/parts/int, Int, loaded [concrete = constants.%Int.generic]
  318. // CHECK:STDOUT: }
  319. // CHECK:STDOUT:
  320. // CHECK:STDOUT: file {
  321. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  322. // CHECK:STDOUT: .Core = imports.%Core
  323. // CHECK:STDOUT: .Interface = %Interface.decl
  324. // CHECK:STDOUT: .AccessMissingGeneric = %AccessMissingGeneric.decl
  325. // CHECK:STDOUT: .AccessMissingConcrete = %AccessMissingConcrete.decl
  326. // CHECK:STDOUT: }
  327. // CHECK:STDOUT: %Core.import = import Core
  328. // CHECK:STDOUT: %Interface.decl: %Interface.type.e32 = interface_decl @Interface [concrete = constants.%Interface.generic] {
  329. // CHECK:STDOUT: %T.patt: %pattern_type.98f = symbolic_binding_pattern T, 0 [concrete]
  330. // CHECK:STDOUT: } {
  331. // CHECK:STDOUT: %.Self: %type = bind_symbolic_name .Self [symbolic_self = constants.%.Self]
  332. // CHECK:STDOUT: %T.loc4_21.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc4_21.1 (constants.%T)]
  333. // CHECK:STDOUT: }
  334. // CHECK:STDOUT: %AccessMissingGeneric.decl: %AccessMissingGeneric.type = fn_decl @AccessMissingGeneric [concrete = constants.%AccessMissingGeneric] {
  335. // CHECK:STDOUT: %T.patt: %pattern_type.98f = symbolic_binding_pattern T, 0 [concrete]
  336. // CHECK:STDOUT: %I.patt: @AccessMissingGeneric.%pattern_type.loc8_35 (%pattern_type.eaa) = symbolic_binding_pattern I, 1 [concrete]
  337. // CHECK:STDOUT: %return.patt: @AccessMissingGeneric.%pattern_type.loc8_53 (%pattern_type.7dc) = return_slot_pattern [concrete]
  338. // CHECK:STDOUT: %return.param_patt: @AccessMissingGeneric.%pattern_type.loc8_53 (%pattern_type.7dc) = out_param_pattern %return.patt, call_param0 [concrete]
  339. // CHECK:STDOUT: } {
  340. // CHECK:STDOUT: %T.ref.loc8_56: type = name_ref T, %T.loc8_25.2 [symbolic = %T.loc8_25.1 (constants.%T)]
  341. // CHECK:STDOUT: %.Self.1: %type = bind_symbolic_name .Self [symbolic_self = constants.%.Self]
  342. // CHECK:STDOUT: %T.loc8_25.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc8_25.1 (constants.%T)]
  343. // CHECK:STDOUT: %.loc8: type = splice_block %Interface.type.loc8_50.2 [symbolic = %Interface.type.loc8_50.1 (constants.%Interface.type.1a8)] {
  344. // CHECK:STDOUT: %.Self.2: %type = bind_symbolic_name .Self [symbolic_self = constants.%.Self]
  345. // CHECK:STDOUT: %Interface.ref: %Interface.type.e32 = name_ref Interface, file.%Interface.decl [concrete = constants.%Interface.generic]
  346. // CHECK:STDOUT: %T.ref.loc8_49: type = name_ref T, %T.loc8_25.2 [symbolic = %T.loc8_25.1 (constants.%T)]
  347. // CHECK:STDOUT: %Interface.type.loc8_50.2: type = facet_type <@Interface, @Interface(constants.%T)> [symbolic = %Interface.type.loc8_50.1 (constants.%Interface.type.1a8)]
  348. // CHECK:STDOUT: }
  349. // CHECK:STDOUT: %I.loc8_35.2: @AccessMissingGeneric.%Interface.type.loc8_50.1 (%Interface.type.1a8) = bind_symbolic_name I, 1 [symbolic = %I.loc8_35.1 (constants.%I.c05)]
  350. // CHECK:STDOUT: %return.param: ref @AccessMissingGeneric.%T.loc8_25.1 (%T) = out_param call_param0
  351. // CHECK:STDOUT: %return: ref @AccessMissingGeneric.%T.loc8_25.1 (%T) = return_slot %return.param
  352. // CHECK:STDOUT: }
  353. // CHECK:STDOUT: %AccessMissingConcrete.decl: %AccessMissingConcrete.type = fn_decl @AccessMissingConcrete [concrete = constants.%AccessMissingConcrete] {
  354. // CHECK:STDOUT: %I.patt: %pattern_type.1c1 = symbolic_binding_pattern I, 0 [concrete]
  355. // CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern [concrete]
  356. // CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern %return.patt, call_param0 [concrete]
  357. // CHECK:STDOUT: } {
  358. // CHECK:STDOUT: %int_32.loc16_49: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  359. // CHECK:STDOUT: %i32.loc16_49: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  360. // CHECK:STDOUT: %.loc16: type = splice_block %Interface.type [concrete = constants.%Interface.type.bcd] {
  361. // CHECK:STDOUT: %.Self: %type = bind_symbolic_name .Self [symbolic_self = constants.%.Self]
  362. // CHECK:STDOUT: %Interface.ref: %Interface.type.e32 = name_ref Interface, file.%Interface.decl [concrete = constants.%Interface.generic]
  363. // CHECK:STDOUT: %int_32.loc16_40: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  364. // CHECK:STDOUT: %i32.loc16_40: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  365. // CHECK:STDOUT: %Interface.type: type = facet_type <@Interface, @Interface(constants.%i32)> [concrete = constants.%Interface.type.bcd]
  366. // CHECK:STDOUT: }
  367. // CHECK:STDOUT: %I.loc16_26.2: %Interface.type.bcd = bind_symbolic_name I, 0 [symbolic = %I.loc16_26.1 (constants.%I.910)]
  368. // CHECK:STDOUT: %return.param: ref %i32 = out_param call_param0
  369. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  370. // CHECK:STDOUT: }
  371. // CHECK:STDOUT: }
  372. // CHECK:STDOUT:
  373. // CHECK:STDOUT: generic interface @Interface(%T.loc4_21.2: type) {
  374. // CHECK:STDOUT: %T.loc4_21.1: type = bind_symbolic_name T, 0 [symbolic = %T.loc4_21.1 (constants.%T)]
  375. // CHECK:STDOUT:
  376. // CHECK:STDOUT: !definition:
  377. // CHECK:STDOUT: %Interface.type: type = facet_type <@Interface, @Interface(%T.loc4_21.1)> [symbolic = %Interface.type (constants.%Interface.type.1a8)]
  378. // CHECK:STDOUT: %Self.2: @Interface.%Interface.type (%Interface.type.1a8) = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self.c05)]
  379. // CHECK:STDOUT: %Interface.assoc_type: type = assoc_entity_type @Interface, @Interface(%T.loc4_21.1) [symbolic = %Interface.assoc_type (constants.%Interface.assoc_type.0d9)]
  380. // CHECK:STDOUT: %assoc0: @Interface.%Interface.assoc_type (%Interface.assoc_type.0d9) = assoc_entity element0, %X [symbolic = %assoc0 (constants.%assoc0.dbe)]
  381. // CHECK:STDOUT:
  382. // CHECK:STDOUT: interface {
  383. // CHECK:STDOUT: %Self.1: @Interface.%Interface.type (%Interface.type.1a8) = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self.c05)]
  384. // CHECK:STDOUT: %X: @X.%T (%T) = assoc_const_decl @X [concrete] {
  385. // CHECK:STDOUT: %assoc0: @Interface.%Interface.assoc_type (%Interface.assoc_type.0d9) = assoc_entity element0, @Interface.%X [symbolic = @Interface.%assoc0 (constants.%assoc0.dbe)]
  386. // CHECK:STDOUT: }
  387. // CHECK:STDOUT:
  388. // CHECK:STDOUT: !members:
  389. // CHECK:STDOUT: .Self = %Self.1
  390. // CHECK:STDOUT: .T = <poisoned>
  391. // CHECK:STDOUT: .X = @X.%assoc0
  392. // CHECK:STDOUT: .nonesuch = <poisoned>
  393. // CHECK:STDOUT: witness = (%X)
  394. // CHECK:STDOUT: }
  395. // CHECK:STDOUT: }
  396. // CHECK:STDOUT:
  397. // CHECK:STDOUT: generic assoc_const @X(@Interface.%T.loc4_21.2: type, @Interface.%Self.1: @Interface.%Interface.type (%Interface.type.1a8)) {
  398. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T)]
  399. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type %T [symbolic = %require_complete (constants.%require_complete.4ae)]
  400. // CHECK:STDOUT:
  401. // CHECK:STDOUT: assoc_const X:! @X.%T (%T);
  402. // CHECK:STDOUT: }
  403. // CHECK:STDOUT:
  404. // CHECK:STDOUT: generic fn @AccessMissingGeneric(%T.loc8_25.2: type, %I.loc8_35.2: @AccessMissingGeneric.%Interface.type.loc8_50.1 (%Interface.type.1a8)) {
  405. // CHECK:STDOUT: %T.loc8_25.1: type = bind_symbolic_name T, 0 [symbolic = %T.loc8_25.1 (constants.%T)]
  406. // CHECK:STDOUT: %Interface.type.loc8_50.1: type = facet_type <@Interface, @Interface(%T.loc8_25.1)> [symbolic = %Interface.type.loc8_50.1 (constants.%Interface.type.1a8)]
  407. // CHECK:STDOUT: %I.loc8_35.1: @AccessMissingGeneric.%Interface.type.loc8_50.1 (%Interface.type.1a8) = bind_symbolic_name I, 1 [symbolic = %I.loc8_35.1 (constants.%I.c05)]
  408. // CHECK:STDOUT: %pattern_type.loc8_35: type = pattern_type %Interface.type.loc8_50.1 [symbolic = %pattern_type.loc8_35 (constants.%pattern_type.eaa)]
  409. // CHECK:STDOUT: %pattern_type.loc8_53: type = pattern_type %T.loc8_25.1 [symbolic = %pattern_type.loc8_53 (constants.%pattern_type.7dc)]
  410. // CHECK:STDOUT:
  411. // CHECK:STDOUT: !definition:
  412. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type %Interface.type.loc8_50.1 [symbolic = %require_complete (constants.%require_complete.376)]
  413. // CHECK:STDOUT:
  414. // CHECK:STDOUT: fn() -> @AccessMissingGeneric.%T.loc8_25.1 (%T) {
  415. // CHECK:STDOUT: !entry:
  416. // CHECK:STDOUT: %I.ref: @AccessMissingGeneric.%Interface.type.loc8_50.1 (%Interface.type.1a8) = name_ref I, %I.loc8_35.2 [symbolic = %I.loc8_35.1 (constants.%I.c05)]
  417. // CHECK:STDOUT: %nonesuch.ref: <error> = name_ref nonesuch, <error> [concrete = <error>]
  418. // CHECK:STDOUT: return <error>
  419. // CHECK:STDOUT: }
  420. // CHECK:STDOUT: }
  421. // CHECK:STDOUT:
  422. // CHECK:STDOUT: generic fn @AccessMissingConcrete(%I.loc16_26.2: %Interface.type.bcd) {
  423. // CHECK:STDOUT: %I.loc16_26.1: %Interface.type.bcd = bind_symbolic_name I, 0 [symbolic = %I.loc16_26.1 (constants.%I.910)]
  424. // CHECK:STDOUT:
  425. // CHECK:STDOUT: !definition:
  426. // CHECK:STDOUT:
  427. // CHECK:STDOUT: fn() -> %i32 {
  428. // CHECK:STDOUT: !entry:
  429. // CHECK:STDOUT: %I.ref: %Interface.type.bcd = name_ref I, %I.loc16_26.2 [symbolic = %I.loc16_26.1 (constants.%I.910)]
  430. // CHECK:STDOUT: %nonesuch.ref: <error> = name_ref nonesuch, <error> [concrete = <error>]
  431. // CHECK:STDOUT: return <error>
  432. // CHECK:STDOUT: }
  433. // CHECK:STDOUT: }
  434. // CHECK:STDOUT:
  435. // CHECK:STDOUT: specific @Interface(constants.%T) {
  436. // CHECK:STDOUT: %T.loc4_21.1 => constants.%T
  437. // CHECK:STDOUT:
  438. // CHECK:STDOUT: !definition:
  439. // CHECK:STDOUT: %Interface.type => constants.%Interface.type.1a8
  440. // CHECK:STDOUT: %Self.2 => constants.%Self.c05
  441. // CHECK:STDOUT: %Interface.assoc_type => constants.%Interface.assoc_type.0d9
  442. // CHECK:STDOUT: %assoc0 => constants.%assoc0.dbe
  443. // CHECK:STDOUT: }
  444. // CHECK:STDOUT:
  445. // CHECK:STDOUT: specific @X(constants.%T, constants.%Self.c05) {
  446. // CHECK:STDOUT: %T => constants.%T
  447. // CHECK:STDOUT: %require_complete => constants.%require_complete.4ae
  448. // CHECK:STDOUT: }
  449. // CHECK:STDOUT:
  450. // CHECK:STDOUT: specific @AccessMissingGeneric(constants.%T, constants.%I.c05) {
  451. // CHECK:STDOUT: %T.loc8_25.1 => constants.%T
  452. // CHECK:STDOUT: %Interface.type.loc8_50.1 => constants.%Interface.type.1a8
  453. // CHECK:STDOUT: %I.loc8_35.1 => constants.%I.c05
  454. // CHECK:STDOUT: %pattern_type.loc8_35 => constants.%pattern_type.eaa
  455. // CHECK:STDOUT: %pattern_type.loc8_53 => constants.%pattern_type.7dc
  456. // CHECK:STDOUT: }
  457. // CHECK:STDOUT:
  458. // CHECK:STDOUT: specific @Interface(constants.%i32) {
  459. // CHECK:STDOUT: %T.loc4_21.1 => constants.%i32
  460. // CHECK:STDOUT:
  461. // CHECK:STDOUT: !definition:
  462. // CHECK:STDOUT: %Interface.type => constants.%Interface.type.bcd
  463. // CHECK:STDOUT: %Self.2 => constants.%Self.e75
  464. // CHECK:STDOUT: %Interface.assoc_type => constants.%Interface.assoc_type.aaa
  465. // CHECK:STDOUT: %assoc0 => constants.%assoc0.69f
  466. // CHECK:STDOUT: }
  467. // CHECK:STDOUT:
  468. // CHECK:STDOUT: specific @AccessMissingConcrete(constants.%I.910) {
  469. // CHECK:STDOUT: %I.loc16_26.1 => constants.%I.910
  470. // CHECK:STDOUT: }
  471. // CHECK:STDOUT: