adapt.carbon 56 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005
  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/adapt.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/generic/adapt.carbon
  10. // --- adapt_specific_type.carbon
  11. library "[[@TEST_NAME]]";
  12. class C(T:! type) {
  13. var x: T;
  14. }
  15. class Adapter {
  16. adapt C(i32);
  17. }
  18. fn Access(a: Adapter) -> i32 {
  19. return (a as C(i32)).x;
  20. }
  21. // --- import_adapt_specific_type.carbon
  22. library "[[@TEST_NAME]]";
  23. import library "adapt_specific_type";
  24. fn ImportedAccess(a: Adapter) -> i32 {
  25. return (a as C(i32)).x;
  26. }
  27. // --- fail_todo_extend_adapt_specific_type.carbon
  28. library "[[@TEST_NAME]]";
  29. class C(T:! type) {
  30. var x: T;
  31. }
  32. class Adapter {
  33. extend adapt C(i32);
  34. }
  35. fn Access(a: Adapter) -> i32 {
  36. // TODO: This should presumably work, but the design doesn't say how yet.
  37. // CHECK:STDERR: fail_todo_extend_adapt_specific_type.carbon:[[@LINE+7]]:10: error: cannot implicitly convert from `Adapter` to `C(i32)` [ImplicitAsConversionFailure]
  38. // CHECK:STDERR: return a.x;
  39. // CHECK:STDERR: ^~~
  40. // CHECK:STDERR: fail_todo_extend_adapt_specific_type.carbon:[[@LINE+4]]:10: note: type `Adapter` does not implement interface `Core.ImplicitAs(C(i32))` [MissingImplInMemberAccessNote]
  41. // CHECK:STDERR: return a.x;
  42. // CHECK:STDERR: ^~~
  43. // CHECK:STDERR:
  44. return a.x;
  45. }
  46. // --- extend_adapt_specific_type_library.carbon
  47. // TODO: Delete this file and change the next file to instead import the
  48. // previous file once the previous file can be successfully type-checked.
  49. library "[[@TEST_NAME]]";
  50. class C(T:! type) {
  51. var x: T;
  52. }
  53. class Adapter {
  54. extend adapt C(i32);
  55. }
  56. // --- fail_todo_import_extend_adapt_specific_type.carbon
  57. library "[[@TEST_NAME]]";
  58. import library "extend_adapt_specific_type_library";
  59. fn ImportedAccess(a: Adapter) -> i32 {
  60. // TODO: This should presumably work, but the design doesn't say how yet.
  61. // CHECK:STDERR: fail_todo_import_extend_adapt_specific_type.carbon:[[@LINE+6]]:10: error: cannot implicitly convert from `Adapter` to `C(i32)` [ImplicitAsConversionFailure]
  62. // CHECK:STDERR: return a.x;
  63. // CHECK:STDERR: ^~~
  64. // CHECK:STDERR: fail_todo_import_extend_adapt_specific_type.carbon:[[@LINE+3]]:10: note: type `Adapter` does not implement interface `Core.ImplicitAs(C(i32))` [MissingImplInMemberAccessNote]
  65. // CHECK:STDERR: return a.x;
  66. // CHECK:STDERR: ^~~
  67. return a.x;
  68. }
  69. // --- adapt_generic_type.carbon
  70. library "[[@TEST_NAME]]";
  71. class Adapter(T:! type) {
  72. adapt T;
  73. }
  74. fn Convert(a: Adapter(i32)) -> i32 {
  75. return a as i32;
  76. }
  77. // --- import_adapt_generic_type.carbon
  78. library "[[@TEST_NAME]]";
  79. import library "adapt_generic_type";
  80. fn ImportedConvert(a: Adapter(i32)) -> i32 {
  81. return a as i32;
  82. }
  83. class C {
  84. var n: i32;
  85. }
  86. fn ImportedConvertLocal(a: Adapter(C)) -> i32 {
  87. return (a as C).n;
  88. }
  89. // CHECK:STDOUT: --- adapt_specific_type.carbon
  90. // CHECK:STDOUT:
  91. // CHECK:STDOUT: constants {
  92. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  93. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
  94. // CHECK:STDOUT: %C.type: type = generic_class_type @C [template]
  95. // CHECK:STDOUT: %C.generic: %C.type = struct_value () [template]
  96. // CHECK:STDOUT: %C.f2e: type = class_type @C, @C(%T) [symbolic]
  97. // CHECK:STDOUT: %require_complete.4ae: <witness> = require_complete_type %T [symbolic]
  98. // CHECK:STDOUT: %C.elem.66c: type = unbound_element_type %C.f2e, %T [symbolic]
  99. // CHECK:STDOUT: %struct_type.x.2ac: type = struct_type {.x: %T} [symbolic]
  100. // CHECK:STDOUT: %complete_type.433: <witness> = complete_type_witness %struct_type.x.2ac [symbolic]
  101. // CHECK:STDOUT: %Adapter: type = class_type @Adapter [template]
  102. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  103. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  104. // CHECK:STDOUT: %C.98a: type = class_type @C, @C(%i32) [template]
  105. // CHECK:STDOUT: %i32.builtin: type = int_type signed, %int_32 [template]
  106. // CHECK:STDOUT: %complete_type.f8a: <witness> = complete_type_witness %i32.builtin [template]
  107. // CHECK:STDOUT: %C.elem.476: type = unbound_element_type %C.98a, %i32 [template]
  108. // CHECK:STDOUT: %struct_type.x.ed6: type = struct_type {.x: %i32} [template]
  109. // CHECK:STDOUT: %complete_type.1ec: <witness> = complete_type_witness %struct_type.x.ed6 [template]
  110. // CHECK:STDOUT: %Access.type: type = fn_type @Access [template]
  111. // CHECK:STDOUT: %Access: %Access.type = struct_value () [template]
  112. // CHECK:STDOUT: }
  113. // CHECK:STDOUT:
  114. // CHECK:STDOUT: imports {
  115. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  116. // CHECK:STDOUT: .Int = %import_ref.485
  117. // CHECK:STDOUT: import Core//prelude
  118. // CHECK:STDOUT: import Core//prelude/...
  119. // CHECK:STDOUT: }
  120. // CHECK:STDOUT: }
  121. // CHECK:STDOUT:
  122. // CHECK:STDOUT: file {
  123. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  124. // CHECK:STDOUT: .Core = imports.%Core
  125. // CHECK:STDOUT: .C = %C.decl
  126. // CHECK:STDOUT: .Adapter = %Adapter.decl
  127. // CHECK:STDOUT: .Access = %Access.decl
  128. // CHECK:STDOUT: }
  129. // CHECK:STDOUT: %Core.import = import Core
  130. // CHECK:STDOUT: %C.decl: %C.type = class_decl @C [template = constants.%C.generic] {
  131. // CHECK:STDOUT: %T.patt.loc4_9.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc4_9.2 (constants.%T.patt)]
  132. // CHECK:STDOUT: %T.param_patt: type = value_param_pattern %T.patt.loc4_9.1, runtime_param<invalid> [symbolic = %T.patt.loc4_9.2 (constants.%T.patt)]
  133. // CHECK:STDOUT: } {
  134. // CHECK:STDOUT: %T.param: type = value_param runtime_param<invalid>
  135. // CHECK:STDOUT: %T.loc4_9.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc4_9.2 (constants.%T)]
  136. // CHECK:STDOUT: }
  137. // CHECK:STDOUT: %Adapter.decl: type = class_decl @Adapter [template = constants.%Adapter] {} {}
  138. // CHECK:STDOUT: %Access.decl: %Access.type = fn_decl @Access [template = constants.%Access] {
  139. // CHECK:STDOUT: %a.patt: %Adapter = binding_pattern a
  140. // CHECK:STDOUT: %a.param_patt: %Adapter = value_param_pattern %a.patt, runtime_param0
  141. // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
  142. // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param1
  143. // CHECK:STDOUT: } {
  144. // CHECK:STDOUT: %int_32.loc12: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  145. // CHECK:STDOUT: %i32.loc12: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  146. // CHECK:STDOUT: %a.param: %Adapter = value_param runtime_param0
  147. // CHECK:STDOUT: %Adapter.ref: type = name_ref Adapter, file.%Adapter.decl [template = constants.%Adapter]
  148. // CHECK:STDOUT: %a: %Adapter = bind_name a, %a.param
  149. // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param1
  150. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  151. // CHECK:STDOUT: }
  152. // CHECK:STDOUT: }
  153. // CHECK:STDOUT:
  154. // CHECK:STDOUT: generic class @C(%T.loc4_9.1: type) {
  155. // CHECK:STDOUT: %T.loc4_9.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc4_9.2 (constants.%T)]
  156. // CHECK:STDOUT: %T.patt.loc4_9.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc4_9.2 (constants.%T.patt)]
  157. // CHECK:STDOUT:
  158. // CHECK:STDOUT: !definition:
  159. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type @C.%T.loc4_9.2 (%T) [symbolic = %require_complete (constants.%require_complete.4ae)]
  160. // CHECK:STDOUT: %C: type = class_type @C, @C(%T.loc4_9.2) [symbolic = %C (constants.%C.f2e)]
  161. // CHECK:STDOUT: %C.elem: type = unbound_element_type @C.%C (%C.f2e), @C.%T.loc4_9.2 (%T) [symbolic = %C.elem (constants.%C.elem.66c)]
  162. // CHECK:STDOUT: %struct_type.x: type = struct_type {.x: @C.%T.loc4_9.2 (%T)} [symbolic = %struct_type.x (constants.%struct_type.x.2ac)]
  163. // CHECK:STDOUT: %complete_type.loc6_1.2: <witness> = complete_type_witness @C.%struct_type.x (%struct_type.x.2ac) [symbolic = %complete_type.loc6_1.2 (constants.%complete_type.433)]
  164. // CHECK:STDOUT:
  165. // CHECK:STDOUT: class {
  166. // CHECK:STDOUT: %.loc5: @C.%C.elem (%C.elem.66c) = field_decl x, element0 [template]
  167. // CHECK:STDOUT: %complete_type.loc6_1.1: <witness> = complete_type_witness %struct_type.x.2ac [symbolic = %complete_type.loc6_1.2 (constants.%complete_type.433)]
  168. // CHECK:STDOUT: complete_type_witness = %complete_type.loc6_1.1
  169. // CHECK:STDOUT:
  170. // CHECK:STDOUT: !members:
  171. // CHECK:STDOUT: .Self = constants.%C.f2e
  172. // CHECK:STDOUT: .x = %.loc5
  173. // CHECK:STDOUT: }
  174. // CHECK:STDOUT: }
  175. // CHECK:STDOUT:
  176. // CHECK:STDOUT: class @Adapter {
  177. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, file.%C.decl [template = constants.%C.generic]
  178. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  179. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  180. // CHECK:STDOUT: %C: type = class_type @C, @C(constants.%i32) [template = constants.%C.98a]
  181. // CHECK:STDOUT: adapt_decl %C [template]
  182. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.x.ed6 [template = constants.%complete_type.1ec]
  183. // CHECK:STDOUT: complete_type_witness = %complete_type
  184. // CHECK:STDOUT:
  185. // CHECK:STDOUT: !members:
  186. // CHECK:STDOUT: .Self = constants.%Adapter
  187. // CHECK:STDOUT: }
  188. // CHECK:STDOUT:
  189. // CHECK:STDOUT: fn @Access(%a.param_patt: %Adapter) -> %i32 {
  190. // CHECK:STDOUT: !entry:
  191. // CHECK:STDOUT: %a.ref: %Adapter = name_ref a, %a
  192. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, file.%C.decl [template = constants.%C.generic]
  193. // CHECK:STDOUT: %int_32.loc13: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  194. // CHECK:STDOUT: %i32.loc13: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  195. // CHECK:STDOUT: %C: type = class_type @C, @C(constants.%i32) [template = constants.%C.98a]
  196. // CHECK:STDOUT: %.loc13_13.1: %C.98a = as_compatible %a.ref
  197. // CHECK:STDOUT: %.loc13_13.2: %C.98a = converted %a.ref, %.loc13_13.1
  198. // CHECK:STDOUT: %x.ref: %C.elem.476 = name_ref x, @C.%.loc5 [template = @C.%.loc5]
  199. // CHECK:STDOUT: %.loc13_23.1: ref %i32 = class_element_access %.loc13_13.2, element0
  200. // CHECK:STDOUT: %.loc13_23.2: %i32 = bind_value %.loc13_23.1
  201. // CHECK:STDOUT: return %.loc13_23.2
  202. // CHECK:STDOUT: }
  203. // CHECK:STDOUT:
  204. // CHECK:STDOUT: specific @C(constants.%T) {
  205. // CHECK:STDOUT: %T.loc4_9.2 => constants.%T
  206. // CHECK:STDOUT: %T.patt.loc4_9.2 => constants.%T
  207. // CHECK:STDOUT: }
  208. // CHECK:STDOUT:
  209. // CHECK:STDOUT: specific @C(%T.loc4_9.2) {}
  210. // CHECK:STDOUT:
  211. // CHECK:STDOUT: specific @C(constants.%i32) {
  212. // CHECK:STDOUT: %T.loc4_9.2 => constants.%i32
  213. // CHECK:STDOUT: %T.patt.loc4_9.2 => constants.%i32
  214. // CHECK:STDOUT:
  215. // CHECK:STDOUT: !definition:
  216. // CHECK:STDOUT: %require_complete => constants.%complete_type.f8a
  217. // CHECK:STDOUT: %C => constants.%C.98a
  218. // CHECK:STDOUT: %C.elem => constants.%C.elem.476
  219. // CHECK:STDOUT: %struct_type.x => constants.%struct_type.x.ed6
  220. // CHECK:STDOUT: %complete_type.loc6_1.2 => constants.%complete_type.1ec
  221. // CHECK:STDOUT: }
  222. // CHECK:STDOUT:
  223. // CHECK:STDOUT: --- import_adapt_specific_type.carbon
  224. // CHECK:STDOUT:
  225. // CHECK:STDOUT: constants {
  226. // CHECK:STDOUT: %Adapter: type = class_type @Adapter [template]
  227. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  228. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  229. // CHECK:STDOUT: %C.type: type = generic_class_type @C [template]
  230. // CHECK:STDOUT: %C.generic: %C.type = struct_value () [template]
  231. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  232. // CHECK:STDOUT: %struct_type.x.2ac: type = struct_type {.x: %T} [symbolic]
  233. // CHECK:STDOUT: %complete_type.433: <witness> = complete_type_witness %struct_type.x.2ac [symbolic]
  234. // CHECK:STDOUT: %C.f2e: type = class_type @C, @C(%T) [symbolic]
  235. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
  236. // CHECK:STDOUT: %C.239: type = class_type @C, @C(%i32) [template]
  237. // CHECK:STDOUT: %struct_type.x.767: type = struct_type {.x: %i32} [template]
  238. // CHECK:STDOUT: %complete_type.c07: <witness> = complete_type_witness %struct_type.x.767 [template]
  239. // CHECK:STDOUT: %require_complete.4ae: <witness> = require_complete_type %T [symbolic]
  240. // CHECK:STDOUT: %C.elem.66c: type = unbound_element_type %C.f2e, %T [symbolic]
  241. // CHECK:STDOUT: %i32.builtin: type = int_type signed, %int_32 [template]
  242. // CHECK:STDOUT: %complete_type.f8a: <witness> = complete_type_witness %i32.builtin [template]
  243. // CHECK:STDOUT: %C.elem.ed6: type = unbound_element_type %C.239, %i32 [template]
  244. // CHECK:STDOUT: %ImportedAccess.type: type = fn_type @ImportedAccess [template]
  245. // CHECK:STDOUT: %ImportedAccess: %ImportedAccess.type = struct_value () [template]
  246. // CHECK:STDOUT: }
  247. // CHECK:STDOUT:
  248. // CHECK:STDOUT: imports {
  249. // CHECK:STDOUT: %import_ref.bb9: %C.type = import_ref Main//adapt_specific_type, C, loaded [template = constants.%C.generic]
  250. // CHECK:STDOUT: %import_ref.c01: type = import_ref Main//adapt_specific_type, Adapter, loaded [template = constants.%Adapter]
  251. // CHECK:STDOUT: %import_ref.baa = import_ref Main//adapt_specific_type, Access, unloaded
  252. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  253. // CHECK:STDOUT: .Int = %import_ref.2c8
  254. // CHECK:STDOUT: import Core//prelude
  255. // CHECK:STDOUT: import Core//prelude/...
  256. // CHECK:STDOUT: }
  257. // CHECK:STDOUT: %import_ref.b5f: <witness> = import_ref Main//adapt_specific_type, loc6_1, loaded [symbolic = @C.%complete_type (constants.%complete_type.433)]
  258. // CHECK:STDOUT: %import_ref.4c0 = import_ref Main//adapt_specific_type, inst27 [no loc], unloaded
  259. // CHECK:STDOUT: %import_ref.262: @C.%C.elem (%C.elem.66c) = import_ref Main//adapt_specific_type, loc5_8, loaded [template = %.22b]
  260. // CHECK:STDOUT: %import_ref.709: <witness> = import_ref Main//adapt_specific_type, loc10_1, loaded [template = constants.%complete_type.c07]
  261. // CHECK:STDOUT: %import_ref.feb = import_ref Main//adapt_specific_type, inst42 [no loc], unloaded
  262. // CHECK:STDOUT: }
  263. // CHECK:STDOUT:
  264. // CHECK:STDOUT: file {
  265. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  266. // CHECK:STDOUT: .C = imports.%import_ref.bb9
  267. // CHECK:STDOUT: .Adapter = imports.%import_ref.c01
  268. // CHECK:STDOUT: .Access = imports.%import_ref.baa
  269. // CHECK:STDOUT: .Core = imports.%Core
  270. // CHECK:STDOUT: .ImportedAccess = %ImportedAccess.decl
  271. // CHECK:STDOUT: }
  272. // CHECK:STDOUT: %Core.import = import Core
  273. // CHECK:STDOUT: %default.import = import <invalid>
  274. // CHECK:STDOUT: %ImportedAccess.decl: %ImportedAccess.type = fn_decl @ImportedAccess [template = constants.%ImportedAccess] {
  275. // CHECK:STDOUT: %a.patt: %Adapter = binding_pattern a
  276. // CHECK:STDOUT: %a.param_patt: %Adapter = value_param_pattern %a.patt, runtime_param0
  277. // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
  278. // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param1
  279. // CHECK:STDOUT: } {
  280. // CHECK:STDOUT: %int_32.loc6: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  281. // CHECK:STDOUT: %i32.loc6: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  282. // CHECK:STDOUT: %a.param: %Adapter = value_param runtime_param0
  283. // CHECK:STDOUT: %Adapter.ref: type = name_ref Adapter, imports.%import_ref.c01 [template = constants.%Adapter]
  284. // CHECK:STDOUT: %a: %Adapter = bind_name a, %a.param
  285. // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param1
  286. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  287. // CHECK:STDOUT: }
  288. // CHECK:STDOUT: }
  289. // CHECK:STDOUT:
  290. // CHECK:STDOUT: class @Adapter [from "adapt_specific_type.carbon"] {
  291. // CHECK:STDOUT: complete_type_witness = imports.%import_ref.709
  292. // CHECK:STDOUT:
  293. // CHECK:STDOUT: !members:
  294. // CHECK:STDOUT: .Self = imports.%import_ref.feb
  295. // CHECK:STDOUT: }
  296. // CHECK:STDOUT:
  297. // CHECK:STDOUT: generic class @C(constants.%T: type) [from "adapt_specific_type.carbon"] {
  298. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T)]
  299. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt (constants.%T.patt)]
  300. // CHECK:STDOUT:
  301. // CHECK:STDOUT: !definition:
  302. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type @C.%T (%T) [symbolic = %require_complete (constants.%require_complete.4ae)]
  303. // CHECK:STDOUT: %C: type = class_type @C, @C(%T) [symbolic = %C (constants.%C.f2e)]
  304. // CHECK:STDOUT: %C.elem: type = unbound_element_type @C.%C (%C.f2e), @C.%T (%T) [symbolic = %C.elem (constants.%C.elem.66c)]
  305. // CHECK:STDOUT: %struct_type.x: type = struct_type {.x: @C.%T (%T)} [symbolic = %struct_type.x (constants.%struct_type.x.2ac)]
  306. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness @C.%struct_type.x (%struct_type.x.2ac) [symbolic = %complete_type (constants.%complete_type.433)]
  307. // CHECK:STDOUT:
  308. // CHECK:STDOUT: class {
  309. // CHECK:STDOUT: complete_type_witness = imports.%import_ref.b5f
  310. // CHECK:STDOUT:
  311. // CHECK:STDOUT: !members:
  312. // CHECK:STDOUT: .Self = imports.%import_ref.4c0
  313. // CHECK:STDOUT: .x = imports.%import_ref.262
  314. // CHECK:STDOUT: }
  315. // CHECK:STDOUT: }
  316. // CHECK:STDOUT:
  317. // CHECK:STDOUT: fn @ImportedAccess(%a.param_patt: %Adapter) -> %i32 {
  318. // CHECK:STDOUT: !entry:
  319. // CHECK:STDOUT: %a.ref: %Adapter = name_ref a, %a
  320. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, imports.%import_ref.bb9 [template = constants.%C.generic]
  321. // CHECK:STDOUT: %int_32.loc7: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  322. // CHECK:STDOUT: %i32.loc7: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  323. // CHECK:STDOUT: %C: type = class_type @C, @C(constants.%i32) [template = constants.%C.239]
  324. // CHECK:STDOUT: %.loc7_13.1: %C.239 = as_compatible %a.ref
  325. // CHECK:STDOUT: %.loc7_13.2: %C.239 = converted %a.ref, %.loc7_13.1
  326. // CHECK:STDOUT: %x.ref: %C.elem.ed6 = name_ref x, imports.%import_ref.262 [template = imports.%.22b]
  327. // CHECK:STDOUT: %.loc7_23.1: ref %i32 = class_element_access %.loc7_13.2, element0
  328. // CHECK:STDOUT: %.loc7_23.2: %i32 = bind_value %.loc7_23.1
  329. // CHECK:STDOUT: return %.loc7_23.2
  330. // CHECK:STDOUT: }
  331. // CHECK:STDOUT:
  332. // CHECK:STDOUT: specific @C(constants.%T) {
  333. // CHECK:STDOUT: %T => constants.%T
  334. // CHECK:STDOUT: %T.patt => constants.%T
  335. // CHECK:STDOUT: }
  336. // CHECK:STDOUT:
  337. // CHECK:STDOUT: specific @C(constants.%i32) {
  338. // CHECK:STDOUT: %T => constants.%i32
  339. // CHECK:STDOUT: %T.patt => constants.%i32
  340. // CHECK:STDOUT:
  341. // CHECK:STDOUT: !definition:
  342. // CHECK:STDOUT: %require_complete => constants.%complete_type.f8a
  343. // CHECK:STDOUT: %C => constants.%C.239
  344. // CHECK:STDOUT: %C.elem => constants.%C.elem.ed6
  345. // CHECK:STDOUT: %struct_type.x => constants.%struct_type.x.767
  346. // CHECK:STDOUT: %complete_type => constants.%complete_type.c07
  347. // CHECK:STDOUT: }
  348. // CHECK:STDOUT:
  349. // CHECK:STDOUT: specific @C(%T) {}
  350. // CHECK:STDOUT:
  351. // CHECK:STDOUT: --- fail_todo_extend_adapt_specific_type.carbon
  352. // CHECK:STDOUT:
  353. // CHECK:STDOUT: constants {
  354. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  355. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
  356. // CHECK:STDOUT: %C.type: type = generic_class_type @C [template]
  357. // CHECK:STDOUT: %C.generic: %C.type = struct_value () [template]
  358. // CHECK:STDOUT: %C.f2e: type = class_type @C, @C(%T) [symbolic]
  359. // CHECK:STDOUT: %require_complete.4ae: <witness> = require_complete_type %T [symbolic]
  360. // CHECK:STDOUT: %C.elem.66c: type = unbound_element_type %C.f2e, %T [symbolic]
  361. // CHECK:STDOUT: %struct_type.x.2ac: type = struct_type {.x: %T} [symbolic]
  362. // CHECK:STDOUT: %complete_type.433: <witness> = complete_type_witness %struct_type.x.2ac [symbolic]
  363. // CHECK:STDOUT: %Adapter: type = class_type @Adapter [template]
  364. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  365. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  366. // CHECK:STDOUT: %C.98a: type = class_type @C, @C(%i32) [template]
  367. // CHECK:STDOUT: %i32.builtin: type = int_type signed, %int_32 [template]
  368. // CHECK:STDOUT: %complete_type.f8a: <witness> = complete_type_witness %i32.builtin [template]
  369. // CHECK:STDOUT: %C.elem.476: type = unbound_element_type %C.98a, %i32 [template]
  370. // CHECK:STDOUT: %struct_type.x.ed6: type = struct_type {.x: %i32} [template]
  371. // CHECK:STDOUT: %complete_type.1ec: <witness> = complete_type_witness %struct_type.x.ed6 [template]
  372. // CHECK:STDOUT: %Access.type: type = fn_type @Access [template]
  373. // CHECK:STDOUT: %Access: %Access.type = struct_value () [template]
  374. // CHECK:STDOUT: }
  375. // CHECK:STDOUT:
  376. // CHECK:STDOUT: imports {
  377. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  378. // CHECK:STDOUT: .Int = %import_ref.485
  379. // CHECK:STDOUT: .ImplicitAs = %import_ref.d44
  380. // CHECK:STDOUT: import Core//prelude
  381. // CHECK:STDOUT: import Core//prelude/...
  382. // CHECK:STDOUT: }
  383. // CHECK:STDOUT: }
  384. // CHECK:STDOUT:
  385. // CHECK:STDOUT: file {
  386. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  387. // CHECK:STDOUT: .Core = imports.%Core
  388. // CHECK:STDOUT: .C = %C.decl
  389. // CHECK:STDOUT: .Adapter = %Adapter.decl
  390. // CHECK:STDOUT: .Access = %Access.decl
  391. // CHECK:STDOUT: }
  392. // CHECK:STDOUT: %Core.import = import Core
  393. // CHECK:STDOUT: %C.decl: %C.type = class_decl @C [template = constants.%C.generic] {
  394. // CHECK:STDOUT: %T.patt.loc4_9.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc4_9.2 (constants.%T.patt)]
  395. // CHECK:STDOUT: %T.param_patt: type = value_param_pattern %T.patt.loc4_9.1, runtime_param<invalid> [symbolic = %T.patt.loc4_9.2 (constants.%T.patt)]
  396. // CHECK:STDOUT: } {
  397. // CHECK:STDOUT: %T.param: type = value_param runtime_param<invalid>
  398. // CHECK:STDOUT: %T.loc4_9.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc4_9.2 (constants.%T)]
  399. // CHECK:STDOUT: }
  400. // CHECK:STDOUT: %Adapter.decl: type = class_decl @Adapter [template = constants.%Adapter] {} {}
  401. // CHECK:STDOUT: %Access.decl: %Access.type = fn_decl @Access [template = constants.%Access] {
  402. // CHECK:STDOUT: %a.patt: %Adapter = binding_pattern a
  403. // CHECK:STDOUT: %a.param_patt: %Adapter = value_param_pattern %a.patt, runtime_param0
  404. // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
  405. // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param1
  406. // CHECK:STDOUT: } {
  407. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  408. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  409. // CHECK:STDOUT: %a.param: %Adapter = value_param runtime_param0
  410. // CHECK:STDOUT: %Adapter.ref: type = name_ref Adapter, file.%Adapter.decl [template = constants.%Adapter]
  411. // CHECK:STDOUT: %a: %Adapter = bind_name a, %a.param
  412. // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param1
  413. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  414. // CHECK:STDOUT: }
  415. // CHECK:STDOUT: }
  416. // CHECK:STDOUT:
  417. // CHECK:STDOUT: generic class @C(%T.loc4_9.1: type) {
  418. // CHECK:STDOUT: %T.loc4_9.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc4_9.2 (constants.%T)]
  419. // CHECK:STDOUT: %T.patt.loc4_9.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc4_9.2 (constants.%T.patt)]
  420. // CHECK:STDOUT:
  421. // CHECK:STDOUT: !definition:
  422. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type @C.%T.loc4_9.2 (%T) [symbolic = %require_complete (constants.%require_complete.4ae)]
  423. // CHECK:STDOUT: %C: type = class_type @C, @C(%T.loc4_9.2) [symbolic = %C (constants.%C.f2e)]
  424. // CHECK:STDOUT: %C.elem: type = unbound_element_type @C.%C (%C.f2e), @C.%T.loc4_9.2 (%T) [symbolic = %C.elem (constants.%C.elem.66c)]
  425. // CHECK:STDOUT: %struct_type.x: type = struct_type {.x: @C.%T.loc4_9.2 (%T)} [symbolic = %struct_type.x (constants.%struct_type.x.2ac)]
  426. // CHECK:STDOUT: %complete_type.loc6_1.2: <witness> = complete_type_witness @C.%struct_type.x (%struct_type.x.2ac) [symbolic = %complete_type.loc6_1.2 (constants.%complete_type.433)]
  427. // CHECK:STDOUT:
  428. // CHECK:STDOUT: class {
  429. // CHECK:STDOUT: %.loc5: @C.%C.elem (%C.elem.66c) = field_decl x, element0 [template]
  430. // CHECK:STDOUT: %complete_type.loc6_1.1: <witness> = complete_type_witness %struct_type.x.2ac [symbolic = %complete_type.loc6_1.2 (constants.%complete_type.433)]
  431. // CHECK:STDOUT: complete_type_witness = %complete_type.loc6_1.1
  432. // CHECK:STDOUT:
  433. // CHECK:STDOUT: !members:
  434. // CHECK:STDOUT: .Self = constants.%C.f2e
  435. // CHECK:STDOUT: .x = %.loc5
  436. // CHECK:STDOUT: }
  437. // CHECK:STDOUT: }
  438. // CHECK:STDOUT:
  439. // CHECK:STDOUT: class @Adapter {
  440. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, file.%C.decl [template = constants.%C.generic]
  441. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  442. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  443. // CHECK:STDOUT: %C: type = class_type @C, @C(constants.%i32) [template = constants.%C.98a]
  444. // CHECK:STDOUT: adapt_decl %C [template]
  445. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.x.ed6 [template = constants.%complete_type.1ec]
  446. // CHECK:STDOUT: complete_type_witness = %complete_type
  447. // CHECK:STDOUT:
  448. // CHECK:STDOUT: !members:
  449. // CHECK:STDOUT: .Self = constants.%Adapter
  450. // CHECK:STDOUT: extend %C
  451. // CHECK:STDOUT: }
  452. // CHECK:STDOUT:
  453. // CHECK:STDOUT: fn @Access(%a.param_patt: %Adapter) -> %i32 {
  454. // CHECK:STDOUT: !entry:
  455. // CHECK:STDOUT: %a.ref: %Adapter = name_ref a, %a
  456. // CHECK:STDOUT: %x.ref: %C.elem.476 = name_ref x, @C.%.loc5 [template = @C.%.loc5]
  457. // CHECK:STDOUT: %.loc21_11.1: %C.98a = converted %a.ref, <error> [template = <error>]
  458. // CHECK:STDOUT: %.loc21_11.2: %i32 = class_element_access <error>, element0 [template = <error>]
  459. // CHECK:STDOUT: return <error>
  460. // CHECK:STDOUT: }
  461. // CHECK:STDOUT:
  462. // CHECK:STDOUT: specific @C(constants.%T) {
  463. // CHECK:STDOUT: %T.loc4_9.2 => constants.%T
  464. // CHECK:STDOUT: %T.patt.loc4_9.2 => constants.%T
  465. // CHECK:STDOUT: }
  466. // CHECK:STDOUT:
  467. // CHECK:STDOUT: specific @C(%T.loc4_9.2) {}
  468. // CHECK:STDOUT:
  469. // CHECK:STDOUT: specific @C(constants.%i32) {
  470. // CHECK:STDOUT: %T.loc4_9.2 => constants.%i32
  471. // CHECK:STDOUT: %T.patt.loc4_9.2 => constants.%i32
  472. // CHECK:STDOUT:
  473. // CHECK:STDOUT: !definition:
  474. // CHECK:STDOUT: %require_complete => constants.%complete_type.f8a
  475. // CHECK:STDOUT: %C => constants.%C.98a
  476. // CHECK:STDOUT: %C.elem => constants.%C.elem.476
  477. // CHECK:STDOUT: %struct_type.x => constants.%struct_type.x.ed6
  478. // CHECK:STDOUT: %complete_type.loc6_1.2 => constants.%complete_type.1ec
  479. // CHECK:STDOUT: }
  480. // CHECK:STDOUT:
  481. // CHECK:STDOUT: --- extend_adapt_specific_type_library.carbon
  482. // CHECK:STDOUT:
  483. // CHECK:STDOUT: constants {
  484. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  485. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
  486. // CHECK:STDOUT: %C.type: type = generic_class_type @C [template]
  487. // CHECK:STDOUT: %C.generic: %C.type = struct_value () [template]
  488. // CHECK:STDOUT: %C.f2e: type = class_type @C, @C(%T) [symbolic]
  489. // CHECK:STDOUT: %require_complete.4ae: <witness> = require_complete_type %T [symbolic]
  490. // CHECK:STDOUT: %C.elem.66c: type = unbound_element_type %C.f2e, %T [symbolic]
  491. // CHECK:STDOUT: %struct_type.x.2ac: type = struct_type {.x: %T} [symbolic]
  492. // CHECK:STDOUT: %complete_type.433: <witness> = complete_type_witness %struct_type.x.2ac [symbolic]
  493. // CHECK:STDOUT: %Adapter: type = class_type @Adapter [template]
  494. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  495. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  496. // CHECK:STDOUT: %C.98a: type = class_type @C, @C(%i32) [template]
  497. // CHECK:STDOUT: %i32.builtin: type = int_type signed, %int_32 [template]
  498. // CHECK:STDOUT: %complete_type.f8a: <witness> = complete_type_witness %i32.builtin [template]
  499. // CHECK:STDOUT: %C.elem.476: type = unbound_element_type %C.98a, %i32 [template]
  500. // CHECK:STDOUT: %struct_type.x.ed6: type = struct_type {.x: %i32} [template]
  501. // CHECK:STDOUT: %complete_type.1ec: <witness> = complete_type_witness %struct_type.x.ed6 [template]
  502. // CHECK:STDOUT: }
  503. // CHECK:STDOUT:
  504. // CHECK:STDOUT: imports {
  505. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  506. // CHECK:STDOUT: .Int = %import_ref.485
  507. // CHECK:STDOUT: import Core//prelude
  508. // CHECK:STDOUT: import Core//prelude/...
  509. // CHECK:STDOUT: }
  510. // CHECK:STDOUT: }
  511. // CHECK:STDOUT:
  512. // CHECK:STDOUT: file {
  513. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  514. // CHECK:STDOUT: .Core = imports.%Core
  515. // CHECK:STDOUT: .C = %C.decl
  516. // CHECK:STDOUT: .Adapter = %Adapter.decl
  517. // CHECK:STDOUT: }
  518. // CHECK:STDOUT: %Core.import = import Core
  519. // CHECK:STDOUT: %C.decl: %C.type = class_decl @C [template = constants.%C.generic] {
  520. // CHECK:STDOUT: %T.patt.loc7_9.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc7_9.2 (constants.%T.patt)]
  521. // CHECK:STDOUT: %T.param_patt: type = value_param_pattern %T.patt.loc7_9.1, runtime_param<invalid> [symbolic = %T.patt.loc7_9.2 (constants.%T.patt)]
  522. // CHECK:STDOUT: } {
  523. // CHECK:STDOUT: %T.param: type = value_param runtime_param<invalid>
  524. // CHECK:STDOUT: %T.loc7_9.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc7_9.2 (constants.%T)]
  525. // CHECK:STDOUT: }
  526. // CHECK:STDOUT: %Adapter.decl: type = class_decl @Adapter [template = constants.%Adapter] {} {}
  527. // CHECK:STDOUT: }
  528. // CHECK:STDOUT:
  529. // CHECK:STDOUT: generic class @C(%T.loc7_9.1: type) {
  530. // CHECK:STDOUT: %T.loc7_9.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc7_9.2 (constants.%T)]
  531. // CHECK:STDOUT: %T.patt.loc7_9.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc7_9.2 (constants.%T.patt)]
  532. // CHECK:STDOUT:
  533. // CHECK:STDOUT: !definition:
  534. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type @C.%T.loc7_9.2 (%T) [symbolic = %require_complete (constants.%require_complete.4ae)]
  535. // CHECK:STDOUT: %C: type = class_type @C, @C(%T.loc7_9.2) [symbolic = %C (constants.%C.f2e)]
  536. // CHECK:STDOUT: %C.elem: type = unbound_element_type @C.%C (%C.f2e), @C.%T.loc7_9.2 (%T) [symbolic = %C.elem (constants.%C.elem.66c)]
  537. // CHECK:STDOUT: %struct_type.x: type = struct_type {.x: @C.%T.loc7_9.2 (%T)} [symbolic = %struct_type.x (constants.%struct_type.x.2ac)]
  538. // CHECK:STDOUT: %complete_type.loc9_1.2: <witness> = complete_type_witness @C.%struct_type.x (%struct_type.x.2ac) [symbolic = %complete_type.loc9_1.2 (constants.%complete_type.433)]
  539. // CHECK:STDOUT:
  540. // CHECK:STDOUT: class {
  541. // CHECK:STDOUT: %.loc8: @C.%C.elem (%C.elem.66c) = field_decl x, element0 [template]
  542. // CHECK:STDOUT: %complete_type.loc9_1.1: <witness> = complete_type_witness %struct_type.x.2ac [symbolic = %complete_type.loc9_1.2 (constants.%complete_type.433)]
  543. // CHECK:STDOUT: complete_type_witness = %complete_type.loc9_1.1
  544. // CHECK:STDOUT:
  545. // CHECK:STDOUT: !members:
  546. // CHECK:STDOUT: .Self = constants.%C.f2e
  547. // CHECK:STDOUT: .x = %.loc8
  548. // CHECK:STDOUT: }
  549. // CHECK:STDOUT: }
  550. // CHECK:STDOUT:
  551. // CHECK:STDOUT: class @Adapter {
  552. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, file.%C.decl [template = constants.%C.generic]
  553. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  554. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  555. // CHECK:STDOUT: %C: type = class_type @C, @C(constants.%i32) [template = constants.%C.98a]
  556. // CHECK:STDOUT: adapt_decl %C [template]
  557. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.x.ed6 [template = constants.%complete_type.1ec]
  558. // CHECK:STDOUT: complete_type_witness = %complete_type
  559. // CHECK:STDOUT:
  560. // CHECK:STDOUT: !members:
  561. // CHECK:STDOUT: .Self = constants.%Adapter
  562. // CHECK:STDOUT: extend %C
  563. // CHECK:STDOUT: }
  564. // CHECK:STDOUT:
  565. // CHECK:STDOUT: specific @C(constants.%T) {
  566. // CHECK:STDOUT: %T.loc7_9.2 => constants.%T
  567. // CHECK:STDOUT: %T.patt.loc7_9.2 => constants.%T
  568. // CHECK:STDOUT: }
  569. // CHECK:STDOUT:
  570. // CHECK:STDOUT: specific @C(%T.loc7_9.2) {}
  571. // CHECK:STDOUT:
  572. // CHECK:STDOUT: specific @C(constants.%i32) {
  573. // CHECK:STDOUT: %T.loc7_9.2 => constants.%i32
  574. // CHECK:STDOUT: %T.patt.loc7_9.2 => constants.%i32
  575. // CHECK:STDOUT:
  576. // CHECK:STDOUT: !definition:
  577. // CHECK:STDOUT: %require_complete => constants.%complete_type.f8a
  578. // CHECK:STDOUT: %C => constants.%C.98a
  579. // CHECK:STDOUT: %C.elem => constants.%C.elem.476
  580. // CHECK:STDOUT: %struct_type.x => constants.%struct_type.x.ed6
  581. // CHECK:STDOUT: %complete_type.loc9_1.2 => constants.%complete_type.1ec
  582. // CHECK:STDOUT: }
  583. // CHECK:STDOUT:
  584. // CHECK:STDOUT: --- fail_todo_import_extend_adapt_specific_type.carbon
  585. // CHECK:STDOUT:
  586. // CHECK:STDOUT: constants {
  587. // CHECK:STDOUT: %Adapter: type = class_type @Adapter [template]
  588. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  589. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  590. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  591. // CHECK:STDOUT: %struct_type.x.2ac: type = struct_type {.x: %T} [symbolic]
  592. // CHECK:STDOUT: %complete_type.433: <witness> = complete_type_witness %struct_type.x.2ac [symbolic]
  593. // CHECK:STDOUT: %C.f2e: type = class_type @C, @C(%T) [symbolic]
  594. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
  595. // CHECK:STDOUT: %C.239: type = class_type @C, @C(%i32) [template]
  596. // CHECK:STDOUT: %struct_type.x.767: type = struct_type {.x: %i32} [template]
  597. // CHECK:STDOUT: %complete_type.c07: <witness> = complete_type_witness %struct_type.x.767 [template]
  598. // CHECK:STDOUT: %require_complete.4ae: <witness> = require_complete_type %T [symbolic]
  599. // CHECK:STDOUT: %C.elem.66c: type = unbound_element_type %C.f2e, %T [symbolic]
  600. // CHECK:STDOUT: %i32.builtin: type = int_type signed, %int_32 [template]
  601. // CHECK:STDOUT: %complete_type.f8a: <witness> = complete_type_witness %i32.builtin [template]
  602. // CHECK:STDOUT: %C.elem.ed6: type = unbound_element_type %C.239, %i32 [template]
  603. // CHECK:STDOUT: %ImportedAccess.type: type = fn_type @ImportedAccess [template]
  604. // CHECK:STDOUT: %ImportedAccess: %ImportedAccess.type = struct_value () [template]
  605. // CHECK:STDOUT: }
  606. // CHECK:STDOUT:
  607. // CHECK:STDOUT: imports {
  608. // CHECK:STDOUT: %import_ref.148 = import_ref Main//extend_adapt_specific_type_library, C, unloaded
  609. // CHECK:STDOUT: %import_ref.c01: type = import_ref Main//extend_adapt_specific_type_library, Adapter, loaded [template = constants.%Adapter]
  610. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  611. // CHECK:STDOUT: .Int = %import_ref.2c8
  612. // CHECK:STDOUT: .ImplicitAs = %import_ref.d44
  613. // CHECK:STDOUT: import Core//prelude
  614. // CHECK:STDOUT: import Core//prelude/...
  615. // CHECK:STDOUT: }
  616. // CHECK:STDOUT: %import_ref.b5f: <witness> = import_ref Main//extend_adapt_specific_type_library, loc9_1, loaded [symbolic = @C.%complete_type (constants.%complete_type.433)]
  617. // CHECK:STDOUT: %import_ref.4c0 = import_ref Main//extend_adapt_specific_type_library, inst27 [no loc], unloaded
  618. // CHECK:STDOUT: %import_ref.262: @C.%C.elem (%C.elem.66c) = import_ref Main//extend_adapt_specific_type_library, loc8_8, loaded [template = %.22b]
  619. // CHECK:STDOUT: %import_ref.709: <witness> = import_ref Main//extend_adapt_specific_type_library, loc13_1, loaded [template = constants.%complete_type.c07]
  620. // CHECK:STDOUT: %import_ref.feb = import_ref Main//extend_adapt_specific_type_library, inst42 [no loc], unloaded
  621. // CHECK:STDOUT: %import_ref.19d12e.2: type = import_ref Main//extend_adapt_specific_type_library, loc12_21, loaded [template = constants.%C.239]
  622. // CHECK:STDOUT: }
  623. // CHECK:STDOUT:
  624. // CHECK:STDOUT: file {
  625. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  626. // CHECK:STDOUT: .C = imports.%import_ref.148
  627. // CHECK:STDOUT: .Adapter = imports.%import_ref.c01
  628. // CHECK:STDOUT: .Core = imports.%Core
  629. // CHECK:STDOUT: .ImportedAccess = %ImportedAccess.decl
  630. // CHECK:STDOUT: }
  631. // CHECK:STDOUT: %Core.import = import Core
  632. // CHECK:STDOUT: %default.import = import <invalid>
  633. // CHECK:STDOUT: %ImportedAccess.decl: %ImportedAccess.type = fn_decl @ImportedAccess [template = constants.%ImportedAccess] {
  634. // CHECK:STDOUT: %a.patt: %Adapter = binding_pattern a
  635. // CHECK:STDOUT: %a.param_patt: %Adapter = value_param_pattern %a.patt, runtime_param0
  636. // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
  637. // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param1
  638. // CHECK:STDOUT: } {
  639. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  640. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  641. // CHECK:STDOUT: %a.param: %Adapter = value_param runtime_param0
  642. // CHECK:STDOUT: %Adapter.ref: type = name_ref Adapter, imports.%import_ref.c01 [template = constants.%Adapter]
  643. // CHECK:STDOUT: %a: %Adapter = bind_name a, %a.param
  644. // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param1
  645. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  646. // CHECK:STDOUT: }
  647. // CHECK:STDOUT: }
  648. // CHECK:STDOUT:
  649. // CHECK:STDOUT: class @Adapter [from "extend_adapt_specific_type_library.carbon"] {
  650. // CHECK:STDOUT: complete_type_witness = imports.%import_ref.709
  651. // CHECK:STDOUT:
  652. // CHECK:STDOUT: !members:
  653. // CHECK:STDOUT: .Self = imports.%import_ref.feb
  654. // CHECK:STDOUT: extend imports.%import_ref.19d12e.2
  655. // CHECK:STDOUT: }
  656. // CHECK:STDOUT:
  657. // CHECK:STDOUT: generic class @C(constants.%T: type) [from "extend_adapt_specific_type_library.carbon"] {
  658. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T)]
  659. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt (constants.%T.patt)]
  660. // CHECK:STDOUT:
  661. // CHECK:STDOUT: !definition:
  662. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type @C.%T (%T) [symbolic = %require_complete (constants.%require_complete.4ae)]
  663. // CHECK:STDOUT: %C: type = class_type @C, @C(%T) [symbolic = %C (constants.%C.f2e)]
  664. // CHECK:STDOUT: %C.elem: type = unbound_element_type @C.%C (%C.f2e), @C.%T (%T) [symbolic = %C.elem (constants.%C.elem.66c)]
  665. // CHECK:STDOUT: %struct_type.x: type = struct_type {.x: @C.%T (%T)} [symbolic = %struct_type.x (constants.%struct_type.x.2ac)]
  666. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness @C.%struct_type.x (%struct_type.x.2ac) [symbolic = %complete_type (constants.%complete_type.433)]
  667. // CHECK:STDOUT:
  668. // CHECK:STDOUT: class {
  669. // CHECK:STDOUT: complete_type_witness = imports.%import_ref.b5f
  670. // CHECK:STDOUT:
  671. // CHECK:STDOUT: !members:
  672. // CHECK:STDOUT: .Self = imports.%import_ref.4c0
  673. // CHECK:STDOUT: .x = imports.%import_ref.262
  674. // CHECK:STDOUT: }
  675. // CHECK:STDOUT: }
  676. // CHECK:STDOUT:
  677. // CHECK:STDOUT: fn @ImportedAccess(%a.param_patt: %Adapter) -> %i32 {
  678. // CHECK:STDOUT: !entry:
  679. // CHECK:STDOUT: %a.ref: %Adapter = name_ref a, %a
  680. // CHECK:STDOUT: %x.ref: %C.elem.ed6 = name_ref x, imports.%import_ref.262 [template = imports.%.22b]
  681. // CHECK:STDOUT: %.loc14_11.1: %C.239 = converted %a.ref, <error> [template = <error>]
  682. // CHECK:STDOUT: %.loc14_11.2: %i32 = class_element_access <error>, element0 [template = <error>]
  683. // CHECK:STDOUT: return <error>
  684. // CHECK:STDOUT: }
  685. // CHECK:STDOUT:
  686. // CHECK:STDOUT: specific @C(constants.%T) {
  687. // CHECK:STDOUT: %T => constants.%T
  688. // CHECK:STDOUT: %T.patt => constants.%T
  689. // CHECK:STDOUT: }
  690. // CHECK:STDOUT:
  691. // CHECK:STDOUT: specific @C(constants.%i32) {
  692. // CHECK:STDOUT: %T => constants.%i32
  693. // CHECK:STDOUT: %T.patt => constants.%i32
  694. // CHECK:STDOUT:
  695. // CHECK:STDOUT: !definition:
  696. // CHECK:STDOUT: %require_complete => constants.%complete_type.f8a
  697. // CHECK:STDOUT: %C => constants.%C.239
  698. // CHECK:STDOUT: %C.elem => constants.%C.elem.ed6
  699. // CHECK:STDOUT: %struct_type.x => constants.%struct_type.x.767
  700. // CHECK:STDOUT: %complete_type => constants.%complete_type.c07
  701. // CHECK:STDOUT: }
  702. // CHECK:STDOUT:
  703. // CHECK:STDOUT: specific @C(%T) {}
  704. // CHECK:STDOUT:
  705. // CHECK:STDOUT: --- adapt_generic_type.carbon
  706. // CHECK:STDOUT:
  707. // CHECK:STDOUT: constants {
  708. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  709. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
  710. // CHECK:STDOUT: %Adapter.type: type = generic_class_type @Adapter [template]
  711. // CHECK:STDOUT: %Adapter.generic: %Adapter.type = struct_value () [template]
  712. // CHECK:STDOUT: %Adapter.0e3: type = class_type @Adapter, @Adapter(%T) [symbolic]
  713. // CHECK:STDOUT: %require_complete.4ae: <witness> = require_complete_type %T [symbolic]
  714. // CHECK:STDOUT: %complete_type.f87: <witness> = complete_type_witness %T [symbolic]
  715. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  716. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  717. // CHECK:STDOUT: %Adapter.e4c: type = class_type @Adapter, @Adapter(%i32) [template]
  718. // CHECK:STDOUT: %Convert.type: type = fn_type @Convert [template]
  719. // CHECK:STDOUT: %Convert: %Convert.type = struct_value () [template]
  720. // CHECK:STDOUT: %i32.builtin: type = int_type signed, %int_32 [template]
  721. // CHECK:STDOUT: %complete_type.f8a: <witness> = complete_type_witness %i32.builtin [template]
  722. // CHECK:STDOUT: %complete_type.1eb: <witness> = complete_type_witness %i32 [template]
  723. // CHECK:STDOUT: }
  724. // CHECK:STDOUT:
  725. // CHECK:STDOUT: imports {
  726. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  727. // CHECK:STDOUT: .Int = %import_ref.485
  728. // CHECK:STDOUT: import Core//prelude
  729. // CHECK:STDOUT: import Core//prelude/...
  730. // CHECK:STDOUT: }
  731. // CHECK:STDOUT: }
  732. // CHECK:STDOUT:
  733. // CHECK:STDOUT: file {
  734. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  735. // CHECK:STDOUT: .Core = imports.%Core
  736. // CHECK:STDOUT: .Adapter = %Adapter.decl
  737. // CHECK:STDOUT: .Convert = %Convert.decl
  738. // CHECK:STDOUT: }
  739. // CHECK:STDOUT: %Core.import = import Core
  740. // CHECK:STDOUT: %Adapter.decl: %Adapter.type = class_decl @Adapter [template = constants.%Adapter.generic] {
  741. // CHECK:STDOUT: %T.patt.loc4_15.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc4_15.2 (constants.%T.patt)]
  742. // CHECK:STDOUT: %T.param_patt: type = value_param_pattern %T.patt.loc4_15.1, runtime_param<invalid> [symbolic = %T.patt.loc4_15.2 (constants.%T.patt)]
  743. // CHECK:STDOUT: } {
  744. // CHECK:STDOUT: %T.param: type = value_param runtime_param<invalid>
  745. // CHECK:STDOUT: %T.loc4_15.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc4_15.2 (constants.%T)]
  746. // CHECK:STDOUT: }
  747. // CHECK:STDOUT: %Convert.decl: %Convert.type = fn_decl @Convert [template = constants.%Convert] {
  748. // CHECK:STDOUT: %a.patt: %Adapter.e4c = binding_pattern a
  749. // CHECK:STDOUT: %a.param_patt: %Adapter.e4c = value_param_pattern %a.patt, runtime_param0
  750. // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
  751. // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param1
  752. // CHECK:STDOUT: } {
  753. // CHECK:STDOUT: %int_32.loc8_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  754. // CHECK:STDOUT: %i32.loc8_32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  755. // CHECK:STDOUT: %a.param: %Adapter.e4c = value_param runtime_param0
  756. // CHECK:STDOUT: %.loc8: type = splice_block %Adapter [template = constants.%Adapter.e4c] {
  757. // CHECK:STDOUT: %Adapter.ref: %Adapter.type = name_ref Adapter, file.%Adapter.decl [template = constants.%Adapter.generic]
  758. // CHECK:STDOUT: %int_32.loc8_23: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  759. // CHECK:STDOUT: %i32.loc8_23: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  760. // CHECK:STDOUT: %Adapter: type = class_type @Adapter, @Adapter(constants.%i32) [template = constants.%Adapter.e4c]
  761. // CHECK:STDOUT: }
  762. // CHECK:STDOUT: %a: %Adapter.e4c = bind_name a, %a.param
  763. // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param1
  764. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  765. // CHECK:STDOUT: }
  766. // CHECK:STDOUT: }
  767. // CHECK:STDOUT:
  768. // CHECK:STDOUT: generic class @Adapter(%T.loc4_15.1: type) {
  769. // CHECK:STDOUT: %T.loc4_15.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc4_15.2 (constants.%T)]
  770. // CHECK:STDOUT: %T.patt.loc4_15.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc4_15.2 (constants.%T.patt)]
  771. // CHECK:STDOUT:
  772. // CHECK:STDOUT: !definition:
  773. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type @Adapter.%T.loc4_15.2 (%T) [symbolic = %require_complete (constants.%require_complete.4ae)]
  774. // CHECK:STDOUT: %complete_type.loc6_1.2: <witness> = complete_type_witness @Adapter.%T.loc4_15.2 (%T) [symbolic = %complete_type.loc6_1.2 (constants.%complete_type.f87)]
  775. // CHECK:STDOUT:
  776. // CHECK:STDOUT: class {
  777. // CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc4_15.1 [symbolic = %T.loc4_15.2 (constants.%T)]
  778. // CHECK:STDOUT: adapt_decl %T.ref [template]
  779. // CHECK:STDOUT: %complete_type.loc6_1.1: <witness> = complete_type_witness %T [symbolic = %complete_type.loc6_1.2 (constants.%complete_type.f87)]
  780. // CHECK:STDOUT: complete_type_witness = %complete_type.loc6_1.1
  781. // CHECK:STDOUT:
  782. // CHECK:STDOUT: !members:
  783. // CHECK:STDOUT: .Self = constants.%Adapter.0e3
  784. // CHECK:STDOUT: }
  785. // CHECK:STDOUT: }
  786. // CHECK:STDOUT:
  787. // CHECK:STDOUT: fn @Convert(%a.param_patt: %Adapter.e4c) -> %i32 {
  788. // CHECK:STDOUT: !entry:
  789. // CHECK:STDOUT: %a.ref: %Adapter.e4c = name_ref a, %a
  790. // CHECK:STDOUT: %int_32.loc9: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  791. // CHECK:STDOUT: %i32.loc9: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  792. // CHECK:STDOUT: %.loc9_12.1: %i32 = as_compatible %a.ref
  793. // CHECK:STDOUT: %.loc9_12.2: %i32 = converted %a.ref, %.loc9_12.1
  794. // CHECK:STDOUT: return %.loc9_12.2
  795. // CHECK:STDOUT: }
  796. // CHECK:STDOUT:
  797. // CHECK:STDOUT: specific @Adapter(constants.%T) {
  798. // CHECK:STDOUT: %T.loc4_15.2 => constants.%T
  799. // CHECK:STDOUT: %T.patt.loc4_15.2 => constants.%T
  800. // CHECK:STDOUT: }
  801. // CHECK:STDOUT:
  802. // CHECK:STDOUT: specific @Adapter(constants.%i32) {
  803. // CHECK:STDOUT: %T.loc4_15.2 => constants.%i32
  804. // CHECK:STDOUT: %T.patt.loc4_15.2 => constants.%i32
  805. // CHECK:STDOUT:
  806. // CHECK:STDOUT: !definition:
  807. // CHECK:STDOUT: %require_complete => constants.%complete_type.f8a
  808. // CHECK:STDOUT: %complete_type.loc6_1.2 => constants.%complete_type.1eb
  809. // CHECK:STDOUT: }
  810. // CHECK:STDOUT:
  811. // CHECK:STDOUT: --- import_adapt_generic_type.carbon
  812. // CHECK:STDOUT:
  813. // CHECK:STDOUT: constants {
  814. // CHECK:STDOUT: %Adapter.type: type = generic_class_type @Adapter [template]
  815. // CHECK:STDOUT: %Adapter.generic: %Adapter.type = struct_value () [template]
  816. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  817. // CHECK:STDOUT: %complete_type.f87: <witness> = complete_type_witness %T [symbolic]
  818. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
  819. // CHECK:STDOUT: %require_complete.4ae: <witness> = require_complete_type %T [symbolic]
  820. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  821. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  822. // CHECK:STDOUT: %Adapter.e4c: type = class_type @Adapter, @Adapter(%i32) [template]
  823. // CHECK:STDOUT: %ImportedConvert.type: type = fn_type @ImportedConvert [template]
  824. // CHECK:STDOUT: %ImportedConvert: %ImportedConvert.type = struct_value () [template]
  825. // CHECK:STDOUT: %i32.builtin: type = int_type signed, %int_32 [template]
  826. // CHECK:STDOUT: %complete_type.f8a: <witness> = complete_type_witness %i32.builtin [template]
  827. // CHECK:STDOUT: %complete_type.1eb: <witness> = complete_type_witness %i32 [template]
  828. // CHECK:STDOUT: %C: type = class_type @C [template]
  829. // CHECK:STDOUT: %C.elem: type = unbound_element_type %C, %i32 [template]
  830. // CHECK:STDOUT: %struct_type.n: type = struct_type {.n: %i32} [template]
  831. // CHECK:STDOUT: %complete_type.54b: <witness> = complete_type_witness %struct_type.n [template]
  832. // CHECK:STDOUT: %Adapter.58f: type = class_type @Adapter, @Adapter(%C) [template]
  833. // CHECK:STDOUT: %ImportedConvertLocal.type: type = fn_type @ImportedConvertLocal [template]
  834. // CHECK:STDOUT: %ImportedConvertLocal: %ImportedConvertLocal.type = struct_value () [template]
  835. // CHECK:STDOUT: %complete_type.af2: <witness> = complete_type_witness %C [template]
  836. // CHECK:STDOUT: }
  837. // CHECK:STDOUT:
  838. // CHECK:STDOUT: imports {
  839. // CHECK:STDOUT: %import_ref.bb5: %Adapter.type = import_ref Main//adapt_generic_type, Adapter, loaded [template = constants.%Adapter.generic]
  840. // CHECK:STDOUT: %import_ref.339 = import_ref Main//adapt_generic_type, Convert, unloaded
  841. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  842. // CHECK:STDOUT: .Int = %import_ref.485
  843. // CHECK:STDOUT: import Core//prelude
  844. // CHECK:STDOUT: import Core//prelude/...
  845. // CHECK:STDOUT: }
  846. // CHECK:STDOUT: %import_ref.fb3: <witness> = import_ref Main//adapt_generic_type, loc6_1, loaded [symbolic = @Adapter.%complete_type (constants.%complete_type.f87)]
  847. // CHECK:STDOUT: %import_ref.9a3 = import_ref Main//adapt_generic_type, inst27 [no loc], unloaded
  848. // CHECK:STDOUT: }
  849. // CHECK:STDOUT:
  850. // CHECK:STDOUT: file {
  851. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  852. // CHECK:STDOUT: .Adapter = imports.%import_ref.bb5
  853. // CHECK:STDOUT: .Convert = imports.%import_ref.339
  854. // CHECK:STDOUT: .Core = imports.%Core
  855. // CHECK:STDOUT: .ImportedConvert = %ImportedConvert.decl
  856. // CHECK:STDOUT: .C = %C.decl
  857. // CHECK:STDOUT: .ImportedConvertLocal = %ImportedConvertLocal.decl
  858. // CHECK:STDOUT: }
  859. // CHECK:STDOUT: %Core.import = import Core
  860. // CHECK:STDOUT: %default.import = import <invalid>
  861. // CHECK:STDOUT: %ImportedConvert.decl: %ImportedConvert.type = fn_decl @ImportedConvert [template = constants.%ImportedConvert] {
  862. // CHECK:STDOUT: %a.patt: %Adapter.e4c = binding_pattern a
  863. // CHECK:STDOUT: %a.param_patt: %Adapter.e4c = value_param_pattern %a.patt, runtime_param0
  864. // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
  865. // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param1
  866. // CHECK:STDOUT: } {
  867. // CHECK:STDOUT: %int_32.loc6_40: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  868. // CHECK:STDOUT: %i32.loc6_40: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  869. // CHECK:STDOUT: %a.param: %Adapter.e4c = value_param runtime_param0
  870. // CHECK:STDOUT: %.loc6: type = splice_block %Adapter [template = constants.%Adapter.e4c] {
  871. // CHECK:STDOUT: %Adapter.ref: %Adapter.type = name_ref Adapter, imports.%import_ref.bb5 [template = constants.%Adapter.generic]
  872. // CHECK:STDOUT: %int_32.loc6_31: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  873. // CHECK:STDOUT: %i32.loc6_31: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  874. // CHECK:STDOUT: %Adapter: type = class_type @Adapter, @Adapter(constants.%i32) [template = constants.%Adapter.e4c]
  875. // CHECK:STDOUT: }
  876. // CHECK:STDOUT: %a: %Adapter.e4c = bind_name a, %a.param
  877. // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param1
  878. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  879. // CHECK:STDOUT: }
  880. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  881. // CHECK:STDOUT: %ImportedConvertLocal.decl: %ImportedConvertLocal.type = fn_decl @ImportedConvertLocal [template = constants.%ImportedConvertLocal] {
  882. // CHECK:STDOUT: %a.patt: %Adapter.58f = binding_pattern a
  883. // CHECK:STDOUT: %a.param_patt: %Adapter.58f = value_param_pattern %a.patt, runtime_param0
  884. // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
  885. // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param1
  886. // CHECK:STDOUT: } {
  887. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  888. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  889. // CHECK:STDOUT: %a.param: %Adapter.58f = value_param runtime_param0
  890. // CHECK:STDOUT: %.loc14: type = splice_block %Adapter [template = constants.%Adapter.58f] {
  891. // CHECK:STDOUT: %Adapter.ref: %Adapter.type = name_ref Adapter, imports.%import_ref.bb5 [template = constants.%Adapter.generic]
  892. // CHECK:STDOUT: %C.ref.loc14: type = name_ref C, file.%C.decl [template = constants.%C]
  893. // CHECK:STDOUT: %Adapter: type = class_type @Adapter, @Adapter(constants.%C) [template = constants.%Adapter.58f]
  894. // CHECK:STDOUT: }
  895. // CHECK:STDOUT: %a: %Adapter.58f = bind_name a, %a.param
  896. // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param1
  897. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  898. // CHECK:STDOUT: }
  899. // CHECK:STDOUT: }
  900. // CHECK:STDOUT:
  901. // CHECK:STDOUT: generic class @Adapter(constants.%T: type) [from "adapt_generic_type.carbon"] {
  902. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T)]
  903. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt (constants.%T.patt)]
  904. // CHECK:STDOUT:
  905. // CHECK:STDOUT: !definition:
  906. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type @Adapter.%T (%T) [symbolic = %require_complete (constants.%require_complete.4ae)]
  907. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness @Adapter.%T (%T) [symbolic = %complete_type (constants.%complete_type.f87)]
  908. // CHECK:STDOUT:
  909. // CHECK:STDOUT: class {
  910. // CHECK:STDOUT: complete_type_witness = imports.%import_ref.fb3
  911. // CHECK:STDOUT:
  912. // CHECK:STDOUT: !members:
  913. // CHECK:STDOUT: .Self = imports.%import_ref.9a3
  914. // CHECK:STDOUT: }
  915. // CHECK:STDOUT: }
  916. // CHECK:STDOUT:
  917. // CHECK:STDOUT: class @C {
  918. // CHECK:STDOUT: %.loc11: %C.elem = field_decl n, element0 [template]
  919. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.n [template = constants.%complete_type.54b]
  920. // CHECK:STDOUT: complete_type_witness = %complete_type
  921. // CHECK:STDOUT:
  922. // CHECK:STDOUT: !members:
  923. // CHECK:STDOUT: .Self = constants.%C
  924. // CHECK:STDOUT: .n = %.loc11
  925. // CHECK:STDOUT: }
  926. // CHECK:STDOUT:
  927. // CHECK:STDOUT: fn @ImportedConvert(%a.param_patt: %Adapter.e4c) -> %i32 {
  928. // CHECK:STDOUT: !entry:
  929. // CHECK:STDOUT: %a.ref: %Adapter.e4c = name_ref a, %a
  930. // CHECK:STDOUT: %int_32.loc7: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  931. // CHECK:STDOUT: %i32.loc7: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  932. // CHECK:STDOUT: %.loc7_12.1: %i32 = as_compatible %a.ref
  933. // CHECK:STDOUT: %.loc7_12.2: %i32 = converted %a.ref, %.loc7_12.1
  934. // CHECK:STDOUT: return %.loc7_12.2
  935. // CHECK:STDOUT: }
  936. // CHECK:STDOUT:
  937. // CHECK:STDOUT: fn @ImportedConvertLocal(%a.param_patt: %Adapter.58f) -> %i32 {
  938. // CHECK:STDOUT: !entry:
  939. // CHECK:STDOUT: %a.ref: %Adapter.58f = name_ref a, %a
  940. // CHECK:STDOUT: %C.ref.loc15: type = name_ref C, file.%C.decl [template = constants.%C]
  941. // CHECK:STDOUT: %.loc15_13.1: %C = as_compatible %a.ref
  942. // CHECK:STDOUT: %.loc15_13.2: %C = converted %a.ref, %.loc15_13.1
  943. // CHECK:STDOUT: %n.ref: %C.elem = name_ref n, @C.%.loc11 [template = @C.%.loc11]
  944. // CHECK:STDOUT: %.loc15_18.1: ref %i32 = class_element_access %.loc15_13.2, element0
  945. // CHECK:STDOUT: %.loc15_18.2: %i32 = bind_value %.loc15_18.1
  946. // CHECK:STDOUT: return %.loc15_18.2
  947. // CHECK:STDOUT: }
  948. // CHECK:STDOUT:
  949. // CHECK:STDOUT: specific @Adapter(constants.%T) {
  950. // CHECK:STDOUT: %T => constants.%T
  951. // CHECK:STDOUT: %T.patt => constants.%T
  952. // CHECK:STDOUT: }
  953. // CHECK:STDOUT:
  954. // CHECK:STDOUT: specific @Adapter(constants.%i32) {
  955. // CHECK:STDOUT: %T => constants.%i32
  956. // CHECK:STDOUT: %T.patt => constants.%i32
  957. // CHECK:STDOUT:
  958. // CHECK:STDOUT: !definition:
  959. // CHECK:STDOUT: %require_complete => constants.%complete_type.f8a
  960. // CHECK:STDOUT: %complete_type => constants.%complete_type.1eb
  961. // CHECK:STDOUT: }
  962. // CHECK:STDOUT:
  963. // CHECK:STDOUT: specific @Adapter(constants.%C) {
  964. // CHECK:STDOUT: %T => constants.%C
  965. // CHECK:STDOUT: %T.patt => constants.%C
  966. // CHECK:STDOUT:
  967. // CHECK:STDOUT: !definition:
  968. // CHECK:STDOUT: %require_complete => constants.%complete_type.54b
  969. // CHECK:STDOUT: %complete_type => constants.%complete_type.af2
  970. // CHECK:STDOUT: }
  971. // CHECK:STDOUT: