stringify.carbon 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // AUTOUPDATE
  6. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/class/generic/stringify.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/generic/stringify.carbon
  10. // --- fail_empty_params.carbon
  11. library "[[@TEST_NAME]]";
  12. class NoParams {}
  13. class EmptyParams() {}
  14. var v: NoParams;
  15. // CHECK:STDERR: fail_empty_params.carbon:[[@LINE+7]]:1: error: cannot implicitly convert from `NoParams` to `EmptyParams()` [ImplicitAsConversionFailure]
  16. // CHECK:STDERR: var w: EmptyParams() = v;
  17. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~
  18. // CHECK:STDERR: fail_empty_params.carbon:[[@LINE+4]]:1: note: type `NoParams` does not implement interface `ImplicitAs(EmptyParams())` [MissingImplInMemberAccessNote]
  19. // CHECK:STDERR: var w: EmptyParams() = v;
  20. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~
  21. // CHECK:STDERR:
  22. var w: EmptyParams() = v;
  23. // --- fail_nested.carbon
  24. library "[[@TEST_NAME]]";
  25. class Outer(T:! type) {
  26. class Inner(U:! type) {
  27. }
  28. }
  29. var v: Outer({}*);
  30. // TODO: It would be nice to include the `Outer({}*).` prefix in the name of `Inner`.
  31. // CHECK:STDERR: fail_nested.carbon:[[@LINE+6]]:1: error: cannot implicitly convert from `Outer({}*)` to `Inner({.a: i32}*)` [ImplicitAsConversionFailure]
  32. // CHECK:STDERR: var w: Outer({}*).Inner({.a: i32}*) = v;
  33. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  34. // CHECK:STDERR: fail_nested.carbon:[[@LINE+3]]:1: note: type `Outer({}*)` does not implement interface `ImplicitAs(Inner({.a: i32}*))` [MissingImplInMemberAccessNote]
  35. // CHECK:STDERR: var w: Outer({}*).Inner({.a: i32}*) = v;
  36. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  37. var w: Outer({}*).Inner({.a: i32}*) = v;
  38. // CHECK:STDOUT: --- fail_empty_params.carbon
  39. // CHECK:STDOUT:
  40. // CHECK:STDOUT: constants {
  41. // CHECK:STDOUT: %NoParams: type = class_type @NoParams [template]
  42. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  43. // CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
  44. // CHECK:STDOUT: %EmptyParams.type: type = generic_class_type @EmptyParams [template]
  45. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  46. // CHECK:STDOUT: %EmptyParams.1: %EmptyParams.type = struct_value () [template]
  47. // CHECK:STDOUT: %EmptyParams.2: type = class_type @EmptyParams [template]
  48. // CHECK:STDOUT: %.3: type = ptr_type %.1 [template]
  49. // CHECK:STDOUT: %ImplicitAs.type.1: type = generic_interface_type @ImplicitAs [template]
  50. // CHECK:STDOUT: %ImplicitAs: %ImplicitAs.type.1 = struct_value () [template]
  51. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic]
  52. // CHECK:STDOUT: %ImplicitAs.type.2: type = facet_type <@ImplicitAs, @ImplicitAs(%Dest)> [symbolic]
  53. // CHECK:STDOUT: %Self.1: @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2) = bind_symbolic_name Self, 1 [symbolic]
  54. // CHECK:STDOUT: %Dest.patt: type = symbolic_binding_pattern Dest, 0 [symbolic]
  55. // CHECK:STDOUT: %Self.2: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic]
  56. // CHECK:STDOUT: %Convert.type.1: type = fn_type @Convert, @ImplicitAs(%Dest) [symbolic]
  57. // CHECK:STDOUT: %Convert.1: %Convert.type.1 = struct_value () [symbolic]
  58. // CHECK:STDOUT: %.4: type = assoc_entity_type %ImplicitAs.type.2, %Convert.type.1 [symbolic]
  59. // CHECK:STDOUT: %.5: %.4 = assoc_entity element0, imports.%import_ref.5 [symbolic]
  60. // CHECK:STDOUT: %ImplicitAs.type.3: type = facet_type <@ImplicitAs, @ImplicitAs(%EmptyParams.2)> [template]
  61. // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert, @ImplicitAs(%EmptyParams.2) [template]
  62. // CHECK:STDOUT: %Convert.2: %Convert.type.2 = struct_value () [template]
  63. // CHECK:STDOUT: %.6: type = assoc_entity_type %ImplicitAs.type.3, %Convert.type.2 [template]
  64. // CHECK:STDOUT: %.7: %.6 = assoc_entity element0, imports.%import_ref.5 [template]
  65. // CHECK:STDOUT: %.8: %.4 = assoc_entity element0, imports.%import_ref.6 [symbolic]
  66. // CHECK:STDOUT: }
  67. // CHECK:STDOUT:
  68. // CHECK:STDOUT: imports {
  69. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  70. // CHECK:STDOUT: .ImplicitAs = %import_ref.1
  71. // CHECK:STDOUT: import Core//prelude
  72. // CHECK:STDOUT: import Core//prelude/...
  73. // CHECK:STDOUT: }
  74. // CHECK:STDOUT: %import_ref.1: %ImplicitAs.type.1 = import_ref Core//prelude/operators/as, inst+48, loaded [template = constants.%ImplicitAs]
  75. // CHECK:STDOUT: %import_ref.2 = import_ref Core//prelude/operators/as, inst+54, unloaded
  76. // CHECK:STDOUT: %import_ref.3: @ImplicitAs.%.1 (%.4) = import_ref Core//prelude/operators/as, inst+76, loaded [symbolic = @ImplicitAs.%.2 (constants.%.8)]
  77. // CHECK:STDOUT: %import_ref.4 = import_ref Core//prelude/operators/as, inst+69, unloaded
  78. // CHECK:STDOUT: %import_ref.5 = import_ref Core//prelude/operators/as, inst+69, unloaded
  79. // CHECK:STDOUT: %import_ref.6 = import_ref Core//prelude/operators/as, inst+69, unloaded
  80. // CHECK:STDOUT: }
  81. // CHECK:STDOUT:
  82. // CHECK:STDOUT: file {
  83. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  84. // CHECK:STDOUT: .Core = imports.%Core
  85. // CHECK:STDOUT: .NoParams = %NoParams.decl
  86. // CHECK:STDOUT: .EmptyParams = %EmptyParams.decl
  87. // CHECK:STDOUT: .v = %v
  88. // CHECK:STDOUT: .w = %w
  89. // CHECK:STDOUT: }
  90. // CHECK:STDOUT: %Core.import = import Core
  91. // CHECK:STDOUT: %NoParams.decl: type = class_decl @NoParams [template = constants.%NoParams] {} {}
  92. // CHECK:STDOUT: %EmptyParams.decl: %EmptyParams.type = class_decl @EmptyParams [template = constants.%EmptyParams.1] {} {}
  93. // CHECK:STDOUT: %NoParams.ref: type = name_ref NoParams, %NoParams.decl [template = constants.%NoParams]
  94. // CHECK:STDOUT: %v.var: ref %NoParams = var v
  95. // CHECK:STDOUT: %v: ref %NoParams = bind_name v, %v.var
  96. // CHECK:STDOUT: %EmptyParams.ref: %EmptyParams.type = name_ref EmptyParams, %EmptyParams.decl [template = constants.%EmptyParams.1]
  97. // CHECK:STDOUT: %EmptyParams: type = class_type @EmptyParams [template = constants.%EmptyParams.2]
  98. // CHECK:STDOUT: %w.var: ref %EmptyParams.2 = var w
  99. // CHECK:STDOUT: %w: ref %EmptyParams.2 = bind_name w, %w.var
  100. // CHECK:STDOUT: }
  101. // CHECK:STDOUT:
  102. // CHECK:STDOUT: generic interface @ImplicitAs(constants.%Dest: type) {
  103. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic = %Dest (constants.%Dest)]
  104. // CHECK:STDOUT: %Dest.patt: type = symbolic_binding_pattern Dest, 0 [symbolic = %Dest.patt (constants.%Dest.patt)]
  105. // CHECK:STDOUT:
  106. // CHECK:STDOUT: !definition:
  107. // CHECK:STDOUT: %ImplicitAs.type: type = facet_type <@ImplicitAs, @ImplicitAs(%Dest)> [symbolic = %ImplicitAs.type (constants.%ImplicitAs.type.2)]
  108. // CHECK:STDOUT: %Self: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.2)]
  109. // CHECK:STDOUT: %Convert.type: type = fn_type @Convert, @ImplicitAs(%Dest) [symbolic = %Convert.type (constants.%Convert.type.1)]
  110. // CHECK:STDOUT: %Convert: @ImplicitAs.%Convert.type (%Convert.type.1) = struct_value () [symbolic = %Convert (constants.%Convert.1)]
  111. // CHECK:STDOUT: %.1: type = assoc_entity_type @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2), @ImplicitAs.%Convert.type (%Convert.type.1) [symbolic = %.1 (constants.%.4)]
  112. // CHECK:STDOUT: %.2: @ImplicitAs.%.1 (%.4) = assoc_entity element0, imports.%import_ref.5 [symbolic = %.2 (constants.%.5)]
  113. // CHECK:STDOUT:
  114. // CHECK:STDOUT: interface {
  115. // CHECK:STDOUT: !members:
  116. // CHECK:STDOUT: .Self = imports.%import_ref.2
  117. // CHECK:STDOUT: .Convert = imports.%import_ref.3
  118. // CHECK:STDOUT: witness = (imports.%import_ref.4)
  119. // CHECK:STDOUT: }
  120. // CHECK:STDOUT: }
  121. // CHECK:STDOUT:
  122. // CHECK:STDOUT: class @NoParams {
  123. // CHECK:STDOUT: %.loc4: <witness> = complete_type_witness %.1 [template = constants.%.2]
  124. // CHECK:STDOUT:
  125. // CHECK:STDOUT: !members:
  126. // CHECK:STDOUT: .Self = constants.%NoParams
  127. // CHECK:STDOUT: }
  128. // CHECK:STDOUT:
  129. // CHECK:STDOUT: class @EmptyParams {
  130. // CHECK:STDOUT: %.loc5: <witness> = complete_type_witness %.1 [template = constants.%.2]
  131. // CHECK:STDOUT:
  132. // CHECK:STDOUT: !members:
  133. // CHECK:STDOUT: .Self = constants.%EmptyParams.2
  134. // CHECK:STDOUT: }
  135. // CHECK:STDOUT:
  136. // CHECK:STDOUT: generic fn @Convert(constants.%Dest: type, constants.%Self.1: @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2)) {
  137. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic = %Dest (constants.%Dest)]
  138. // CHECK:STDOUT: %ImplicitAs.type: type = facet_type <@ImplicitAs, @ImplicitAs(%Dest)> [symbolic = %ImplicitAs.type (constants.%ImplicitAs.type.2)]
  139. // CHECK:STDOUT: %Self: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.2)]
  140. // CHECK:STDOUT:
  141. // CHECK:STDOUT: fn[%self.param_patt: @Convert.%Self (%Self.2)]() -> @Convert.%Dest (%Dest);
  142. // CHECK:STDOUT: }
  143. // CHECK:STDOUT:
  144. // CHECK:STDOUT: fn @__global_init() {
  145. // CHECK:STDOUT: !entry:
  146. // CHECK:STDOUT: %v.ref: ref %NoParams = name_ref v, file.%v
  147. // CHECK:STDOUT: %.loc15: %EmptyParams.2 = converted %v.ref, <error> [template = <error>]
  148. // CHECK:STDOUT: assign file.%w.var, <error>
  149. // CHECK:STDOUT: return
  150. // CHECK:STDOUT: }
  151. // CHECK:STDOUT:
  152. // CHECK:STDOUT: specific @ImplicitAs(constants.%Dest) {
  153. // CHECK:STDOUT: %Dest => constants.%Dest
  154. // CHECK:STDOUT: %Dest.patt => constants.%Dest
  155. // CHECK:STDOUT: }
  156. // CHECK:STDOUT:
  157. // CHECK:STDOUT: specific @ImplicitAs(@ImplicitAs.%Dest) {
  158. // CHECK:STDOUT: %Dest => constants.%Dest
  159. // CHECK:STDOUT: %Dest.patt => constants.%Dest
  160. // CHECK:STDOUT: }
  161. // CHECK:STDOUT:
  162. // CHECK:STDOUT: specific @ImplicitAs(@Convert.%Dest) {
  163. // CHECK:STDOUT: %Dest => constants.%Dest
  164. // CHECK:STDOUT: %Dest.patt => constants.%Dest
  165. // CHECK:STDOUT: }
  166. // CHECK:STDOUT:
  167. // CHECK:STDOUT: specific @Convert(constants.%Dest, constants.%Self.1) {
  168. // CHECK:STDOUT: %Dest => constants.%Dest
  169. // CHECK:STDOUT: %ImplicitAs.type => constants.%ImplicitAs.type.2
  170. // CHECK:STDOUT: %Self => constants.%Self.1
  171. // CHECK:STDOUT: }
  172. // CHECK:STDOUT:
  173. // CHECK:STDOUT: specific @ImplicitAs(constants.%EmptyParams.2) {
  174. // CHECK:STDOUT: %Dest => constants.%EmptyParams.2
  175. // CHECK:STDOUT: %Dest.patt => constants.%EmptyParams.2
  176. // CHECK:STDOUT:
  177. // CHECK:STDOUT: !definition:
  178. // CHECK:STDOUT: %ImplicitAs.type => constants.%ImplicitAs.type.3
  179. // CHECK:STDOUT: %Self => constants.%Self.2
  180. // CHECK:STDOUT: %Convert.type => constants.%Convert.type.2
  181. // CHECK:STDOUT: %Convert => constants.%Convert.2
  182. // CHECK:STDOUT: %.1 => constants.%.6
  183. // CHECK:STDOUT: %.2 => constants.%.7
  184. // CHECK:STDOUT: }
  185. // CHECK:STDOUT:
  186. // CHECK:STDOUT: --- fail_nested.carbon
  187. // CHECK:STDOUT:
  188. // CHECK:STDOUT: constants {
  189. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  190. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
  191. // CHECK:STDOUT: %Outer.type: type = generic_class_type @Outer [template]
  192. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  193. // CHECK:STDOUT: %Outer.1: %Outer.type = struct_value () [template]
  194. // CHECK:STDOUT: %Outer.2: type = class_type @Outer, @Outer(%T) [symbolic]
  195. // CHECK:STDOUT: %U: type = bind_symbolic_name U, 1 [symbolic]
  196. // CHECK:STDOUT: %U.patt: type = symbolic_binding_pattern U, 1 [symbolic]
  197. // CHECK:STDOUT: %Inner.type.1: type = generic_class_type @Inner, @Outer(%T) [symbolic]
  198. // CHECK:STDOUT: %Inner.1: %Inner.type.1 = struct_value () [symbolic]
  199. // CHECK:STDOUT: %Inner.2: type = class_type @Inner, @Inner(%T, %U) [symbolic]
  200. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  201. // CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
  202. // CHECK:STDOUT: %.3: type = ptr_type %.1 [template]
  203. // CHECK:STDOUT: %Outer.3: type = class_type @Outer, @Outer(%.3) [template]
  204. // CHECK:STDOUT: %Inner.type.2: type = generic_class_type @Inner, @Outer(%.3) [template]
  205. // CHECK:STDOUT: %Inner.3: %Inner.type.2 = struct_value () [template]
  206. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  207. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  208. // CHECK:STDOUT: %.4: type = struct_type {.a: i32} [template]
  209. // CHECK:STDOUT: %.5: type = ptr_type %.4 [template]
  210. // CHECK:STDOUT: %Inner.4: type = class_type @Inner, @Inner(%.3, %.5) [template]
  211. // CHECK:STDOUT: %ImplicitAs.type.1: type = generic_interface_type @ImplicitAs [template]
  212. // CHECK:STDOUT: %ImplicitAs: %ImplicitAs.type.1 = struct_value () [template]
  213. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic]
  214. // CHECK:STDOUT: %ImplicitAs.type.2: type = facet_type <@ImplicitAs, @ImplicitAs(%Dest)> [symbolic]
  215. // CHECK:STDOUT: %Self.1: @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2) = bind_symbolic_name Self, 1 [symbolic]
  216. // CHECK:STDOUT: %Dest.patt: type = symbolic_binding_pattern Dest, 0 [symbolic]
  217. // CHECK:STDOUT: %Self.2: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic]
  218. // CHECK:STDOUT: %Convert.type.1: type = fn_type @Convert, @ImplicitAs(%Dest) [symbolic]
  219. // CHECK:STDOUT: %Convert.1: %Convert.type.1 = struct_value () [symbolic]
  220. // CHECK:STDOUT: %.6: type = assoc_entity_type %ImplicitAs.type.2, %Convert.type.1 [symbolic]
  221. // CHECK:STDOUT: %.7: %.6 = assoc_entity element0, imports.%import_ref.6 [symbolic]
  222. // CHECK:STDOUT: %ImplicitAs.type.3: type = facet_type <@ImplicitAs, @ImplicitAs(%Inner.4)> [template]
  223. // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert, @ImplicitAs(%Inner.4) [template]
  224. // CHECK:STDOUT: %Convert.2: %Convert.type.2 = struct_value () [template]
  225. // CHECK:STDOUT: %.8: type = assoc_entity_type %ImplicitAs.type.3, %Convert.type.2 [template]
  226. // CHECK:STDOUT: %.9: %.8 = assoc_entity element0, imports.%import_ref.6 [template]
  227. // CHECK:STDOUT: %.10: %.6 = assoc_entity element0, imports.%import_ref.7 [symbolic]
  228. // CHECK:STDOUT: }
  229. // CHECK:STDOUT:
  230. // CHECK:STDOUT: imports {
  231. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  232. // CHECK:STDOUT: .Int32 = %import_ref.1
  233. // CHECK:STDOUT: .ImplicitAs = %import_ref.2
  234. // CHECK:STDOUT: import Core//prelude
  235. // CHECK:STDOUT: import Core//prelude/...
  236. // CHECK:STDOUT: }
  237. // CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//prelude/types, inst+15, loaded [template = constants.%Int32]
  238. // CHECK:STDOUT: %import_ref.2: %ImplicitAs.type.1 = import_ref Core//prelude/operators/as, inst+48, loaded [template = constants.%ImplicitAs]
  239. // CHECK:STDOUT: %import_ref.3 = import_ref Core//prelude/operators/as, inst+54, unloaded
  240. // CHECK:STDOUT: %import_ref.4: @ImplicitAs.%.1 (%.6) = import_ref Core//prelude/operators/as, inst+76, loaded [symbolic = @ImplicitAs.%.2 (constants.%.10)]
  241. // CHECK:STDOUT: %import_ref.5 = import_ref Core//prelude/operators/as, inst+69, unloaded
  242. // CHECK:STDOUT: %import_ref.6 = import_ref Core//prelude/operators/as, inst+69, unloaded
  243. // CHECK:STDOUT: %import_ref.7 = import_ref Core//prelude/operators/as, inst+69, unloaded
  244. // CHECK:STDOUT: }
  245. // CHECK:STDOUT:
  246. // CHECK:STDOUT: file {
  247. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  248. // CHECK:STDOUT: .Core = imports.%Core
  249. // CHECK:STDOUT: .Outer = %Outer.decl
  250. // CHECK:STDOUT: .v = %v
  251. // CHECK:STDOUT: .w = %w
  252. // CHECK:STDOUT: }
  253. // CHECK:STDOUT: %Core.import = import Core
  254. // CHECK:STDOUT: %Outer.decl: %Outer.type = class_decl @Outer [template = constants.%Outer.1] {
  255. // CHECK:STDOUT: %T.patt.loc4_13.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc4_13.2 (constants.%T.patt)]
  256. // CHECK:STDOUT: %T.param_patt: type = value_param_pattern %T.patt.loc4_13.1, runtime_param<invalid> [symbolic = %T.patt.loc4_13.2 (constants.%T.patt)]
  257. // CHECK:STDOUT: } {
  258. // CHECK:STDOUT: %T.param: type = value_param runtime_param<invalid>
  259. // CHECK:STDOUT: %T.loc4_13.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc4_13.2 (constants.%T)]
  260. // CHECK:STDOUT: }
  261. // CHECK:STDOUT: %Outer.ref.loc9: %Outer.type = name_ref Outer, %Outer.decl [template = constants.%Outer.1]
  262. // CHECK:STDOUT: %.loc9_15: %.1 = struct_literal ()
  263. // CHECK:STDOUT: %.loc9_16.1: type = converted %.loc9_15, constants.%.1 [template = constants.%.1]
  264. // CHECK:STDOUT: %.loc9_16.2: type = ptr_type %.1 [template = constants.%.3]
  265. // CHECK:STDOUT: %Outer.loc9: type = class_type @Outer, @Outer(constants.%.3) [template = constants.%Outer.3]
  266. // CHECK:STDOUT: %v.var: ref %Outer.3 = var v
  267. // CHECK:STDOUT: %v: ref %Outer.3 = bind_name v, %v.var
  268. // CHECK:STDOUT: %Outer.ref.loc18: %Outer.type = name_ref Outer, %Outer.decl [template = constants.%Outer.1]
  269. // CHECK:STDOUT: %.loc18_15: %.1 = struct_literal ()
  270. // CHECK:STDOUT: %.loc18_16.1: type = converted %.loc18_15, constants.%.1 [template = constants.%.1]
  271. // CHECK:STDOUT: %.loc18_16.2: type = ptr_type %.1 [template = constants.%.3]
  272. // CHECK:STDOUT: %Outer.loc18: type = class_type @Outer, @Outer(constants.%.3) [template = constants.%Outer.3]
  273. // CHECK:STDOUT: %.loc18_18: %Inner.type.2 = specific_constant @Outer.%Inner.decl, @Outer(constants.%.3) [template = constants.%Inner.3]
  274. // CHECK:STDOUT: %Inner.ref: %Inner.type.2 = name_ref Inner, %.loc18_18 [template = constants.%Inner.3]
  275. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  276. // CHECK:STDOUT: %.loc18_30.1: type = value_of_initializer %int.make_type_32 [template = i32]
  277. // CHECK:STDOUT: %.loc18_30.2: type = converted %int.make_type_32, %.loc18_30.1 [template = i32]
  278. // CHECK:STDOUT: %.loc18_33: type = struct_type {.a: i32} [template = constants.%.4]
  279. // CHECK:STDOUT: %.loc18_34: type = ptr_type %.4 [template = constants.%.5]
  280. // CHECK:STDOUT: %Inner: type = class_type @Inner, @Inner(constants.%.3, constants.%.5) [template = constants.%Inner.4]
  281. // CHECK:STDOUT: %w.var: ref %Inner.4 = var w
  282. // CHECK:STDOUT: %w: ref %Inner.4 = bind_name w, %w.var
  283. // CHECK:STDOUT: }
  284. // CHECK:STDOUT:
  285. // CHECK:STDOUT: generic interface @ImplicitAs(constants.%Dest: type) {
  286. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic = %Dest (constants.%Dest)]
  287. // CHECK:STDOUT: %Dest.patt: type = symbolic_binding_pattern Dest, 0 [symbolic = %Dest.patt (constants.%Dest.patt)]
  288. // CHECK:STDOUT:
  289. // CHECK:STDOUT: !definition:
  290. // CHECK:STDOUT: %ImplicitAs.type: type = facet_type <@ImplicitAs, @ImplicitAs(%Dest)> [symbolic = %ImplicitAs.type (constants.%ImplicitAs.type.2)]
  291. // CHECK:STDOUT: %Self: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.2)]
  292. // CHECK:STDOUT: %Convert.type: type = fn_type @Convert, @ImplicitAs(%Dest) [symbolic = %Convert.type (constants.%Convert.type.1)]
  293. // CHECK:STDOUT: %Convert: @ImplicitAs.%Convert.type (%Convert.type.1) = struct_value () [symbolic = %Convert (constants.%Convert.1)]
  294. // CHECK:STDOUT: %.1: type = assoc_entity_type @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2), @ImplicitAs.%Convert.type (%Convert.type.1) [symbolic = %.1 (constants.%.6)]
  295. // CHECK:STDOUT: %.2: @ImplicitAs.%.1 (%.6) = assoc_entity element0, imports.%import_ref.6 [symbolic = %.2 (constants.%.7)]
  296. // CHECK:STDOUT:
  297. // CHECK:STDOUT: interface {
  298. // CHECK:STDOUT: !members:
  299. // CHECK:STDOUT: .Self = imports.%import_ref.3
  300. // CHECK:STDOUT: .Convert = imports.%import_ref.4
  301. // CHECK:STDOUT: witness = (imports.%import_ref.5)
  302. // CHECK:STDOUT: }
  303. // CHECK:STDOUT: }
  304. // CHECK:STDOUT:
  305. // CHECK:STDOUT: generic class @Outer(%T.loc4_13.1: type) {
  306. // CHECK:STDOUT: %T.loc4_13.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc4_13.2 (constants.%T)]
  307. // CHECK:STDOUT: %T.patt.loc4_13.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc4_13.2 (constants.%T.patt)]
  308. // CHECK:STDOUT:
  309. // CHECK:STDOUT: !definition:
  310. // CHECK:STDOUT: %Inner.type: type = generic_class_type @Inner, @Outer(%T.loc4_13.2) [symbolic = %Inner.type (constants.%Inner.type.1)]
  311. // CHECK:STDOUT: %Inner: @Outer.%Inner.type (%Inner.type.1) = struct_value () [symbolic = %Inner (constants.%Inner.1)]
  312. // CHECK:STDOUT:
  313. // CHECK:STDOUT: class {
  314. // CHECK:STDOUT: %Inner.decl: @Outer.%Inner.type (%Inner.type.1) = class_decl @Inner [symbolic = @Outer.%Inner (constants.%Inner.1)] {
  315. // CHECK:STDOUT: %U.patt.loc5_15.1: type = symbolic_binding_pattern U, 1 [symbolic = %U.patt.loc5_15.2 (constants.%U.patt)]
  316. // CHECK:STDOUT: %U.param_patt: type = value_param_pattern %U.patt.loc5_15.1, runtime_param<invalid> [symbolic = %U.patt.loc5_15.2 (constants.%U.patt)]
  317. // CHECK:STDOUT: } {
  318. // CHECK:STDOUT: %U.param: type = value_param runtime_param<invalid>
  319. // CHECK:STDOUT: %U.loc5_15.1: type = bind_symbolic_name U, 1, %U.param [symbolic = %U.loc5_15.2 (constants.%U)]
  320. // CHECK:STDOUT: }
  321. // CHECK:STDOUT: %.loc7: <witness> = complete_type_witness %.1 [template = constants.%.2]
  322. // CHECK:STDOUT:
  323. // CHECK:STDOUT: !members:
  324. // CHECK:STDOUT: .Self = constants.%Outer.2
  325. // CHECK:STDOUT: .Inner = %Inner.decl
  326. // CHECK:STDOUT: }
  327. // CHECK:STDOUT: }
  328. // CHECK:STDOUT:
  329. // CHECK:STDOUT: generic class @Inner(@Outer.%T.loc4_13.1: type, %U.loc5_15.1: type) {
  330. // CHECK:STDOUT: %U.loc5_15.2: type = bind_symbolic_name U, 1 [symbolic = %U.loc5_15.2 (constants.%U)]
  331. // CHECK:STDOUT: %U.patt.loc5_15.2: type = symbolic_binding_pattern U, 1 [symbolic = %U.patt.loc5_15.2 (constants.%U.patt)]
  332. // CHECK:STDOUT:
  333. // CHECK:STDOUT: !definition:
  334. // CHECK:STDOUT:
  335. // CHECK:STDOUT: class {
  336. // CHECK:STDOUT: %.loc6: <witness> = complete_type_witness %.1 [template = constants.%.2]
  337. // CHECK:STDOUT:
  338. // CHECK:STDOUT: !members:
  339. // CHECK:STDOUT: .Self = constants.%Inner.2
  340. // CHECK:STDOUT: }
  341. // CHECK:STDOUT: }
  342. // CHECK:STDOUT:
  343. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  344. // CHECK:STDOUT:
  345. // CHECK:STDOUT: generic fn @Convert(constants.%Dest: type, constants.%Self.1: @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2)) {
  346. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic = %Dest (constants.%Dest)]
  347. // CHECK:STDOUT: %ImplicitAs.type: type = facet_type <@ImplicitAs, @ImplicitAs(%Dest)> [symbolic = %ImplicitAs.type (constants.%ImplicitAs.type.2)]
  348. // CHECK:STDOUT: %Self: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.2)]
  349. // CHECK:STDOUT:
  350. // CHECK:STDOUT: fn[%self.param_patt: @Convert.%Self (%Self.2)]() -> @Convert.%Dest (%Dest);
  351. // CHECK:STDOUT: }
  352. // CHECK:STDOUT:
  353. // CHECK:STDOUT: fn @__global_init() {
  354. // CHECK:STDOUT: !entry:
  355. // CHECK:STDOUT: %v.ref: ref %Outer.3 = name_ref v, file.%v
  356. // CHECK:STDOUT: %.loc18: %Inner.4 = converted %v.ref, <error> [template = <error>]
  357. // CHECK:STDOUT: assign file.%w.var, <error>
  358. // CHECK:STDOUT: return
  359. // CHECK:STDOUT: }
  360. // CHECK:STDOUT:
  361. // CHECK:STDOUT: specific @Outer(constants.%T) {
  362. // CHECK:STDOUT: %T.loc4_13.2 => constants.%T
  363. // CHECK:STDOUT: %T.patt.loc4_13.2 => constants.%T
  364. // CHECK:STDOUT: }
  365. // CHECK:STDOUT:
  366. // CHECK:STDOUT: specific @Inner(constants.%T, constants.%U) {
  367. // CHECK:STDOUT: %U.loc5_15.2 => constants.%U
  368. // CHECK:STDOUT: %U.patt.loc5_15.2 => constants.%U
  369. // CHECK:STDOUT: }
  370. // CHECK:STDOUT:
  371. // CHECK:STDOUT: specific @Outer(@Outer.%T.loc4_13.2) {
  372. // CHECK:STDOUT: %T.loc4_13.2 => constants.%T
  373. // CHECK:STDOUT: %T.patt.loc4_13.2 => constants.%T
  374. // CHECK:STDOUT: }
  375. // CHECK:STDOUT:
  376. // CHECK:STDOUT: specific @Outer(constants.%.3) {
  377. // CHECK:STDOUT: %T.loc4_13.2 => constants.%.3
  378. // CHECK:STDOUT: %T.patt.loc4_13.2 => constants.%.3
  379. // CHECK:STDOUT:
  380. // CHECK:STDOUT: !definition:
  381. // CHECK:STDOUT: %Inner.type => constants.%Inner.type.2
  382. // CHECK:STDOUT: %Inner => constants.%Inner.3
  383. // CHECK:STDOUT: }
  384. // CHECK:STDOUT:
  385. // CHECK:STDOUT: specific @Inner(constants.%.3, constants.%.5) {
  386. // CHECK:STDOUT: %U.loc5_15.2 => constants.%.5
  387. // CHECK:STDOUT: %U.patt.loc5_15.2 => constants.%.5
  388. // CHECK:STDOUT:
  389. // CHECK:STDOUT: !definition:
  390. // CHECK:STDOUT: }
  391. // CHECK:STDOUT:
  392. // CHECK:STDOUT: specific @ImplicitAs(constants.%Dest) {
  393. // CHECK:STDOUT: %Dest => constants.%Dest
  394. // CHECK:STDOUT: %Dest.patt => constants.%Dest
  395. // CHECK:STDOUT: }
  396. // CHECK:STDOUT:
  397. // CHECK:STDOUT: specific @ImplicitAs(@ImplicitAs.%Dest) {
  398. // CHECK:STDOUT: %Dest => constants.%Dest
  399. // CHECK:STDOUT: %Dest.patt => constants.%Dest
  400. // CHECK:STDOUT: }
  401. // CHECK:STDOUT:
  402. // CHECK:STDOUT: specific @ImplicitAs(@Convert.%Dest) {
  403. // CHECK:STDOUT: %Dest => constants.%Dest
  404. // CHECK:STDOUT: %Dest.patt => constants.%Dest
  405. // CHECK:STDOUT: }
  406. // CHECK:STDOUT:
  407. // CHECK:STDOUT: specific @Convert(constants.%Dest, constants.%Self.1) {
  408. // CHECK:STDOUT: %Dest => constants.%Dest
  409. // CHECK:STDOUT: %ImplicitAs.type => constants.%ImplicitAs.type.2
  410. // CHECK:STDOUT: %Self => constants.%Self.1
  411. // CHECK:STDOUT: }
  412. // CHECK:STDOUT:
  413. // CHECK:STDOUT: specific @ImplicitAs(constants.%Inner.4) {
  414. // CHECK:STDOUT: %Dest => constants.%Inner.4
  415. // CHECK:STDOUT: %Dest.patt => constants.%Inner.4
  416. // CHECK:STDOUT:
  417. // CHECK:STDOUT: !definition:
  418. // CHECK:STDOUT: %ImplicitAs.type => constants.%ImplicitAs.type.3
  419. // CHECK:STDOUT: %Self => constants.%Self.2
  420. // CHECK:STDOUT: %Convert.type => constants.%Convert.type.2
  421. // CHECK:STDOUT: %Convert => constants.%Convert.2
  422. // CHECK:STDOUT: %.1 => constants.%.8
  423. // CHECK:STDOUT: %.2 => constants.%.9
  424. // CHECK:STDOUT: }
  425. // CHECK:STDOUT: