member_access.carbon 40 KB

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