member_lookup.carbon 32 KB

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