member_access.carbon 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696
  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/generic/template/member_access.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/generic/template/member_access.carbon
  14. // --- member_access.carbon
  15. library "[[@TEST_NAME]]";
  16. fn F[template T:! type](x: T) -> i32 {
  17. return x.n;
  18. }
  19. class C {
  20. var n: i32;
  21. }
  22. fn Test1(c: C) {
  23. F(c);
  24. }
  25. fn Test2(x: {.m: i32, .n: i32}) {
  26. F(x);
  27. }
  28. // --- fail_no_such_member.carbon
  29. library "[[@TEST_NAME]]";
  30. fn F[template T:! type](x: T) -> i32 {
  31. // CHECK:STDERR: fail_no_such_member.carbon:[[@LINE+3]]:10: error: member name `n` not found in `D` [MemberNameNotFoundInInstScope]
  32. // CHECK:STDERR: return x.n;
  33. // CHECK:STDERR: ^~~
  34. return x.n;
  35. }
  36. class D {
  37. var m: i32;
  38. }
  39. fn Test(d: D) {
  40. // CHECK:STDERR: fail_no_such_member.carbon:[[@LINE+4]]:3: note: in `F(D)` used here [ResolvingSpecificHere]
  41. // CHECK:STDERR: F(d);
  42. // CHECK:STDERR: ^
  43. // CHECK:STDERR:
  44. F(d);
  45. }
  46. // --- fail_member_wrong_type.carbon
  47. library "[[@TEST_NAME]]";
  48. fn F[template T:! type](x: T) -> i32 {
  49. // CHECK:STDERR: fail_member_wrong_type.carbon:[[@LINE+6]]:3: error: cannot implicitly convert expression of type `F` to `i32` [ConversionFailure]
  50. // CHECK:STDERR: return x.n;
  51. // CHECK:STDERR: ^~~~~~~~~~~
  52. // CHECK:STDERR: fail_member_wrong_type.carbon:[[@LINE+3]]:3: note: type `F` does not implement interface `Core.ImplicitAs(i32)` [MissingImplInMemberAccessNote]
  53. // CHECK:STDERR: return x.n;
  54. // CHECK:STDERR: ^~~~~~~~~~~
  55. return x.n;
  56. }
  57. class E {
  58. class F {}
  59. var n: F;
  60. }
  61. fn Test(e: E) {
  62. // CHECK:STDERR: fail_member_wrong_type.carbon:[[@LINE+4]]:3: note: in `F(E)` used here [ResolvingSpecificHere]
  63. // CHECK:STDERR: F(e);
  64. // CHECK:STDERR: ^
  65. // CHECK:STDERR:
  66. F(e);
  67. }
  68. // CHECK:STDOUT: --- member_access.carbon
  69. // CHECK:STDOUT:
  70. // CHECK:STDOUT: constants {
  71. // CHECK:STDOUT: %.Self: type = bind_symbolic_name .Self [symbolic_self]
  72. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0, template [template]
  73. // CHECK:STDOUT: %pattern_type.98f: type = pattern_type type [concrete]
  74. // CHECK:STDOUT: %pattern_type.7dc: type = pattern_type %T [template]
  75. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  76. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  77. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  78. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  79. // CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
  80. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  81. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  82. // CHECK:STDOUT: %require_complete.4ae: <witness> = require_complete_type %T [template]
  83. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  84. // CHECK:STDOUT: %C.elem: type = unbound_element_type %C, %i32 [concrete]
  85. // CHECK:STDOUT: %Destroy.type: type = facet_type <@Destroy> [concrete]
  86. // CHECK:STDOUT: %pattern_type.f6d: type = pattern_type auto [concrete]
  87. // CHECK:STDOUT: %Destroy.impl_witness: <witness> = impl_witness @C.%Destroy.impl_witness_table [concrete]
  88. // CHECK:STDOUT: %ptr.019: type = ptr_type %C [concrete]
  89. // CHECK:STDOUT: %pattern_type.44a: type = pattern_type %ptr.019 [concrete]
  90. // CHECK:STDOUT: %C.as.Destroy.impl.Op.type: type = fn_type @C.as.Destroy.impl.Op [concrete]
  91. // CHECK:STDOUT: %C.as.Destroy.impl.Op: %C.as.Destroy.impl.Op.type = struct_value () [concrete]
  92. // CHECK:STDOUT: %struct_type.n: type = struct_type {.n: %i32} [concrete]
  93. // CHECK:STDOUT: %complete_type.54b: <witness> = complete_type_witness %struct_type.n [concrete]
  94. // CHECK:STDOUT: %pattern_type.c48: type = pattern_type %C [concrete]
  95. // CHECK:STDOUT: %Test1.type: type = fn_type @Test1 [concrete]
  96. // CHECK:STDOUT: %Test1: %Test1.type = struct_value () [concrete]
  97. // CHECK:STDOUT: %F.specific_fn.04a: <specific function> = specific_function %F, @F(%C) [concrete]
  98. // CHECK:STDOUT: %struct_type.m.n: type = struct_type {.m: %i32, .n: %i32} [concrete]
  99. // CHECK:STDOUT: %pattern_type.811: type = pattern_type %struct_type.m.n [concrete]
  100. // CHECK:STDOUT: %Test2.type: type = fn_type @Test2 [concrete]
  101. // CHECK:STDOUT: %Test2: %Test2.type = struct_value () [concrete]
  102. // CHECK:STDOUT: %F.specific_fn.92d: <specific function> = specific_function %F, @F(%struct_type.m.n) [concrete]
  103. // CHECK:STDOUT: %inst.as_compatible.c0a: <instruction> = inst_value [concrete] {
  104. // CHECK:STDOUT: %.fbe: %C = as_compatible @F.%x.ref
  105. // CHECK:STDOUT: }
  106. // CHECK:STDOUT: %inst.splice_block.d20: <instruction> = inst_value [concrete] {
  107. // CHECK:STDOUT: %.39c: %i32 = splice_block %.e83 {
  108. // CHECK:STDOUT: %n.ref: %C.elem = name_ref n, @C.%.loc9 [concrete = @C.%.loc9]
  109. // CHECK:STDOUT: %.d20: ref %i32 = class_element_access %.fbe, element0
  110. // CHECK:STDOUT: %.e83: %i32 = bind_value %.d20
  111. // CHECK:STDOUT: }
  112. // CHECK:STDOUT: }
  113. // CHECK:STDOUT: %inst.splice_block.435: <instruction> = inst_value [concrete] {
  114. // CHECK:STDOUT: %.460: %i32 = splice_block %.39c {}
  115. // CHECK:STDOUT: }
  116. // CHECK:STDOUT: %complete_type.622: <witness> = complete_type_witness %struct_type.m.n [concrete]
  117. // CHECK:STDOUT: %inst.as_compatible.8f8: <instruction> = inst_value [concrete] {
  118. // CHECK:STDOUT: %.61c: %struct_type.m.n = as_compatible @F.%x.ref
  119. // CHECK:STDOUT: }
  120. // CHECK:STDOUT: %inst.struct_access: <instruction> = inst_value [concrete] {
  121. // CHECK:STDOUT: %.fd5: %i32 = struct_access %.61c, element1
  122. // CHECK:STDOUT: }
  123. // CHECK:STDOUT: %inst.splice_block.57b: <instruction> = inst_value [concrete] {
  124. // CHECK:STDOUT: %.fbf: %i32 = splice_block %.fd5 {}
  125. // CHECK:STDOUT: }
  126. // CHECK:STDOUT: }
  127. // CHECK:STDOUT:
  128. // CHECK:STDOUT: imports {
  129. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  130. // CHECK:STDOUT: .Int = %Core.Int
  131. // CHECK:STDOUT: .Destroy = %Core.Destroy
  132. // CHECK:STDOUT: import Core//prelude
  133. // CHECK:STDOUT: import Core//prelude/...
  134. // CHECK:STDOUT: }
  135. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/parts/int, Int, loaded [concrete = constants.%Int.generic]
  136. // CHECK:STDOUT: %Core.Destroy: type = import_ref Core//prelude/parts/destroy, Destroy, loaded [concrete = constants.%Destroy.type]
  137. // CHECK:STDOUT: }
  138. // CHECK:STDOUT:
  139. // CHECK:STDOUT: file {
  140. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  141. // CHECK:STDOUT: .Core = imports.%Core
  142. // CHECK:STDOUT: .F = %F.decl
  143. // CHECK:STDOUT: .C = %C.decl
  144. // CHECK:STDOUT: .Test1 = %Test1.decl
  145. // CHECK:STDOUT: .Test2 = %Test2.decl
  146. // CHECK:STDOUT: }
  147. // CHECK:STDOUT: %Core.import = import Core
  148. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  149. // CHECK:STDOUT: %T.patt: %pattern_type.98f = symbolic_binding_pattern T, 0, template [concrete]
  150. // CHECK:STDOUT: %x.patt: @F.%pattern_type (%pattern_type.7dc) = binding_pattern x [concrete]
  151. // CHECK:STDOUT: %x.param_patt: @F.%pattern_type (%pattern_type.7dc) = value_param_pattern %x.patt, call_param0 [concrete]
  152. // CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern [concrete]
  153. // CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern %return.patt, call_param1 [concrete]
  154. // CHECK:STDOUT: } {
  155. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  156. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  157. // CHECK:STDOUT: %.Self: type = bind_symbolic_name .Self [symbolic_self = constants.%.Self]
  158. // CHECK:STDOUT: %T.loc4_15.2: type = bind_symbolic_name T, 0, template [template = %T.loc4_15.1 (constants.%T)]
  159. // CHECK:STDOUT: %x.param: @F.%T.loc4_15.1 (%T) = value_param call_param0
  160. // CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc4_15.2 [template = %T.loc4_15.1 (constants.%T)]
  161. // CHECK:STDOUT: %x: @F.%T.loc4_15.1 (%T) = bind_name x, %x.param
  162. // CHECK:STDOUT: %return.param: ref %i32 = out_param call_param1
  163. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  164. // CHECK:STDOUT: }
  165. // CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {}
  166. // CHECK:STDOUT: %Test1.decl: %Test1.type = fn_decl @Test1 [concrete = constants.%Test1] {
  167. // CHECK:STDOUT: %c.patt: %pattern_type.c48 = binding_pattern c [concrete]
  168. // CHECK:STDOUT: %c.param_patt: %pattern_type.c48 = value_param_pattern %c.patt, call_param0 [concrete]
  169. // CHECK:STDOUT: } {
  170. // CHECK:STDOUT: %c.param: %C = value_param call_param0
  171. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C]
  172. // CHECK:STDOUT: %c: %C = bind_name c, %c.param
  173. // CHECK:STDOUT: }
  174. // CHECK:STDOUT: %Test2.decl: %Test2.type = fn_decl @Test2 [concrete = constants.%Test2] {
  175. // CHECK:STDOUT: %x.patt: %pattern_type.811 = binding_pattern x [concrete]
  176. // CHECK:STDOUT: %x.param_patt: %pattern_type.811 = value_param_pattern %x.patt, call_param0 [concrete]
  177. // CHECK:STDOUT: } {
  178. // CHECK:STDOUT: %x.param: %struct_type.m.n = value_param call_param0
  179. // CHECK:STDOUT: %.loc16: type = splice_block %struct_type.m.n [concrete = constants.%struct_type.m.n] {
  180. // CHECK:STDOUT: %int_32.loc16_18: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  181. // CHECK:STDOUT: %i32.loc16_18: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  182. // CHECK:STDOUT: %int_32.loc16_27: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  183. // CHECK:STDOUT: %i32.loc16_27: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  184. // CHECK:STDOUT: %struct_type.m.n: type = struct_type {.m: %i32, .n: %i32} [concrete = constants.%struct_type.m.n]
  185. // CHECK:STDOUT: }
  186. // CHECK:STDOUT: %x: %struct_type.m.n = bind_name x, %x.param
  187. // CHECK:STDOUT: }
  188. // CHECK:STDOUT: }
  189. // CHECK:STDOUT:
  190. // CHECK:STDOUT: impl @C.as.Destroy.impl: @C.%Self.ref as constants.%Destroy.type {
  191. // CHECK:STDOUT: %C.as.Destroy.impl.Op.decl: %C.as.Destroy.impl.Op.type = fn_decl @C.as.Destroy.impl.Op [concrete = constants.%C.as.Destroy.impl.Op] {
  192. // CHECK:STDOUT: %self.patt: %pattern_type.44a = binding_pattern self [concrete]
  193. // CHECK:STDOUT: %self.param_patt: %pattern_type.44a = value_param_pattern %self.patt, call_param0 [concrete]
  194. // CHECK:STDOUT: %.loc8: %pattern_type.f6d = addr_pattern %self.param_patt [concrete]
  195. // CHECK:STDOUT: } {
  196. // CHECK:STDOUT: %self.param: %ptr.019 = value_param call_param0
  197. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%C [concrete = constants.%C]
  198. // CHECK:STDOUT: %self: %ptr.019 = bind_name self, %self.param
  199. // CHECK:STDOUT: }
  200. // CHECK:STDOUT:
  201. // CHECK:STDOUT: !members:
  202. // CHECK:STDOUT: .Op = %C.as.Destroy.impl.Op.decl
  203. // CHECK:STDOUT: witness = @C.%Destroy.impl_witness
  204. // CHECK:STDOUT: }
  205. // CHECK:STDOUT:
  206. // CHECK:STDOUT: class @C {
  207. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  208. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  209. // CHECK:STDOUT: %.loc9: %C.elem = field_decl n, element0 [concrete]
  210. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%C [concrete = constants.%C]
  211. // CHECK:STDOUT: impl_decl @C.as.Destroy.impl [concrete] {} {}
  212. // CHECK:STDOUT: %Destroy.impl_witness_table = impl_witness_table (@C.as.Destroy.impl.%C.as.Destroy.impl.Op.decl), @C.as.Destroy.impl [concrete]
  213. // CHECK:STDOUT: %Destroy.impl_witness: <witness> = impl_witness %Destroy.impl_witness_table [concrete = constants.%Destroy.impl_witness]
  214. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%struct_type.n [concrete = constants.%complete_type.54b]
  215. // CHECK:STDOUT: complete_type_witness = %complete_type
  216. // CHECK:STDOUT:
  217. // CHECK:STDOUT: !members:
  218. // CHECK:STDOUT: .Self = constants.%C
  219. // CHECK:STDOUT: .n = %.loc9
  220. // CHECK:STDOUT: }
  221. // CHECK:STDOUT:
  222. // CHECK:STDOUT: generic fn @F(%T.loc4_15.2: type) {
  223. // CHECK:STDOUT: %T.loc4_15.1: type = bind_symbolic_name T, 0, template [template = %T.loc4_15.1 (constants.%T)]
  224. // CHECK:STDOUT: %pattern_type: type = pattern_type %T.loc4_15.1 [template = %pattern_type (constants.%pattern_type.7dc)]
  225. // CHECK:STDOUT:
  226. // CHECK:STDOUT: !definition:
  227. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type %T.loc4_15.1 [template = %require_complete (constants.%require_complete.4ae)]
  228. // CHECK:STDOUT: %.loc5_11.3: <instruction> = refine_type_action %x.ref, %T.loc4_15.1 [template]
  229. // CHECK:STDOUT: %.loc5_11.4: <instruction> = access_member_action %.loc5_11.1, n [template]
  230. // CHECK:STDOUT: %.loc5_11.5: type = type_of_inst %.loc5_11.4 [template]
  231. // CHECK:STDOUT: %.loc5_13.2: <instruction> = convert_to_value_action %.loc5_11.2, constants.%i32 [template]
  232. // CHECK:STDOUT:
  233. // CHECK:STDOUT: fn(%x.param: @F.%T.loc4_15.1 (%T)) -> %i32 {
  234. // CHECK:STDOUT: !entry:
  235. // CHECK:STDOUT: %x.ref: @F.%T.loc4_15.1 (%T) = name_ref x, %x
  236. // CHECK:STDOUT: %.loc5_11.1: @F.%T.loc4_15.1 (%T) = splice_inst %.loc5_11.3
  237. // CHECK:STDOUT: %.loc5_11.2: @F.%.loc5_11.5 (@F.%.loc5_11.5) = splice_inst %.loc5_11.4
  238. // CHECK:STDOUT: %.loc5_13.1: %i32 = splice_inst %.loc5_13.2
  239. // CHECK:STDOUT: return %.loc5_13.1
  240. // CHECK:STDOUT: }
  241. // CHECK:STDOUT: }
  242. // CHECK:STDOUT:
  243. // CHECK:STDOUT: fn @C.as.Destroy.impl.Op(%self.param: %ptr.019) = "no_op";
  244. // CHECK:STDOUT:
  245. // CHECK:STDOUT: fn @Test1(%c.param: %C) {
  246. // CHECK:STDOUT: !entry:
  247. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [concrete = constants.%F]
  248. // CHECK:STDOUT: %c.ref: %C = name_ref c, %c
  249. // CHECK:STDOUT: %F.specific_fn: <specific function> = specific_function %F.ref, @F(constants.%C) [concrete = constants.%F.specific_fn.04a]
  250. // CHECK:STDOUT: %F.call: init %i32 = call %F.specific_fn(%c.ref)
  251. // CHECK:STDOUT: return
  252. // CHECK:STDOUT: }
  253. // CHECK:STDOUT:
  254. // CHECK:STDOUT: fn @Test2(%x.param: %struct_type.m.n) {
  255. // CHECK:STDOUT: !entry:
  256. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [concrete = constants.%F]
  257. // CHECK:STDOUT: %x.ref: %struct_type.m.n = name_ref x, %x
  258. // CHECK:STDOUT: %F.specific_fn: <specific function> = specific_function %F.ref, @F(constants.%struct_type.m.n) [concrete = constants.%F.specific_fn.92d]
  259. // CHECK:STDOUT: %F.call: init %i32 = call %F.specific_fn(%x.ref)
  260. // CHECK:STDOUT: return
  261. // CHECK:STDOUT: }
  262. // CHECK:STDOUT:
  263. // CHECK:STDOUT: specific @F(constants.%T) {
  264. // CHECK:STDOUT: %T.loc4_15.1 => constants.%T
  265. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.7dc
  266. // CHECK:STDOUT: }
  267. // CHECK:STDOUT:
  268. // CHECK:STDOUT: specific @F(constants.%C) {
  269. // CHECK:STDOUT: %T.loc4_15.1 => constants.%C
  270. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.c48
  271. // CHECK:STDOUT:
  272. // CHECK:STDOUT: !definition:
  273. // CHECK:STDOUT: %require_complete => constants.%complete_type.54b
  274. // CHECK:STDOUT: %.loc5_11.3 => constants.%inst.as_compatible.c0a
  275. // CHECK:STDOUT: %.loc5_11.4 => constants.%inst.splice_block.d20
  276. // CHECK:STDOUT: %.loc5_11.5 => constants.%i32
  277. // CHECK:STDOUT: %.loc5_13.2 => constants.%inst.splice_block.435
  278. // CHECK:STDOUT: }
  279. // CHECK:STDOUT:
  280. // CHECK:STDOUT: specific @F(constants.%struct_type.m.n) {
  281. // CHECK:STDOUT: %T.loc4_15.1 => constants.%struct_type.m.n
  282. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.811
  283. // CHECK:STDOUT:
  284. // CHECK:STDOUT: !definition:
  285. // CHECK:STDOUT: %require_complete => constants.%complete_type.622
  286. // CHECK:STDOUT: %.loc5_11.3 => constants.%inst.as_compatible.8f8
  287. // CHECK:STDOUT: %.loc5_11.4 => constants.%inst.struct_access
  288. // CHECK:STDOUT: %.loc5_11.5 => constants.%i32
  289. // CHECK:STDOUT: %.loc5_13.2 => constants.%inst.splice_block.57b
  290. // CHECK:STDOUT: }
  291. // CHECK:STDOUT:
  292. // CHECK:STDOUT: --- fail_no_such_member.carbon
  293. // CHECK:STDOUT:
  294. // CHECK:STDOUT: constants {
  295. // CHECK:STDOUT: %.Self: type = bind_symbolic_name .Self [symbolic_self]
  296. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0, template [template]
  297. // CHECK:STDOUT: %pattern_type.98f: type = pattern_type type [concrete]
  298. // CHECK:STDOUT: %pattern_type.7dc: type = pattern_type %T [template]
  299. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  300. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  301. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  302. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  303. // CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
  304. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  305. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  306. // CHECK:STDOUT: %require_complete.4ae: <witness> = require_complete_type %T [template]
  307. // CHECK:STDOUT: %D: type = class_type @D [concrete]
  308. // CHECK:STDOUT: %D.elem: type = unbound_element_type %D, %i32 [concrete]
  309. // CHECK:STDOUT: %Destroy.type: type = facet_type <@Destroy> [concrete]
  310. // CHECK:STDOUT: %pattern_type.f6d: type = pattern_type auto [concrete]
  311. // CHECK:STDOUT: %Destroy.impl_witness: <witness> = impl_witness @D.%Destroy.impl_witness_table [concrete]
  312. // CHECK:STDOUT: %ptr.19c: type = ptr_type %D [concrete]
  313. // CHECK:STDOUT: %pattern_type.a94: type = pattern_type %ptr.19c [concrete]
  314. // CHECK:STDOUT: %D.as.Destroy.impl.Op.type: type = fn_type @D.as.Destroy.impl.Op [concrete]
  315. // CHECK:STDOUT: %D.as.Destroy.impl.Op: %D.as.Destroy.impl.Op.type = struct_value () [concrete]
  316. // CHECK:STDOUT: %struct_type.m: type = struct_type {.m: %i32} [concrete]
  317. // CHECK:STDOUT: %complete_type.218: <witness> = complete_type_witness %struct_type.m [concrete]
  318. // CHECK:STDOUT: %pattern_type.510: type = pattern_type %D [concrete]
  319. // CHECK:STDOUT: %Test.type: type = fn_type @Test [concrete]
  320. // CHECK:STDOUT: %Test: %Test.type = struct_value () [concrete]
  321. // CHECK:STDOUT: %F.specific_fn: <specific function> = specific_function %F, @F(%D) [concrete]
  322. // CHECK:STDOUT: %inst.as_compatible: <instruction> = inst_value [concrete] {
  323. // CHECK:STDOUT: %.63b: %D = as_compatible @F.%x.ref
  324. // CHECK:STDOUT: }
  325. // CHECK:STDOUT: %inst.name_ref: <instruction> = inst_value [concrete] {
  326. // CHECK:STDOUT: %n.ref: <error> = name_ref n, <error> [concrete = <error>]
  327. // CHECK:STDOUT: }
  328. // CHECK:STDOUT: %inst.splice_block: <instruction> = inst_value [concrete] {
  329. // CHECK:STDOUT: %.432: <error> = splice_block <error> [concrete = <error>] {}
  330. // CHECK:STDOUT: }
  331. // CHECK:STDOUT: }
  332. // CHECK:STDOUT:
  333. // CHECK:STDOUT: imports {
  334. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  335. // CHECK:STDOUT: .Int = %Core.Int
  336. // CHECK:STDOUT: .Destroy = %Core.Destroy
  337. // CHECK:STDOUT: import Core//prelude
  338. // CHECK:STDOUT: import Core//prelude/...
  339. // CHECK:STDOUT: }
  340. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/parts/int, Int, loaded [concrete = constants.%Int.generic]
  341. // CHECK:STDOUT: %Core.Destroy: type = import_ref Core//prelude/parts/destroy, Destroy, loaded [concrete = constants.%Destroy.type]
  342. // CHECK:STDOUT: }
  343. // CHECK:STDOUT:
  344. // CHECK:STDOUT: file {
  345. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  346. // CHECK:STDOUT: .Core = imports.%Core
  347. // CHECK:STDOUT: .F = %F.decl
  348. // CHECK:STDOUT: .D = %D.decl
  349. // CHECK:STDOUT: .Test = %Test.decl
  350. // CHECK:STDOUT: }
  351. // CHECK:STDOUT: %Core.import = import Core
  352. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  353. // CHECK:STDOUT: %T.patt: %pattern_type.98f = symbolic_binding_pattern T, 0, template [concrete]
  354. // CHECK:STDOUT: %x.patt: @F.%pattern_type (%pattern_type.7dc) = binding_pattern x [concrete]
  355. // CHECK:STDOUT: %x.param_patt: @F.%pattern_type (%pattern_type.7dc) = value_param_pattern %x.patt, call_param0 [concrete]
  356. // CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern [concrete]
  357. // CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern %return.patt, call_param1 [concrete]
  358. // CHECK:STDOUT: } {
  359. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  360. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  361. // CHECK:STDOUT: %.Self: type = bind_symbolic_name .Self [symbolic_self = constants.%.Self]
  362. // CHECK:STDOUT: %T.loc4_15.2: type = bind_symbolic_name T, 0, template [template = %T.loc4_15.1 (constants.%T)]
  363. // CHECK:STDOUT: %x.param: @F.%T.loc4_15.1 (%T) = value_param call_param0
  364. // CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc4_15.2 [template = %T.loc4_15.1 (constants.%T)]
  365. // CHECK:STDOUT: %x: @F.%T.loc4_15.1 (%T) = bind_name x, %x.param
  366. // CHECK:STDOUT: %return.param: ref %i32 = out_param call_param1
  367. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  368. // CHECK:STDOUT: }
  369. // CHECK:STDOUT: %D.decl: type = class_decl @D [concrete = constants.%D] {} {}
  370. // CHECK:STDOUT: %Test.decl: %Test.type = fn_decl @Test [concrete = constants.%Test] {
  371. // CHECK:STDOUT: %d.patt: %pattern_type.510 = binding_pattern d [concrete]
  372. // CHECK:STDOUT: %d.param_patt: %pattern_type.510 = value_param_pattern %d.patt, call_param0 [concrete]
  373. // CHECK:STDOUT: } {
  374. // CHECK:STDOUT: %d.param: %D = value_param call_param0
  375. // CHECK:STDOUT: %D.ref: type = name_ref D, file.%D.decl [concrete = constants.%D]
  376. // CHECK:STDOUT: %d: %D = bind_name d, %d.param
  377. // CHECK:STDOUT: }
  378. // CHECK:STDOUT: }
  379. // CHECK:STDOUT:
  380. // CHECK:STDOUT: impl @D.as.Destroy.impl: @D.%Self.ref as constants.%Destroy.type {
  381. // CHECK:STDOUT: %D.as.Destroy.impl.Op.decl: %D.as.Destroy.impl.Op.type = fn_decl @D.as.Destroy.impl.Op [concrete = constants.%D.as.Destroy.impl.Op] {
  382. // CHECK:STDOUT: %self.patt: %pattern_type.a94 = binding_pattern self [concrete]
  383. // CHECK:STDOUT: %self.param_patt: %pattern_type.a94 = value_param_pattern %self.patt, call_param0 [concrete]
  384. // CHECK:STDOUT: %.loc11: %pattern_type.f6d = addr_pattern %self.param_patt [concrete]
  385. // CHECK:STDOUT: } {
  386. // CHECK:STDOUT: %self.param: %ptr.19c = value_param call_param0
  387. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%D [concrete = constants.%D]
  388. // CHECK:STDOUT: %self: %ptr.19c = bind_name self, %self.param
  389. // CHECK:STDOUT: }
  390. // CHECK:STDOUT:
  391. // CHECK:STDOUT: !members:
  392. // CHECK:STDOUT: .Op = %D.as.Destroy.impl.Op.decl
  393. // CHECK:STDOUT: witness = @D.%Destroy.impl_witness
  394. // CHECK:STDOUT: }
  395. // CHECK:STDOUT:
  396. // CHECK:STDOUT: class @D {
  397. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  398. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  399. // CHECK:STDOUT: %.loc12: %D.elem = field_decl m, element0 [concrete]
  400. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%D [concrete = constants.%D]
  401. // CHECK:STDOUT: impl_decl @D.as.Destroy.impl [concrete] {} {}
  402. // CHECK:STDOUT: %Destroy.impl_witness_table = impl_witness_table (@D.as.Destroy.impl.%D.as.Destroy.impl.Op.decl), @D.as.Destroy.impl [concrete]
  403. // CHECK:STDOUT: %Destroy.impl_witness: <witness> = impl_witness %Destroy.impl_witness_table [concrete = constants.%Destroy.impl_witness]
  404. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%struct_type.m [concrete = constants.%complete_type.218]
  405. // CHECK:STDOUT: complete_type_witness = %complete_type
  406. // CHECK:STDOUT:
  407. // CHECK:STDOUT: !members:
  408. // CHECK:STDOUT: .Self = constants.%D
  409. // CHECK:STDOUT: .m = %.loc12
  410. // CHECK:STDOUT: .n = <poisoned>
  411. // CHECK:STDOUT: }
  412. // CHECK:STDOUT:
  413. // CHECK:STDOUT: generic fn @F(%T.loc4_15.2: type) {
  414. // CHECK:STDOUT: %T.loc4_15.1: type = bind_symbolic_name T, 0, template [template = %T.loc4_15.1 (constants.%T)]
  415. // CHECK:STDOUT: %pattern_type: type = pattern_type %T.loc4_15.1 [template = %pattern_type (constants.%pattern_type.7dc)]
  416. // CHECK:STDOUT:
  417. // CHECK:STDOUT: !definition:
  418. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type %T.loc4_15.1 [template = %require_complete (constants.%require_complete.4ae)]
  419. // CHECK:STDOUT: %.loc8_11.3: <instruction> = refine_type_action %x.ref, %T.loc4_15.1 [template]
  420. // CHECK:STDOUT: %.loc8_11.4: <instruction> = access_member_action %.loc8_11.1, n [template]
  421. // CHECK:STDOUT: %.loc8_11.5: type = type_of_inst %.loc8_11.4 [template]
  422. // CHECK:STDOUT: %.loc8_13.2: <instruction> = convert_to_value_action %.loc8_11.2, constants.%i32 [template]
  423. // CHECK:STDOUT:
  424. // CHECK:STDOUT: fn(%x.param: @F.%T.loc4_15.1 (%T)) -> %i32 {
  425. // CHECK:STDOUT: !entry:
  426. // CHECK:STDOUT: %x.ref: @F.%T.loc4_15.1 (%T) = name_ref x, %x
  427. // CHECK:STDOUT: %.loc8_11.1: @F.%T.loc4_15.1 (%T) = splice_inst %.loc8_11.3
  428. // CHECK:STDOUT: %.loc8_11.2: @F.%.loc8_11.5 (@F.%.loc8_11.5) = splice_inst %.loc8_11.4
  429. // CHECK:STDOUT: %.loc8_13.1: %i32 = splice_inst %.loc8_13.2
  430. // CHECK:STDOUT: return %.loc8_13.1
  431. // CHECK:STDOUT: }
  432. // CHECK:STDOUT: }
  433. // CHECK:STDOUT:
  434. // CHECK:STDOUT: fn @D.as.Destroy.impl.Op(%self.param: %ptr.19c) = "no_op";
  435. // CHECK:STDOUT:
  436. // CHECK:STDOUT: fn @Test(%d.param: %D) {
  437. // CHECK:STDOUT: !entry:
  438. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [concrete = constants.%F]
  439. // CHECK:STDOUT: %d.ref: %D = name_ref d, %d
  440. // CHECK:STDOUT: %F.specific_fn: <specific function> = specific_function %F.ref, @F(constants.%D) [concrete = constants.%F.specific_fn]
  441. // CHECK:STDOUT: %F.call: init %i32 = call %F.specific_fn(%d.ref)
  442. // CHECK:STDOUT: return
  443. // CHECK:STDOUT: }
  444. // CHECK:STDOUT:
  445. // CHECK:STDOUT: specific @F(constants.%T) {
  446. // CHECK:STDOUT: %T.loc4_15.1 => constants.%T
  447. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.7dc
  448. // CHECK:STDOUT: }
  449. // CHECK:STDOUT:
  450. // CHECK:STDOUT: specific @F(constants.%D) {
  451. // CHECK:STDOUT: %T.loc4_15.1 => constants.%D
  452. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.510
  453. // CHECK:STDOUT:
  454. // CHECK:STDOUT: !definition:
  455. // CHECK:STDOUT: %require_complete => constants.%complete_type.218
  456. // CHECK:STDOUT: %.loc8_11.3 => constants.%inst.as_compatible
  457. // CHECK:STDOUT: %.loc8_11.4 => constants.%inst.name_ref
  458. // CHECK:STDOUT: %.loc8_11.5 => <error>
  459. // CHECK:STDOUT: %.loc8_13.2 => constants.%inst.splice_block
  460. // CHECK:STDOUT: }
  461. // CHECK:STDOUT:
  462. // CHECK:STDOUT: --- fail_member_wrong_type.carbon
  463. // CHECK:STDOUT:
  464. // CHECK:STDOUT: constants {
  465. // CHECK:STDOUT: %.Self.644: type = bind_symbolic_name .Self [symbolic_self]
  466. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0, template [template]
  467. // CHECK:STDOUT: %pattern_type.98f: type = pattern_type type [concrete]
  468. // CHECK:STDOUT: %pattern_type.7dcd0a.1: type = pattern_type %T [template]
  469. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  470. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  471. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  472. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  473. // CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
  474. // CHECK:STDOUT: %F.type: type = fn_type @F.loc4 [concrete]
  475. // CHECK:STDOUT: %F.c41: %F.type = struct_value () [concrete]
  476. // CHECK:STDOUT: %require_complete.4ae: <witness> = require_complete_type %T [template]
  477. // CHECK:STDOUT: %E: type = class_type @E [concrete]
  478. // CHECK:STDOUT: %F.a8a: type = class_type @F.loc15 [concrete]
  479. // CHECK:STDOUT: %Destroy.type: type = facet_type <@Destroy> [concrete]
  480. // CHECK:STDOUT: %pattern_type.f6d: type = pattern_type auto [concrete]
  481. // CHECK:STDOUT: %Destroy.impl_witness.51a: <witness> = impl_witness @F.loc15.%Destroy.impl_witness_table [concrete]
  482. // CHECK:STDOUT: %ptr.01c: type = ptr_type %F.a8a [concrete]
  483. // CHECK:STDOUT: %pattern_type.463: type = pattern_type %ptr.01c [concrete]
  484. // CHECK:STDOUT: %F.as.Destroy.impl.Op.type: type = fn_type @F.as.Destroy.impl.Op [concrete]
  485. // CHECK:STDOUT: %F.as.Destroy.impl.Op: %F.as.Destroy.impl.Op.type = struct_value () [concrete]
  486. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  487. // CHECK:STDOUT: %complete_type.357: <witness> = complete_type_witness %empty_struct_type [concrete]
  488. // CHECK:STDOUT: %E.elem: type = unbound_element_type %E, %F.a8a [concrete]
  489. // CHECK:STDOUT: %Destroy.impl_witness.c1f: <witness> = impl_witness @E.%Destroy.impl_witness_table [concrete]
  490. // CHECK:STDOUT: %ptr.742: type = ptr_type %E [concrete]
  491. // CHECK:STDOUT: %pattern_type.88c: type = pattern_type %ptr.742 [concrete]
  492. // CHECK:STDOUT: %E.as.Destroy.impl.Op.type: type = fn_type @E.as.Destroy.impl.Op [concrete]
  493. // CHECK:STDOUT: %E.as.Destroy.impl.Op: %E.as.Destroy.impl.Op.type = struct_value () [concrete]
  494. // CHECK:STDOUT: %struct_type.n.e4c: type = struct_type {.n: %F.a8a} [concrete]
  495. // CHECK:STDOUT: %complete_type.5ba: <witness> = complete_type_witness %struct_type.n.e4c [concrete]
  496. // CHECK:STDOUT: %pattern_type.a4a: type = pattern_type %E [concrete]
  497. // CHECK:STDOUT: %Test.type: type = fn_type @Test [concrete]
  498. // CHECK:STDOUT: %Test: %Test.type = struct_value () [concrete]
  499. // CHECK:STDOUT: %F.specific_fn: <specific function> = specific_function %F.c41, @F.loc4(%E) [concrete]
  500. // CHECK:STDOUT: %inst.as_compatible: <instruction> = inst_value [concrete] {
  501. // CHECK:STDOUT: %.a66: %E = as_compatible @F.loc4.%x.ref
  502. // CHECK:STDOUT: }
  503. // CHECK:STDOUT: %inst.splice_block.2a2: <instruction> = inst_value [concrete] {
  504. // CHECK:STDOUT: %.6c9: %F.a8a = splice_block %.e29 {
  505. // CHECK:STDOUT: %n.ref: %E.elem = name_ref n, @E.%.loc16 [concrete = @E.%.loc16]
  506. // CHECK:STDOUT: %.999: ref %F.a8a = class_element_access %.a66, element0
  507. // CHECK:STDOUT: %.e29: %F.a8a = bind_value %.999
  508. // CHECK:STDOUT: }
  509. // CHECK:STDOUT: }
  510. // CHECK:STDOUT: %ImplicitAs.type.cc7: type = generic_interface_type @ImplicitAs [concrete]
  511. // CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.cc7 = struct_value () [concrete]
  512. // CHECK:STDOUT: %inst.splice_block.a04: <instruction> = inst_value [concrete] {
  513. // CHECK:STDOUT: %.31f: <error> = splice_block <error> [concrete = <error>] {
  514. // CHECK:STDOUT: %.fd6: %i32 = converted %.6c9, <error> [concrete = <error>]
  515. // CHECK:STDOUT: }
  516. // CHECK:STDOUT: }
  517. // CHECK:STDOUT: }
  518. // CHECK:STDOUT:
  519. // CHECK:STDOUT: imports {
  520. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  521. // CHECK:STDOUT: .Int = %Core.Int
  522. // CHECK:STDOUT: .Destroy = %Core.Destroy
  523. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  524. // CHECK:STDOUT: import Core//prelude
  525. // CHECK:STDOUT: import Core//prelude/...
  526. // CHECK:STDOUT: }
  527. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/parts/int, Int, loaded [concrete = constants.%Int.generic]
  528. // CHECK:STDOUT: %Core.Destroy: type = import_ref Core//prelude/parts/destroy, Destroy, loaded [concrete = constants.%Destroy.type]
  529. // CHECK:STDOUT: %Core.ImplicitAs: %ImplicitAs.type.cc7 = import_ref Core//prelude/parts/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic]
  530. // CHECK:STDOUT: }
  531. // CHECK:STDOUT:
  532. // CHECK:STDOUT: file {
  533. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  534. // CHECK:STDOUT: .Core = imports.%Core
  535. // CHECK:STDOUT: .F = %F.decl
  536. // CHECK:STDOUT: .E = %E.decl
  537. // CHECK:STDOUT: .Test = %Test.decl
  538. // CHECK:STDOUT: }
  539. // CHECK:STDOUT: %Core.import = import Core
  540. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F.loc4 [concrete = constants.%F.c41] {
  541. // CHECK:STDOUT: %T.patt: %pattern_type.98f = symbolic_binding_pattern T, 0, template [concrete]
  542. // CHECK:STDOUT: %x.patt: @F.loc4.%pattern_type (%pattern_type.7dcd0a.1) = binding_pattern x [concrete]
  543. // CHECK:STDOUT: %x.param_patt: @F.loc4.%pattern_type (%pattern_type.7dcd0a.1) = value_param_pattern %x.patt, call_param0 [concrete]
  544. // CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern [concrete]
  545. // CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern %return.patt, call_param1 [concrete]
  546. // CHECK:STDOUT: } {
  547. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  548. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  549. // CHECK:STDOUT: %.Self: type = bind_symbolic_name .Self [symbolic_self = constants.%.Self.644]
  550. // CHECK:STDOUT: %T.loc4_15.2: type = bind_symbolic_name T, 0, template [template = %T.loc4_15.1 (constants.%T)]
  551. // CHECK:STDOUT: %x.param: @F.loc4.%T.loc4_15.1 (%T) = value_param call_param0
  552. // CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc4_15.2 [template = %T.loc4_15.1 (constants.%T)]
  553. // CHECK:STDOUT: %x: @F.loc4.%T.loc4_15.1 (%T) = bind_name x, %x.param
  554. // CHECK:STDOUT: %return.param: ref %i32 = out_param call_param1
  555. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  556. // CHECK:STDOUT: }
  557. // CHECK:STDOUT: %E.decl: type = class_decl @E [concrete = constants.%E] {} {}
  558. // CHECK:STDOUT: %Test.decl: %Test.type = fn_decl @Test [concrete = constants.%Test] {
  559. // CHECK:STDOUT: %e.patt: %pattern_type.a4a = binding_pattern e [concrete]
  560. // CHECK:STDOUT: %e.param_patt: %pattern_type.a4a = value_param_pattern %e.patt, call_param0 [concrete]
  561. // CHECK:STDOUT: } {
  562. // CHECK:STDOUT: %e.param: %E = value_param call_param0
  563. // CHECK:STDOUT: %E.ref: type = name_ref E, file.%E.decl [concrete = constants.%E]
  564. // CHECK:STDOUT: %e: %E = bind_name e, %e.param
  565. // CHECK:STDOUT: }
  566. // CHECK:STDOUT: }
  567. // CHECK:STDOUT:
  568. // CHECK:STDOUT: impl @F.as.Destroy.impl: @F.loc15.%Self.ref as constants.%Destroy.type {
  569. // CHECK:STDOUT: %F.as.Destroy.impl.Op.decl: %F.as.Destroy.impl.Op.type = fn_decl @F.as.Destroy.impl.Op [concrete = constants.%F.as.Destroy.impl.Op] {
  570. // CHECK:STDOUT: %self.patt: %pattern_type.463 = binding_pattern self [concrete]
  571. // CHECK:STDOUT: %self.param_patt: %pattern_type.463 = value_param_pattern %self.patt, call_param0 [concrete]
  572. // CHECK:STDOUT: %.loc15: %pattern_type.f6d = addr_pattern %self.param_patt [concrete]
  573. // CHECK:STDOUT: } {
  574. // CHECK:STDOUT: %self.param: %ptr.01c = value_param call_param0
  575. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%F.a8a [concrete = constants.%F.a8a]
  576. // CHECK:STDOUT: %self: %ptr.01c = bind_name self, %self.param
  577. // CHECK:STDOUT: }
  578. // CHECK:STDOUT:
  579. // CHECK:STDOUT: !members:
  580. // CHECK:STDOUT: .Op = %F.as.Destroy.impl.Op.decl
  581. // CHECK:STDOUT: witness = @F.loc15.%Destroy.impl_witness
  582. // CHECK:STDOUT: }
  583. // CHECK:STDOUT:
  584. // CHECK:STDOUT: impl @E.as.Destroy.impl: @E.%Self.ref as constants.%Destroy.type {
  585. // CHECK:STDOUT: %E.as.Destroy.impl.Op.decl: %E.as.Destroy.impl.Op.type = fn_decl @E.as.Destroy.impl.Op [concrete = constants.%E.as.Destroy.impl.Op] {
  586. // CHECK:STDOUT: %self.patt: %pattern_type.88c = binding_pattern self [concrete]
  587. // CHECK:STDOUT: %self.param_patt: %pattern_type.88c = value_param_pattern %self.patt, call_param0 [concrete]
  588. // CHECK:STDOUT: %.loc14: %pattern_type.f6d = addr_pattern %self.param_patt [concrete]
  589. // CHECK:STDOUT: } {
  590. // CHECK:STDOUT: %self.param: %ptr.742 = value_param call_param0
  591. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%E [concrete = constants.%E]
  592. // CHECK:STDOUT: %self: %ptr.742 = bind_name self, %self.param
  593. // CHECK:STDOUT: }
  594. // CHECK:STDOUT:
  595. // CHECK:STDOUT: !members:
  596. // CHECK:STDOUT: .Op = %E.as.Destroy.impl.Op.decl
  597. // CHECK:STDOUT: witness = @E.%Destroy.impl_witness
  598. // CHECK:STDOUT: }
  599. // CHECK:STDOUT:
  600. // CHECK:STDOUT: class @E {
  601. // CHECK:STDOUT: %F.decl: type = class_decl @F.loc15 [concrete = constants.%F.a8a] {} {}
  602. // CHECK:STDOUT: %F.ref: type = name_ref F, %F.decl [concrete = constants.%F.a8a]
  603. // CHECK:STDOUT: %.loc16: %E.elem = field_decl n, element0 [concrete]
  604. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%E [concrete = constants.%E]
  605. // CHECK:STDOUT: impl_decl @E.as.Destroy.impl [concrete] {} {}
  606. // CHECK:STDOUT: %Destroy.impl_witness_table = impl_witness_table (@E.as.Destroy.impl.%E.as.Destroy.impl.Op.decl), @E.as.Destroy.impl [concrete]
  607. // CHECK:STDOUT: %Destroy.impl_witness: <witness> = impl_witness %Destroy.impl_witness_table [concrete = constants.%Destroy.impl_witness.c1f]
  608. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%struct_type.n.e4c [concrete = constants.%complete_type.5ba]
  609. // CHECK:STDOUT: complete_type_witness = %complete_type
  610. // CHECK:STDOUT:
  611. // CHECK:STDOUT: !members:
  612. // CHECK:STDOUT: .Self = constants.%E
  613. // CHECK:STDOUT: .F = %F.decl
  614. // CHECK:STDOUT: .n = %.loc16
  615. // CHECK:STDOUT: }
  616. // CHECK:STDOUT:
  617. // CHECK:STDOUT: class @F.loc15 {
  618. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%F.a8a [concrete = constants.%F.a8a]
  619. // CHECK:STDOUT: impl_decl @F.as.Destroy.impl [concrete] {} {}
  620. // CHECK:STDOUT: %Destroy.impl_witness_table = impl_witness_table (@F.as.Destroy.impl.%F.as.Destroy.impl.Op.decl), @F.as.Destroy.impl [concrete]
  621. // CHECK:STDOUT: %Destroy.impl_witness: <witness> = impl_witness %Destroy.impl_witness_table [concrete = constants.%Destroy.impl_witness.51a]
  622. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type.357]
  623. // CHECK:STDOUT: complete_type_witness = %complete_type
  624. // CHECK:STDOUT:
  625. // CHECK:STDOUT: !members:
  626. // CHECK:STDOUT: .Self = constants.%F.a8a
  627. // CHECK:STDOUT: }
  628. // CHECK:STDOUT:
  629. // CHECK:STDOUT: generic fn @F.loc4(%T.loc4_15.2: type) {
  630. // CHECK:STDOUT: %T.loc4_15.1: type = bind_symbolic_name T, 0, template [template = %T.loc4_15.1 (constants.%T)]
  631. // CHECK:STDOUT: %pattern_type: type = pattern_type %T.loc4_15.1 [template = %pattern_type (constants.%pattern_type.7dcd0a.1)]
  632. // CHECK:STDOUT:
  633. // CHECK:STDOUT: !definition:
  634. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type %T.loc4_15.1 [template = %require_complete (constants.%require_complete.4ae)]
  635. // CHECK:STDOUT: %.loc11_11.3: <instruction> = refine_type_action %x.ref, %T.loc4_15.1 [template]
  636. // CHECK:STDOUT: %.loc11_11.4: <instruction> = access_member_action %.loc11_11.1, n [template]
  637. // CHECK:STDOUT: %.loc11_11.5: type = type_of_inst %.loc11_11.4 [template]
  638. // CHECK:STDOUT: %.loc11_13.2: <instruction> = convert_to_value_action %.loc11_11.2, constants.%i32 [template]
  639. // CHECK:STDOUT:
  640. // CHECK:STDOUT: fn(%x.param: @F.loc4.%T.loc4_15.1 (%T)) -> %i32 {
  641. // CHECK:STDOUT: !entry:
  642. // CHECK:STDOUT: %x.ref: @F.loc4.%T.loc4_15.1 (%T) = name_ref x, %x
  643. // CHECK:STDOUT: %.loc11_11.1: @F.loc4.%T.loc4_15.1 (%T) = splice_inst %.loc11_11.3
  644. // CHECK:STDOUT: %.loc11_11.2: @F.loc4.%.loc11_11.5 (@F.loc4.%.loc11_11.5) = splice_inst %.loc11_11.4
  645. // CHECK:STDOUT: %.loc11_13.1: %i32 = splice_inst %.loc11_13.2
  646. // CHECK:STDOUT: return %.loc11_13.1
  647. // CHECK:STDOUT: }
  648. // CHECK:STDOUT: }
  649. // CHECK:STDOUT:
  650. // CHECK:STDOUT: fn @F.as.Destroy.impl.Op(%self.param: %ptr.01c) = "no_op";
  651. // CHECK:STDOUT:
  652. // CHECK:STDOUT: fn @E.as.Destroy.impl.Op(%self.param: %ptr.742) = "no_op";
  653. // CHECK:STDOUT:
  654. // CHECK:STDOUT: fn @Test(%e.param: %E) {
  655. // CHECK:STDOUT: !entry:
  656. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [concrete = constants.%F.c41]
  657. // CHECK:STDOUT: %e.ref: %E = name_ref e, %e
  658. // CHECK:STDOUT: %F.specific_fn: <specific function> = specific_function %F.ref, @F.loc4(constants.%E) [concrete = constants.%F.specific_fn]
  659. // CHECK:STDOUT: %F.call: init %i32 = call %F.specific_fn(%e.ref)
  660. // CHECK:STDOUT: return
  661. // CHECK:STDOUT: }
  662. // CHECK:STDOUT:
  663. // CHECK:STDOUT: specific @F.loc4(constants.%T) {
  664. // CHECK:STDOUT: %T.loc4_15.1 => constants.%T
  665. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.7dcd0a.1
  666. // CHECK:STDOUT: }
  667. // CHECK:STDOUT:
  668. // CHECK:STDOUT: specific @F.loc4(constants.%E) {
  669. // CHECK:STDOUT: %T.loc4_15.1 => constants.%E
  670. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.a4a
  671. // CHECK:STDOUT:
  672. // CHECK:STDOUT: !definition:
  673. // CHECK:STDOUT: %require_complete => constants.%complete_type.5ba
  674. // CHECK:STDOUT: %.loc11_11.3 => constants.%inst.as_compatible
  675. // CHECK:STDOUT: %.loc11_11.4 => constants.%inst.splice_block.2a2
  676. // CHECK:STDOUT: %.loc11_11.5 => constants.%F.a8a
  677. // CHECK:STDOUT: %.loc11_13.2 => constants.%inst.splice_block.a04
  678. // CHECK:STDOUT: }
  679. // CHECK:STDOUT: