import_use_generic.carbon 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/none.carbon
  6. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  7. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  8. //
  9. // AUTOUPDATE
  10. // TIP: To test this file alone, run:
  11. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/impl/import_use_generic.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/import_use_generic.carbon
  14. // --- import_generic.carbon
  15. library "[[@TEST_NAME]]";
  16. class C(T:! type) {}
  17. interface I {
  18. fn F();
  19. }
  20. impl forall [T:! type] C(T) as I {
  21. fn F() {}
  22. }
  23. // --- fail_use_in_fn_decl.carbon
  24. library "[[@TEST_NAME]]";
  25. import library "import_generic";
  26. var c: C({}) = {};
  27. // We're just checking that this doesn't crash. It's not expected to compile.
  28. // CHECK:STDERR: fail_use_in_fn_decl.carbon:[[@LINE+8]]:11: error: `Core.ImplicitAs` implicitly referenced here, but package `Core` not found [CoreNotFound]
  29. // CHECK:STDERR: fn G() -> c.(I.F)() {}
  30. // CHECK:STDERR: ^~~~~~~
  31. // CHECK:STDERR:
  32. // CHECK:STDERR: fail_use_in_fn_decl.carbon:[[@LINE+4]]:22: error: missing `return` at end of function with declared return type [MissingReturnStatement]
  33. // CHECK:STDERR: fn G() -> c.(I.F)() {}
  34. // CHECK:STDERR: ^
  35. // CHECK:STDERR:
  36. fn G() -> c.(I.F)() {}
  37. // CHECK:STDERR: fail_use_in_fn_decl.carbon:[[@LINE+8]]:11: error: `Core.ImplicitAs` implicitly referenced here, but package `Core` not found [CoreNotFound]
  38. // CHECK:STDERR: fn H() -> C({}).(I.F)() {}
  39. // CHECK:STDERR: ^~~~~~~~~~~~~
  40. // CHECK:STDERR:
  41. // CHECK:STDERR: fail_use_in_fn_decl.carbon:[[@LINE+4]]:26: error: missing `return` at end of function with declared return type [MissingReturnStatement]
  42. // CHECK:STDERR: fn H() -> C({}).(I.F)() {}
  43. // CHECK:STDERR: ^
  44. // CHECK:STDERR:
  45. fn H() -> C({}).(I.F)() {}
  46. // CHECK:STDOUT: --- import_generic.carbon
  47. // CHECK:STDOUT:
  48. // CHECK:STDOUT: constants {
  49. // CHECK:STDOUT: %type: type = facet_type <type> [concrete]
  50. // CHECK:STDOUT: %.Self: %type = symbolic_binding .Self [symbolic_self]
  51. // CHECK:STDOUT: %T: type = symbolic_binding T, 0 [symbolic]
  52. // CHECK:STDOUT: %pattern_type: type = pattern_type type [concrete]
  53. // CHECK:STDOUT: %C.type: type = generic_class_type @C [concrete]
  54. // CHECK:STDOUT: %C.generic: %C.type = struct_value () [concrete]
  55. // CHECK:STDOUT: %C: type = class_type @C, @C(%T) [symbolic]
  56. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  57. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  58. // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
  59. // CHECK:STDOUT: %Self: %I.type = symbolic_binding Self, 0 [symbolic]
  60. // CHECK:STDOUT: %I.WithSelf.F.type.08c: type = fn_type @I.WithSelf.F, @I(%Self) [symbolic]
  61. // CHECK:STDOUT: %I.WithSelf.F.705: %I.WithSelf.F.type.08c = struct_value () [symbolic]
  62. // CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type @I [concrete]
  63. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.%I.WithSelf.F.decl [concrete]
  64. // CHECK:STDOUT: %I.impl_witness: <witness> = impl_witness @C.as.I.impl.%I.impl_witness_table, @C.as.I.impl(%T) [symbolic]
  65. // CHECK:STDOUT: %C.as.I.impl.F.type: type = fn_type @C.as.I.impl.F, @C.as.I.impl(%T) [symbolic]
  66. // CHECK:STDOUT: %C.as.I.impl.F: %C.as.I.impl.F.type = struct_value () [symbolic]
  67. // CHECK:STDOUT: %I.facet: %I.type = facet_value %C, (%I.impl_witness) [symbolic]
  68. // CHECK:STDOUT: %I.WithSelf.F.type.c16: type = fn_type @I.WithSelf.F, @I(%I.facet) [symbolic]
  69. // CHECK:STDOUT: %I.WithSelf.F.708: %I.WithSelf.F.type.c16 = struct_value () [symbolic]
  70. // CHECK:STDOUT: }
  71. // CHECK:STDOUT:
  72. // CHECK:STDOUT: file {
  73. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  74. // CHECK:STDOUT: .C = %C.decl
  75. // CHECK:STDOUT: .I = %I.decl
  76. // CHECK:STDOUT: }
  77. // CHECK:STDOUT: %C.decl: %C.type = class_decl @C [concrete = constants.%C.generic] {
  78. // CHECK:STDOUT: %T.patt: %pattern_type = symbolic_binding_pattern T, 0 [concrete]
  79. // CHECK:STDOUT: } {
  80. // CHECK:STDOUT: %.Self: %type = symbolic_binding .Self [symbolic_self = constants.%.Self]
  81. // CHECK:STDOUT: %T.loc4_9.2: type = symbolic_binding T, 0 [symbolic = %T.loc4_9.1 (constants.%T)]
  82. // CHECK:STDOUT: }
  83. // CHECK:STDOUT: %I.decl: type = interface_decl @I [concrete = constants.%I.type] {} {}
  84. // CHECK:STDOUT: impl_decl @C.as.I.impl [concrete] {
  85. // CHECK:STDOUT: %T.patt: %pattern_type = symbolic_binding_pattern T, 0 [concrete]
  86. // CHECK:STDOUT: } {
  87. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, file.%C.decl [concrete = constants.%C.generic]
  88. // CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc10_14.2 [symbolic = %T.loc10_14.1 (constants.%T)]
  89. // CHECK:STDOUT: %C.loc10_27.2: type = class_type @C, @C(constants.%T) [symbolic = %C.loc10_27.1 (constants.%C)]
  90. // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [concrete = constants.%I.type]
  91. // CHECK:STDOUT: %.Self: %type = symbolic_binding .Self [symbolic_self = constants.%.Self]
  92. // CHECK:STDOUT: %T.loc10_14.2: type = symbolic_binding T, 0 [symbolic = %T.loc10_14.1 (constants.%T)]
  93. // CHECK:STDOUT: }
  94. // CHECK:STDOUT: }
  95. // CHECK:STDOUT:
  96. // CHECK:STDOUT: interface @I {
  97. // CHECK:STDOUT: %Self.loc6: %I.type = symbolic_binding Self, 0 [symbolic = constants.%Self]
  98. // CHECK:STDOUT: interface_with_self_decl @I [concrete]
  99. // CHECK:STDOUT:
  100. // CHECK:STDOUT: !with Self:
  101. // CHECK:STDOUT: %I.WithSelf.F.decl: @I.%I.WithSelf.F.type (%I.WithSelf.F.type.08c) = fn_decl @I.WithSelf.F [symbolic = @I.%I.WithSelf.F (constants.%I.WithSelf.F.705)] {} {}
  102. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, %I.WithSelf.F.decl [concrete = constants.%assoc0]
  103. // CHECK:STDOUT:
  104. // CHECK:STDOUT: !members:
  105. // CHECK:STDOUT: .Self = %Self.loc6
  106. // CHECK:STDOUT: .F = %assoc0
  107. // CHECK:STDOUT: witness = (%I.WithSelf.F.decl)
  108. // CHECK:STDOUT:
  109. // CHECK:STDOUT: !requires:
  110. // CHECK:STDOUT: }
  111. // CHECK:STDOUT:
  112. // CHECK:STDOUT: generic impl @C.as.I.impl(%T.loc10_14.2: type) {
  113. // CHECK:STDOUT: %T.loc10_14.1: type = symbolic_binding T, 0 [symbolic = %T.loc10_14.1 (constants.%T)]
  114. // CHECK:STDOUT: %C.loc10_27.1: type = class_type @C, @C(%T.loc10_14.1) [symbolic = %C.loc10_27.1 (constants.%C)]
  115. // CHECK:STDOUT: %I.impl_witness.loc10_34.2: <witness> = impl_witness %I.impl_witness_table, @C.as.I.impl(%T.loc10_14.1) [symbolic = %I.impl_witness.loc10_34.2 (constants.%I.impl_witness)]
  116. // CHECK:STDOUT:
  117. // CHECK:STDOUT: !definition:
  118. // CHECK:STDOUT: %C.as.I.impl.F.type: type = fn_type @C.as.I.impl.F, @C.as.I.impl(%T.loc10_14.1) [symbolic = %C.as.I.impl.F.type (constants.%C.as.I.impl.F.type)]
  119. // CHECK:STDOUT: %C.as.I.impl.F: @C.as.I.impl.%C.as.I.impl.F.type (%C.as.I.impl.F.type) = struct_value () [symbolic = %C.as.I.impl.F (constants.%C.as.I.impl.F)]
  120. // CHECK:STDOUT:
  121. // CHECK:STDOUT: impl: %C.loc10_27.2 as %I.ref {
  122. // CHECK:STDOUT: %C.as.I.impl.F.decl: @C.as.I.impl.%C.as.I.impl.F.type (%C.as.I.impl.F.type) = fn_decl @C.as.I.impl.F [symbolic = @C.as.I.impl.%C.as.I.impl.F (constants.%C.as.I.impl.F)] {} {}
  123. // CHECK:STDOUT: %I.impl_witness_table = impl_witness_table (%C.as.I.impl.F.decl), @C.as.I.impl [concrete]
  124. // CHECK:STDOUT: %I.impl_witness.loc10_34.1: <witness> = impl_witness %I.impl_witness_table, @C.as.I.impl(constants.%T) [symbolic = %I.impl_witness.loc10_34.2 (constants.%I.impl_witness)]
  125. // CHECK:STDOUT:
  126. // CHECK:STDOUT: !members:
  127. // CHECK:STDOUT: .F = %C.as.I.impl.F.decl
  128. // CHECK:STDOUT: witness = %I.impl_witness.loc10_34.1
  129. // CHECK:STDOUT: }
  130. // CHECK:STDOUT: }
  131. // CHECK:STDOUT:
  132. // CHECK:STDOUT: generic class @C(%T.loc4_9.2: type) {
  133. // CHECK:STDOUT: %T.loc4_9.1: type = symbolic_binding T, 0 [symbolic = %T.loc4_9.1 (constants.%T)]
  134. // CHECK:STDOUT:
  135. // CHECK:STDOUT: !definition:
  136. // CHECK:STDOUT:
  137. // CHECK:STDOUT: class {
  138. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type]
  139. // CHECK:STDOUT: complete_type_witness = %complete_type
  140. // CHECK:STDOUT:
  141. // CHECK:STDOUT: !members:
  142. // CHECK:STDOUT: .Self = constants.%C
  143. // CHECK:STDOUT: }
  144. // CHECK:STDOUT: }
  145. // CHECK:STDOUT:
  146. // CHECK:STDOUT: generic fn @I.WithSelf.F(@I.%Self.loc6: %I.type) {
  147. // CHECK:STDOUT: fn();
  148. // CHECK:STDOUT: }
  149. // CHECK:STDOUT:
  150. // CHECK:STDOUT: generic fn @C.as.I.impl.F(@C.as.I.impl.%T.loc10_14.2: type) {
  151. // CHECK:STDOUT: !definition:
  152. // CHECK:STDOUT:
  153. // CHECK:STDOUT: fn() {
  154. // CHECK:STDOUT: !entry:
  155. // CHECK:STDOUT: return
  156. // CHECK:STDOUT: }
  157. // CHECK:STDOUT: }
  158. // CHECK:STDOUT:
  159. // CHECK:STDOUT: specific @C(constants.%T) {
  160. // CHECK:STDOUT: %T.loc4_9.1 => constants.%T
  161. // CHECK:STDOUT: }
  162. // CHECK:STDOUT:
  163. // CHECK:STDOUT: specific @I(constants.%Self) {
  164. // CHECK:STDOUT: !definition:
  165. // CHECK:STDOUT: %Self.loc7 => constants.%Self
  166. // CHECK:STDOUT: %I.WithSelf.F.type => constants.%I.WithSelf.F.type.08c
  167. // CHECK:STDOUT: %I.WithSelf.F => constants.%I.WithSelf.F.705
  168. // CHECK:STDOUT: }
  169. // CHECK:STDOUT:
  170. // CHECK:STDOUT: specific @I.WithSelf.F(constants.%Self) {}
  171. // CHECK:STDOUT:
  172. // CHECK:STDOUT: specific @C.as.I.impl(constants.%T) {
  173. // CHECK:STDOUT: %T.loc10_14.1 => constants.%T
  174. // CHECK:STDOUT: %C.loc10_27.1 => constants.%C
  175. // CHECK:STDOUT: %I.impl_witness.loc10_34.2 => constants.%I.impl_witness
  176. // CHECK:STDOUT:
  177. // CHECK:STDOUT: !definition:
  178. // CHECK:STDOUT: %C.as.I.impl.F.type => constants.%C.as.I.impl.F.type
  179. // CHECK:STDOUT: %C.as.I.impl.F => constants.%C.as.I.impl.F
  180. // CHECK:STDOUT: }
  181. // CHECK:STDOUT:
  182. // CHECK:STDOUT: specific @C.as.I.impl.F(constants.%T) {}
  183. // CHECK:STDOUT:
  184. // CHECK:STDOUT: specific @I(constants.%I.facet) {
  185. // CHECK:STDOUT: !definition:
  186. // CHECK:STDOUT: %Self.loc7 => constants.%I.facet
  187. // CHECK:STDOUT: %I.WithSelf.F.type => constants.%I.WithSelf.F.type.c16
  188. // CHECK:STDOUT: %I.WithSelf.F => constants.%I.WithSelf.F.708
  189. // CHECK:STDOUT: }
  190. // CHECK:STDOUT:
  191. // CHECK:STDOUT: specific @I.WithSelf.F(constants.%I.facet) {}
  192. // CHECK:STDOUT:
  193. // CHECK:STDOUT: --- fail_use_in_fn_decl.carbon
  194. // CHECK:STDOUT:
  195. // CHECK:STDOUT: constants {
  196. // CHECK:STDOUT: %C.type: type = generic_class_type @C [concrete]
  197. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  198. // CHECK:STDOUT: %C.generic: %C.type = struct_value () [concrete]
  199. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  200. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  201. // CHECK:STDOUT: %T: type = symbolic_binding T, 0 [symbolic]
  202. // CHECK:STDOUT: %C.5a3: type = class_type @C, @C(%T) [symbolic]
  203. // CHECK:STDOUT: %empty_struct: %empty_struct_type = struct_value () [concrete]
  204. // CHECK:STDOUT: %C.850: type = class_type @C, @C(%empty_struct_type) [concrete]
  205. // CHECK:STDOUT: %pattern_type.526: type = pattern_type %C.850 [concrete]
  206. // CHECK:STDOUT: %C.val: %C.850 = struct_value () [concrete]
  207. // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
  208. // CHECK:STDOUT: %Self: %I.type = symbolic_binding Self, 0 [symbolic]
  209. // CHECK:STDOUT: %I.WithSelf.F.type.a1f: type = fn_type @I.WithSelf.F, @I(%Self) [symbolic]
  210. // CHECK:STDOUT: %I.WithSelf.F.cc3: %I.WithSelf.F.type.a1f = struct_value () [symbolic]
  211. // CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type @I [concrete]
  212. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, imports.%Main.import_ref.972 [concrete]
  213. // CHECK:STDOUT: %G.type: type = fn_type @G [concrete]
  214. // CHECK:STDOUT: %G: %G.type = struct_value () [concrete]
  215. // CHECK:STDOUT: %I.impl_witness.e33: <witness> = impl_witness imports.%I.impl_witness_table, @C.as.I.impl(%T) [symbolic]
  216. // CHECK:STDOUT: %C.as.I.impl.F.type.ec1: type = fn_type @C.as.I.impl.F, @C.as.I.impl(%T) [symbolic]
  217. // CHECK:STDOUT: %C.as.I.impl.F.983: %C.as.I.impl.F.type.ec1 = struct_value () [symbolic]
  218. // CHECK:STDOUT: %I.impl_witness.79b: <witness> = impl_witness imports.%I.impl_witness_table, @C.as.I.impl(%empty_struct_type) [concrete]
  219. // CHECK:STDOUT: %C.as.I.impl.F.type.b66: type = fn_type @C.as.I.impl.F, @C.as.I.impl(%empty_struct_type) [concrete]
  220. // CHECK:STDOUT: %C.as.I.impl.F.930: %C.as.I.impl.F.type.b66 = struct_value () [concrete]
  221. // CHECK:STDOUT: %I.facet: %I.type = facet_value %C.850, (%I.impl_witness.79b) [concrete]
  222. // CHECK:STDOUT: %I.WithSelf.F.type.ca6: type = fn_type @I.WithSelf.F, @I(%I.facet) [concrete]
  223. // CHECK:STDOUT: %I.WithSelf.F.ed7: %I.WithSelf.F.type.ca6 = struct_value () [concrete]
  224. // CHECK:STDOUT: %.864: type = fn_type_with_self_type %I.WithSelf.F.type.ca6, %I.facet [concrete]
  225. // CHECK:STDOUT: %C.as.I.impl.F.specific_fn: <specific function> = specific_function %C.as.I.impl.F.930, @C.as.I.impl.F(%empty_struct_type) [concrete]
  226. // CHECK:STDOUT: %H.type: type = fn_type @H [concrete]
  227. // CHECK:STDOUT: %H: %H.type = struct_value () [concrete]
  228. // CHECK:STDOUT: }
  229. // CHECK:STDOUT:
  230. // CHECK:STDOUT: imports {
  231. // CHECK:STDOUT: %Main.C: %C.type = import_ref Main//import_generic, C, loaded [concrete = constants.%C.generic]
  232. // CHECK:STDOUT: %Main.I: type = import_ref Main//import_generic, I, loaded [concrete = constants.%I.type]
  233. // CHECK:STDOUT: %Main.import_ref.8f2: <witness> = import_ref Main//import_generic, loc4_20, loaded [concrete = constants.%complete_type]
  234. // CHECK:STDOUT: %Main.import_ref.820 = import_ref Main//import_generic, inst{{[0-9A-F]+}} [no loc], unloaded
  235. // CHECK:STDOUT: %Main.import_ref.b3bc94.1: type = import_ref Main//import_generic, loc4_9, loaded [symbolic = @C.%T (constants.%T)]
  236. // CHECK:STDOUT: %Main.import_ref.a54: %I.assoc_type = import_ref Main//import_generic, loc7_9, loaded [concrete = constants.%assoc0]
  237. // CHECK:STDOUT: %Main.F = import_ref Main//import_generic, F, unloaded
  238. // CHECK:STDOUT: %Main.import_ref.2362f8.2: %I.type = import_ref Main//import_generic, loc6_13, loaded [symbolic = constants.%Self]
  239. // CHECK:STDOUT: %Main.import_ref.c82 = import_ref Main//import_generic, loc6_13, unloaded
  240. // CHECK:STDOUT: %Main.import_ref.972: @I.%I.WithSelf.F.type (%I.WithSelf.F.type.a1f) = import_ref Main//import_generic, loc7_9, loaded [symbolic = @I.%I.WithSelf.F (constants.%I.WithSelf.F.cc3)]
  241. // CHECK:STDOUT: %Main.import_ref.ce3: <witness> = import_ref Main//import_generic, loc10_34, loaded [symbolic = @C.as.I.impl.%I.impl_witness (constants.%I.impl_witness.e33)]
  242. // CHECK:STDOUT: %Main.import_ref.870: @C.as.I.impl.%C.as.I.impl.F.type (%C.as.I.impl.F.type.ec1) = import_ref Main//import_generic, loc11_10, loaded [symbolic = @C.as.I.impl.%C.as.I.impl.F (constants.%C.as.I.impl.F.983)]
  243. // CHECK:STDOUT: %I.impl_witness_table = impl_witness_table (%Main.import_ref.870), @C.as.I.impl [concrete]
  244. // CHECK:STDOUT: %Main.import_ref.b3bc94.2: type = import_ref Main//import_generic, loc10_14, loaded [symbolic = @C.as.I.impl.%T (constants.%T)]
  245. // CHECK:STDOUT: %Main.import_ref.c96: type = import_ref Main//import_generic, loc10_27, loaded [symbolic = @C.as.I.impl.%C (constants.%C.5a3)]
  246. // CHECK:STDOUT: %Main.import_ref.72a: type = import_ref Main//import_generic, loc10_32, loaded [concrete = constants.%I.type]
  247. // CHECK:STDOUT: %Main.import_ref.b3bc94.3: type = import_ref Main//import_generic, loc10_14, loaded [symbolic = @C.as.I.impl.%T (constants.%T)]
  248. // CHECK:STDOUT: }
  249. // CHECK:STDOUT:
  250. // CHECK:STDOUT: file {
  251. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  252. // CHECK:STDOUT: .C = imports.%Main.C
  253. // CHECK:STDOUT: .I = imports.%Main.I
  254. // CHECK:STDOUT: .c = %c
  255. // CHECK:STDOUT: .G = %G.decl
  256. // CHECK:STDOUT: .H = %H.decl
  257. // CHECK:STDOUT: }
  258. // CHECK:STDOUT: %default.import = import <none>
  259. // CHECK:STDOUT: name_binding_decl {
  260. // CHECK:STDOUT: %c.patt: %pattern_type.526 = ref_binding_pattern c [concrete]
  261. // CHECK:STDOUT: %c.var_patt: %pattern_type.526 = var_pattern %c.patt [concrete]
  262. // CHECK:STDOUT: }
  263. // CHECK:STDOUT: %c.var: ref %C.850 = var %c.var_patt [concrete]
  264. // CHECK:STDOUT: %.loc6_12.1: type = splice_block %C [concrete = constants.%C.850] {
  265. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, imports.%Main.C [concrete = constants.%C.generic]
  266. // CHECK:STDOUT: %.loc6_11: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct]
  267. // CHECK:STDOUT: %.loc6_12.2: type = converted %.loc6_11, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  268. // CHECK:STDOUT: %C: type = class_type @C, @C(constants.%empty_struct_type) [concrete = constants.%C.850]
  269. // CHECK:STDOUT: }
  270. // CHECK:STDOUT: %c: ref %C.850 = ref_binding c, %c.var [concrete = %c.var]
  271. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [concrete = constants.%G] {} {
  272. // CHECK:STDOUT: %c.ref: ref %C.850 = name_ref c, file.%c [concrete = file.%c.var]
  273. // CHECK:STDOUT: %I.ref: type = name_ref I, imports.%Main.I [concrete = constants.%I.type]
  274. // CHECK:STDOUT: %F.ref: %I.assoc_type = name_ref F, imports.%Main.import_ref.a54 [concrete = constants.%assoc0]
  275. // CHECK:STDOUT: %.loc16: %I.type = converted %c.ref, <error> [concrete = <error>]
  276. // CHECK:STDOUT: }
  277. // CHECK:STDOUT: %H.decl: %H.type = fn_decl @H [concrete = constants.%H] {} {
  278. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, imports.%Main.C [concrete = constants.%C.generic]
  279. // CHECK:STDOUT: %.loc25_14: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct]
  280. // CHECK:STDOUT: %.loc25_15: type = converted %.loc25_14, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  281. // CHECK:STDOUT: %C: type = class_type @C, @C(constants.%empty_struct_type) [concrete = constants.%C.850]
  282. // CHECK:STDOUT: %I.ref: type = name_ref I, imports.%Main.I [concrete = constants.%I.type]
  283. // CHECK:STDOUT: %F.ref: %I.assoc_type = name_ref F, imports.%Main.import_ref.a54 [concrete = constants.%assoc0]
  284. // CHECK:STDOUT: %I.facet: %I.type = facet_value %C, (constants.%I.impl_witness.79b) [concrete = constants.%I.facet]
  285. // CHECK:STDOUT: %.loc25_16: %I.type = converted %C, %I.facet [concrete = constants.%I.facet]
  286. // CHECK:STDOUT: %impl.elem0: %.864 = impl_witness_access constants.%I.impl_witness.79b, element0 [concrete = constants.%C.as.I.impl.F.930]
  287. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @C.as.I.impl.F(constants.%empty_struct_type) [concrete = constants.%C.as.I.impl.F.specific_fn]
  288. // CHECK:STDOUT: %C.as.I.impl.F.call: init %empty_tuple.type = call %specific_fn()
  289. // CHECK:STDOUT: %.loc25_23: type = converted %C.as.I.impl.F.call, <error> [concrete = <error>]
  290. // CHECK:STDOUT: }
  291. // CHECK:STDOUT: }
  292. // CHECK:STDOUT:
  293. // CHECK:STDOUT: interface @I [from "import_generic.carbon"] {
  294. // CHECK:STDOUT: !members:
  295. // CHECK:STDOUT: .Self = imports.%Main.import_ref.c82
  296. // CHECK:STDOUT: .F = imports.%Main.import_ref.a54
  297. // CHECK:STDOUT: witness = (imports.%Main.F)
  298. // CHECK:STDOUT:
  299. // CHECK:STDOUT: !requires:
  300. // CHECK:STDOUT: }
  301. // CHECK:STDOUT:
  302. // CHECK:STDOUT: generic impl @C.as.I.impl(imports.%Main.import_ref.b3bc94.3: type) [from "import_generic.carbon"] {
  303. // CHECK:STDOUT: %T: type = symbolic_binding T, 0 [symbolic = %T (constants.%T)]
  304. // CHECK:STDOUT: %C: type = class_type @C, @C(%T) [symbolic = %C (constants.%C.5a3)]
  305. // CHECK:STDOUT: %I.impl_witness: <witness> = impl_witness imports.%I.impl_witness_table, @C.as.I.impl(%T) [symbolic = %I.impl_witness (constants.%I.impl_witness.e33)]
  306. // CHECK:STDOUT:
  307. // CHECK:STDOUT: !definition:
  308. // CHECK:STDOUT: %C.as.I.impl.F.type: type = fn_type @C.as.I.impl.F, @C.as.I.impl(%T) [symbolic = %C.as.I.impl.F.type (constants.%C.as.I.impl.F.type.ec1)]
  309. // CHECK:STDOUT: %C.as.I.impl.F: @C.as.I.impl.%C.as.I.impl.F.type (%C.as.I.impl.F.type.ec1) = struct_value () [symbolic = %C.as.I.impl.F (constants.%C.as.I.impl.F.983)]
  310. // CHECK:STDOUT:
  311. // CHECK:STDOUT: impl: imports.%Main.import_ref.c96 as imports.%Main.import_ref.72a {
  312. // CHECK:STDOUT: !members:
  313. // CHECK:STDOUT: witness = imports.%Main.import_ref.ce3
  314. // CHECK:STDOUT: }
  315. // CHECK:STDOUT: }
  316. // CHECK:STDOUT:
  317. // CHECK:STDOUT: generic class @C(imports.%Main.import_ref.b3bc94.1: type) [from "import_generic.carbon"] {
  318. // CHECK:STDOUT: %T: type = symbolic_binding T, 0 [symbolic = %T (constants.%T)]
  319. // CHECK:STDOUT:
  320. // CHECK:STDOUT: !definition:
  321. // CHECK:STDOUT:
  322. // CHECK:STDOUT: class {
  323. // CHECK:STDOUT: complete_type_witness = imports.%Main.import_ref.8f2
  324. // CHECK:STDOUT:
  325. // CHECK:STDOUT: !members:
  326. // CHECK:STDOUT: .Self = imports.%Main.import_ref.820
  327. // CHECK:STDOUT: }
  328. // CHECK:STDOUT: }
  329. // CHECK:STDOUT:
  330. // CHECK:STDOUT: generic fn @I.WithSelf.F(imports.%Main.import_ref.2362f8.2: %I.type) [from "import_generic.carbon"] {
  331. // CHECK:STDOUT: fn;
  332. // CHECK:STDOUT: }
  333. // CHECK:STDOUT:
  334. // CHECK:STDOUT: fn @G() -> <error> {
  335. // CHECK:STDOUT: !entry:
  336. // CHECK:STDOUT: }
  337. // CHECK:STDOUT:
  338. // CHECK:STDOUT: generic fn @C.as.I.impl.F(imports.%Main.import_ref.b3bc94.2: type) [from "import_generic.carbon"] {
  339. // CHECK:STDOUT: !definition:
  340. // CHECK:STDOUT:
  341. // CHECK:STDOUT: fn;
  342. // CHECK:STDOUT: }
  343. // CHECK:STDOUT:
  344. // CHECK:STDOUT: fn @H() -> <error> {
  345. // CHECK:STDOUT: !entry:
  346. // CHECK:STDOUT: }
  347. // CHECK:STDOUT:
  348. // CHECK:STDOUT: fn @__global_init() {
  349. // CHECK:STDOUT: !entry:
  350. // CHECK:STDOUT: %.loc6_17.1: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct]
  351. // CHECK:STDOUT: %.loc6_17.2: init %C.850 to file.%c.var = class_init () [concrete = constants.%C.val]
  352. // CHECK:STDOUT: %.loc6_1: init %C.850 = converted %.loc6_17.1, %.loc6_17.2 [concrete = constants.%C.val]
  353. // CHECK:STDOUT: assign file.%c.var, %.loc6_1
  354. // CHECK:STDOUT: return
  355. // CHECK:STDOUT: }
  356. // CHECK:STDOUT:
  357. // CHECK:STDOUT: specific @C(constants.%T) {
  358. // CHECK:STDOUT: %T => constants.%T
  359. // CHECK:STDOUT: }
  360. // CHECK:STDOUT:
  361. // CHECK:STDOUT: specific @C(constants.%empty_struct_type) {
  362. // CHECK:STDOUT: %T => constants.%empty_struct_type
  363. // CHECK:STDOUT:
  364. // CHECK:STDOUT: !definition:
  365. // CHECK:STDOUT: }
  366. // CHECK:STDOUT:
  367. // CHECK:STDOUT: specific @I(constants.%Self) {
  368. // CHECK:STDOUT: !definition:
  369. // CHECK:STDOUT: %Self => constants.%Self
  370. // CHECK:STDOUT: %I.WithSelf.F.type => constants.%I.WithSelf.F.type.a1f
  371. // CHECK:STDOUT: %I.WithSelf.F => constants.%I.WithSelf.F.cc3
  372. // CHECK:STDOUT: }
  373. // CHECK:STDOUT:
  374. // CHECK:STDOUT: specific @I.WithSelf.F(constants.%Self) {}
  375. // CHECK:STDOUT:
  376. // CHECK:STDOUT: specific @C.as.I.impl(constants.%T) {
  377. // CHECK:STDOUT: %T => constants.%T
  378. // CHECK:STDOUT: %C => constants.%C.5a3
  379. // CHECK:STDOUT: %I.impl_witness => constants.%I.impl_witness.e33
  380. // CHECK:STDOUT:
  381. // CHECK:STDOUT: !definition:
  382. // CHECK:STDOUT: %C.as.I.impl.F.type => constants.%C.as.I.impl.F.type.ec1
  383. // CHECK:STDOUT: %C.as.I.impl.F => constants.%C.as.I.impl.F.983
  384. // CHECK:STDOUT: }
  385. // CHECK:STDOUT:
  386. // CHECK:STDOUT: specific @C.as.I.impl.F(constants.%T) {}
  387. // CHECK:STDOUT:
  388. // CHECK:STDOUT: specific @C.as.I.impl(constants.%empty_struct_type) {
  389. // CHECK:STDOUT: %T => constants.%empty_struct_type
  390. // CHECK:STDOUT: %C => constants.%C.850
  391. // CHECK:STDOUT: %I.impl_witness => constants.%I.impl_witness.79b
  392. // CHECK:STDOUT:
  393. // CHECK:STDOUT: !definition:
  394. // CHECK:STDOUT: %C.as.I.impl.F.type => constants.%C.as.I.impl.F.type.b66
  395. // CHECK:STDOUT: %C.as.I.impl.F => constants.%C.as.I.impl.F.930
  396. // CHECK:STDOUT: }
  397. // CHECK:STDOUT:
  398. // CHECK:STDOUT: specific @I(constants.%I.facet) {
  399. // CHECK:STDOUT: !definition:
  400. // CHECK:STDOUT: %Self => constants.%I.facet
  401. // CHECK:STDOUT: %I.WithSelf.F.type => constants.%I.WithSelf.F.type.ca6
  402. // CHECK:STDOUT: %I.WithSelf.F => constants.%I.WithSelf.F.ed7
  403. // CHECK:STDOUT: }
  404. // CHECK:STDOUT:
  405. // CHECK:STDOUT: specific @C.as.I.impl.F(constants.%empty_struct_type) {
  406. // CHECK:STDOUT: !definition:
  407. // CHECK:STDOUT: }
  408. // CHECK:STDOUT: