adapt.carbon 56 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000
  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.37e: type = class_type @C, @C(%T) [symbolic]
  97. // CHECK:STDOUT: %require_complete.db1: <witness> = require_complete_type %T [symbolic]
  98. // CHECK:STDOUT: %C.elem.5ab: type = unbound_element_type %C.37e, %T [symbolic]
  99. // CHECK:STDOUT: %struct_type.x.710: type = struct_type {.x: %T} [symbolic]
  100. // CHECK:STDOUT: %complete_type.60a: <witness> = complete_type_witness %struct_type.x.710 [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.268: 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.dd4: type = unbound_element_type %C.268, %i32 [template]
  108. // CHECK:STDOUT: %struct_type.x.b74: type = struct_type {.x: %i32} [template]
  109. // CHECK:STDOUT: %complete_type.f6d: <witness> = complete_type_witness %struct_type.x.b74 [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.187
  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.db1)]
  160. // CHECK:STDOUT: %C: type = class_type @C, @C(%T.loc4_9.2) [symbolic = %C (constants.%C.37e)]
  161. // CHECK:STDOUT: %C.elem: type = unbound_element_type @C.%C (%C.37e), @C.%T.loc4_9.2 (%T) [symbolic = %C.elem (constants.%C.elem.5ab)]
  162. // CHECK:STDOUT: %struct_type.x: type = struct_type {.x: @C.%T.loc4_9.2 (%T)} [symbolic = %struct_type.x (constants.%struct_type.x.710)]
  163. // CHECK:STDOUT: %complete_type.loc6_1.2: <witness> = complete_type_witness @C.%struct_type.x (%struct_type.x.710) [symbolic = %complete_type.loc6_1.2 (constants.%complete_type.60a)]
  164. // CHECK:STDOUT:
  165. // CHECK:STDOUT: class {
  166. // CHECK:STDOUT: %.loc5: @C.%C.elem (%C.elem.5ab) = field_decl x, element0 [template]
  167. // CHECK:STDOUT: %complete_type.loc6_1.1: <witness> = complete_type_witness %struct_type.x.710 [symbolic = %complete_type.loc6_1.2 (constants.%complete_type.60a)]
  168. // CHECK:STDOUT:
  169. // CHECK:STDOUT: !members:
  170. // CHECK:STDOUT: .Self = constants.%C.37e
  171. // CHECK:STDOUT: .x = %.loc5
  172. // CHECK:STDOUT: complete_type_witness = %complete_type.loc6_1.1
  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.268]
  181. // CHECK:STDOUT: adapt_decl %C [template]
  182. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.x.b74 [template = constants.%complete_type.f6d]
  183. // CHECK:STDOUT:
  184. // CHECK:STDOUT: !members:
  185. // CHECK:STDOUT: .Self = constants.%Adapter
  186. // CHECK:STDOUT: complete_type_witness = %complete_type
  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.268]
  196. // CHECK:STDOUT: %.loc13_13.1: %C.268 = as_compatible %a.ref
  197. // CHECK:STDOUT: %.loc13_13.2: %C.268 = converted %a.ref, %.loc13_13.1
  198. // CHECK:STDOUT: %x.ref: %C.elem.dd4 = 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.268
  218. // CHECK:STDOUT: %C.elem => constants.%C.elem.dd4
  219. // CHECK:STDOUT: %struct_type.x => constants.%struct_type.x.b74
  220. // CHECK:STDOUT: %complete_type.loc6_1.2 => constants.%complete_type.f6d
  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.710: type = struct_type {.x: %T} [symbolic]
  233. // CHECK:STDOUT: %complete_type.60a: <witness> = complete_type_witness %struct_type.x.710 [symbolic]
  234. // CHECK:STDOUT: %C.df4: type = class_type @C, @C(%T) [symbolic]
  235. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
  236. // CHECK:STDOUT: %C.3f8: type = class_type @C, @C(%i32) [template]
  237. // CHECK:STDOUT: %struct_type.x.6d6: type = struct_type {.x: %i32} [template]
  238. // CHECK:STDOUT: %complete_type.555: <witness> = complete_type_witness %struct_type.x.6d6 [template]
  239. // CHECK:STDOUT: %require_complete.db1: <witness> = require_complete_type %T [symbolic]
  240. // CHECK:STDOUT: %C.elem.0d5: type = unbound_element_type %C.df4, %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.f99: type = unbound_element_type %C.3f8, %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.26e: %C.type = import_ref Main//adapt_specific_type, C, loaded [template = constants.%C.generic]
  250. // CHECK:STDOUT: %import_ref.abc: type = import_ref Main//adapt_specific_type, Adapter, loaded [template = constants.%Adapter]
  251. // CHECK:STDOUT: %import_ref.92d = import_ref Main//adapt_specific_type, Access, unloaded
  252. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  253. // CHECK:STDOUT: .Int = %import_ref.d69
  254. // CHECK:STDOUT: import Core//prelude
  255. // CHECK:STDOUT: import Core//prelude/...
  256. // CHECK:STDOUT: }
  257. // CHECK:STDOUT: %import_ref.3ee: <witness> = import_ref Main//adapt_specific_type, loc6_1, loaded [symbolic = @C.%complete_type (constants.%complete_type.60a)]
  258. // CHECK:STDOUT: %import_ref.495 = import_ref Main//adapt_specific_type, inst27 [no loc], unloaded
  259. // CHECK:STDOUT: %import_ref.ec6: @C.%C.elem (%C.elem.0d5) = import_ref Main//adapt_specific_type, loc5_8, loaded [template = %.8d2]
  260. // CHECK:STDOUT: %import_ref.377: <witness> = import_ref Main//adapt_specific_type, loc10_1, loaded [template = constants.%complete_type.555]
  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.26e
  267. // CHECK:STDOUT: .Adapter = imports.%import_ref.abc
  268. // CHECK:STDOUT: .Access = imports.%import_ref.92d
  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.abc [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: !members:
  292. // CHECK:STDOUT: .Self = imports.%import_ref.feb
  293. // CHECK:STDOUT: complete_type_witness = imports.%import_ref.377
  294. // CHECK:STDOUT: }
  295. // CHECK:STDOUT:
  296. // CHECK:STDOUT: generic class @C(constants.%T: type) [from "adapt_specific_type.carbon"] {
  297. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T)]
  298. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt (constants.%T.patt)]
  299. // CHECK:STDOUT:
  300. // CHECK:STDOUT: !definition:
  301. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type @C.%T (%T) [symbolic = %require_complete (constants.%require_complete.db1)]
  302. // CHECK:STDOUT: %C: type = class_type @C, @C(%T) [symbolic = %C (constants.%C.df4)]
  303. // CHECK:STDOUT: %C.elem: type = unbound_element_type @C.%C (%C.df4), @C.%T (%T) [symbolic = %C.elem (constants.%C.elem.0d5)]
  304. // CHECK:STDOUT: %struct_type.x: type = struct_type {.x: @C.%T (%T)} [symbolic = %struct_type.x (constants.%struct_type.x.710)]
  305. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness @C.%struct_type.x (%struct_type.x.710) [symbolic = %complete_type (constants.%complete_type.60a)]
  306. // CHECK:STDOUT:
  307. // CHECK:STDOUT: class {
  308. // CHECK:STDOUT: !members:
  309. // CHECK:STDOUT: .Self = imports.%import_ref.495
  310. // CHECK:STDOUT: .x = imports.%import_ref.ec6
  311. // CHECK:STDOUT: complete_type_witness = imports.%import_ref.3ee
  312. // CHECK:STDOUT: }
  313. // CHECK:STDOUT: }
  314. // CHECK:STDOUT:
  315. // CHECK:STDOUT: fn @ImportedAccess(%a.param_patt: %Adapter) -> %i32 {
  316. // CHECK:STDOUT: !entry:
  317. // CHECK:STDOUT: %a.ref: %Adapter = name_ref a, %a
  318. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, imports.%import_ref.26e [template = constants.%C.generic]
  319. // CHECK:STDOUT: %int_32.loc7: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  320. // CHECK:STDOUT: %i32.loc7: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  321. // CHECK:STDOUT: %C: type = class_type @C, @C(constants.%i32) [template = constants.%C.3f8]
  322. // CHECK:STDOUT: %.loc7_13.1: %C.3f8 = as_compatible %a.ref
  323. // CHECK:STDOUT: %.loc7_13.2: %C.3f8 = converted %a.ref, %.loc7_13.1
  324. // CHECK:STDOUT: %x.ref: %C.elem.f99 = name_ref x, imports.%import_ref.ec6 [template = imports.%.8d2]
  325. // CHECK:STDOUT: %.loc7_23.1: ref %i32 = class_element_access %.loc7_13.2, element0
  326. // CHECK:STDOUT: %.loc7_23.2: %i32 = bind_value %.loc7_23.1
  327. // CHECK:STDOUT: return %.loc7_23.2
  328. // CHECK:STDOUT: }
  329. // CHECK:STDOUT:
  330. // CHECK:STDOUT: specific @C(constants.%T) {
  331. // CHECK:STDOUT: %T => constants.%T
  332. // CHECK:STDOUT: %T.patt => constants.%T
  333. // CHECK:STDOUT: }
  334. // CHECK:STDOUT:
  335. // CHECK:STDOUT: specific @C(constants.%i32) {
  336. // CHECK:STDOUT: %T => constants.%i32
  337. // CHECK:STDOUT: %T.patt => constants.%i32
  338. // CHECK:STDOUT:
  339. // CHECK:STDOUT: !definition:
  340. // CHECK:STDOUT: %require_complete => constants.%complete_type.f8a
  341. // CHECK:STDOUT: %C => constants.%C.3f8
  342. // CHECK:STDOUT: %C.elem => constants.%C.elem.f99
  343. // CHECK:STDOUT: %struct_type.x => constants.%struct_type.x.6d6
  344. // CHECK:STDOUT: %complete_type => constants.%complete_type.555
  345. // CHECK:STDOUT: }
  346. // CHECK:STDOUT:
  347. // CHECK:STDOUT: specific @C(%T) {}
  348. // CHECK:STDOUT:
  349. // CHECK:STDOUT: --- fail_todo_extend_adapt_specific_type.carbon
  350. // CHECK:STDOUT:
  351. // CHECK:STDOUT: constants {
  352. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  353. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
  354. // CHECK:STDOUT: %C.type: type = generic_class_type @C [template]
  355. // CHECK:STDOUT: %C.generic: %C.type = struct_value () [template]
  356. // CHECK:STDOUT: %C.37e: type = class_type @C, @C(%T) [symbolic]
  357. // CHECK:STDOUT: %require_complete.db1: <witness> = require_complete_type %T [symbolic]
  358. // CHECK:STDOUT: %C.elem.5ab: type = unbound_element_type %C.37e, %T [symbolic]
  359. // CHECK:STDOUT: %struct_type.x.710: type = struct_type {.x: %T} [symbolic]
  360. // CHECK:STDOUT: %complete_type.60a: <witness> = complete_type_witness %struct_type.x.710 [symbolic]
  361. // CHECK:STDOUT: %Adapter: type = class_type @Adapter [template]
  362. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  363. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  364. // CHECK:STDOUT: %C.268: type = class_type @C, @C(%i32) [template]
  365. // CHECK:STDOUT: %i32.builtin: type = int_type signed, %int_32 [template]
  366. // CHECK:STDOUT: %complete_type.f8a: <witness> = complete_type_witness %i32.builtin [template]
  367. // CHECK:STDOUT: %C.elem.dd4: type = unbound_element_type %C.268, %i32 [template]
  368. // CHECK:STDOUT: %struct_type.x.b74: type = struct_type {.x: %i32} [template]
  369. // CHECK:STDOUT: %complete_type.f6d: <witness> = complete_type_witness %struct_type.x.b74 [template]
  370. // CHECK:STDOUT: %Access.type: type = fn_type @Access [template]
  371. // CHECK:STDOUT: %Access: %Access.type = struct_value () [template]
  372. // CHECK:STDOUT: }
  373. // CHECK:STDOUT:
  374. // CHECK:STDOUT: imports {
  375. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  376. // CHECK:STDOUT: .Int = %import_ref.187
  377. // CHECK:STDOUT: .ImplicitAs = %import_ref.a69
  378. // CHECK:STDOUT: import Core//prelude
  379. // CHECK:STDOUT: import Core//prelude/...
  380. // CHECK:STDOUT: }
  381. // CHECK:STDOUT: }
  382. // CHECK:STDOUT:
  383. // CHECK:STDOUT: file {
  384. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  385. // CHECK:STDOUT: .Core = imports.%Core
  386. // CHECK:STDOUT: .C = %C.decl
  387. // CHECK:STDOUT: .Adapter = %Adapter.decl
  388. // CHECK:STDOUT: .Access = %Access.decl
  389. // CHECK:STDOUT: }
  390. // CHECK:STDOUT: %Core.import = import Core
  391. // CHECK:STDOUT: %C.decl: %C.type = class_decl @C [template = constants.%C.generic] {
  392. // CHECK:STDOUT: %T.patt.loc4_9.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc4_9.2 (constants.%T.patt)]
  393. // 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)]
  394. // CHECK:STDOUT: } {
  395. // CHECK:STDOUT: %T.param: type = value_param runtime_param<invalid>
  396. // CHECK:STDOUT: %T.loc4_9.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc4_9.2 (constants.%T)]
  397. // CHECK:STDOUT: }
  398. // CHECK:STDOUT: %Adapter.decl: type = class_decl @Adapter [template = constants.%Adapter] {} {}
  399. // CHECK:STDOUT: %Access.decl: %Access.type = fn_decl @Access [template = constants.%Access] {
  400. // CHECK:STDOUT: %a.patt: %Adapter = binding_pattern a
  401. // CHECK:STDOUT: %a.param_patt: %Adapter = value_param_pattern %a.patt, runtime_param0
  402. // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
  403. // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param1
  404. // CHECK:STDOUT: } {
  405. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  406. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  407. // CHECK:STDOUT: %a.param: %Adapter = value_param runtime_param0
  408. // CHECK:STDOUT: %Adapter.ref: type = name_ref Adapter, file.%Adapter.decl [template = constants.%Adapter]
  409. // CHECK:STDOUT: %a: %Adapter = bind_name a, %a.param
  410. // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param1
  411. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  412. // CHECK:STDOUT: }
  413. // CHECK:STDOUT: }
  414. // CHECK:STDOUT:
  415. // CHECK:STDOUT: generic class @C(%T.loc4_9.1: type) {
  416. // CHECK:STDOUT: %T.loc4_9.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc4_9.2 (constants.%T)]
  417. // CHECK:STDOUT: %T.patt.loc4_9.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc4_9.2 (constants.%T.patt)]
  418. // CHECK:STDOUT:
  419. // CHECK:STDOUT: !definition:
  420. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type @C.%T.loc4_9.2 (%T) [symbolic = %require_complete (constants.%require_complete.db1)]
  421. // CHECK:STDOUT: %C: type = class_type @C, @C(%T.loc4_9.2) [symbolic = %C (constants.%C.37e)]
  422. // CHECK:STDOUT: %C.elem: type = unbound_element_type @C.%C (%C.37e), @C.%T.loc4_9.2 (%T) [symbolic = %C.elem (constants.%C.elem.5ab)]
  423. // CHECK:STDOUT: %struct_type.x: type = struct_type {.x: @C.%T.loc4_9.2 (%T)} [symbolic = %struct_type.x (constants.%struct_type.x.710)]
  424. // CHECK:STDOUT: %complete_type.loc6_1.2: <witness> = complete_type_witness @C.%struct_type.x (%struct_type.x.710) [symbolic = %complete_type.loc6_1.2 (constants.%complete_type.60a)]
  425. // CHECK:STDOUT:
  426. // CHECK:STDOUT: class {
  427. // CHECK:STDOUT: %.loc5: @C.%C.elem (%C.elem.5ab) = field_decl x, element0 [template]
  428. // CHECK:STDOUT: %complete_type.loc6_1.1: <witness> = complete_type_witness %struct_type.x.710 [symbolic = %complete_type.loc6_1.2 (constants.%complete_type.60a)]
  429. // CHECK:STDOUT:
  430. // CHECK:STDOUT: !members:
  431. // CHECK:STDOUT: .Self = constants.%C.37e
  432. // CHECK:STDOUT: .x = %.loc5
  433. // CHECK:STDOUT: complete_type_witness = %complete_type.loc6_1.1
  434. // CHECK:STDOUT: }
  435. // CHECK:STDOUT: }
  436. // CHECK:STDOUT:
  437. // CHECK:STDOUT: class @Adapter {
  438. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, file.%C.decl [template = constants.%C.generic]
  439. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  440. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  441. // CHECK:STDOUT: %C: type = class_type @C, @C(constants.%i32) [template = constants.%C.268]
  442. // CHECK:STDOUT: adapt_decl %C [template]
  443. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.x.b74 [template = constants.%complete_type.f6d]
  444. // CHECK:STDOUT:
  445. // CHECK:STDOUT: !members:
  446. // CHECK:STDOUT: .Self = constants.%Adapter
  447. // CHECK:STDOUT: extend %C
  448. // CHECK:STDOUT: complete_type_witness = %complete_type
  449. // CHECK:STDOUT: }
  450. // CHECK:STDOUT:
  451. // CHECK:STDOUT: fn @Access(%a.param_patt: %Adapter) -> %i32 {
  452. // CHECK:STDOUT: !entry:
  453. // CHECK:STDOUT: %a.ref: %Adapter = name_ref a, %a
  454. // CHECK:STDOUT: %x.ref: %C.elem.dd4 = name_ref x, @C.%.loc5 [template = @C.%.loc5]
  455. // CHECK:STDOUT: %.loc21_11.1: %C.268 = converted %a.ref, <error> [template = <error>]
  456. // CHECK:STDOUT: %.loc21_11.2: %i32 = class_element_access <error>, element0 [template = <error>]
  457. // CHECK:STDOUT: return <error>
  458. // CHECK:STDOUT: }
  459. // CHECK:STDOUT:
  460. // CHECK:STDOUT: specific @C(constants.%T) {
  461. // CHECK:STDOUT: %T.loc4_9.2 => constants.%T
  462. // CHECK:STDOUT: %T.patt.loc4_9.2 => constants.%T
  463. // CHECK:STDOUT: }
  464. // CHECK:STDOUT:
  465. // CHECK:STDOUT: specific @C(%T.loc4_9.2) {}
  466. // CHECK:STDOUT:
  467. // CHECK:STDOUT: specific @C(constants.%i32) {
  468. // CHECK:STDOUT: %T.loc4_9.2 => constants.%i32
  469. // CHECK:STDOUT: %T.patt.loc4_9.2 => constants.%i32
  470. // CHECK:STDOUT:
  471. // CHECK:STDOUT: !definition:
  472. // CHECK:STDOUT: %require_complete => constants.%complete_type.f8a
  473. // CHECK:STDOUT: %C => constants.%C.268
  474. // CHECK:STDOUT: %C.elem => constants.%C.elem.dd4
  475. // CHECK:STDOUT: %struct_type.x => constants.%struct_type.x.b74
  476. // CHECK:STDOUT: %complete_type.loc6_1.2 => constants.%complete_type.f6d
  477. // CHECK:STDOUT: }
  478. // CHECK:STDOUT:
  479. // CHECK:STDOUT: --- extend_adapt_specific_type_library.carbon
  480. // CHECK:STDOUT:
  481. // CHECK:STDOUT: constants {
  482. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  483. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
  484. // CHECK:STDOUT: %C.type: type = generic_class_type @C [template]
  485. // CHECK:STDOUT: %C.generic: %C.type = struct_value () [template]
  486. // CHECK:STDOUT: %C.37e: type = class_type @C, @C(%T) [symbolic]
  487. // CHECK:STDOUT: %require_complete.db1: <witness> = require_complete_type %T [symbolic]
  488. // CHECK:STDOUT: %C.elem.5ab: type = unbound_element_type %C.37e, %T [symbolic]
  489. // CHECK:STDOUT: %struct_type.x.710: type = struct_type {.x: %T} [symbolic]
  490. // CHECK:STDOUT: %complete_type.60a: <witness> = complete_type_witness %struct_type.x.710 [symbolic]
  491. // CHECK:STDOUT: %Adapter: type = class_type @Adapter [template]
  492. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  493. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  494. // CHECK:STDOUT: %C.268: type = class_type @C, @C(%i32) [template]
  495. // CHECK:STDOUT: %i32.builtin: type = int_type signed, %int_32 [template]
  496. // CHECK:STDOUT: %complete_type.f8a: <witness> = complete_type_witness %i32.builtin [template]
  497. // CHECK:STDOUT: %C.elem.dd4: type = unbound_element_type %C.268, %i32 [template]
  498. // CHECK:STDOUT: %struct_type.x.b74: type = struct_type {.x: %i32} [template]
  499. // CHECK:STDOUT: %complete_type.f6d: <witness> = complete_type_witness %struct_type.x.b74 [template]
  500. // CHECK:STDOUT: }
  501. // CHECK:STDOUT:
  502. // CHECK:STDOUT: imports {
  503. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  504. // CHECK:STDOUT: .Int = %import_ref.187
  505. // CHECK:STDOUT: import Core//prelude
  506. // CHECK:STDOUT: import Core//prelude/...
  507. // CHECK:STDOUT: }
  508. // CHECK:STDOUT: }
  509. // CHECK:STDOUT:
  510. // CHECK:STDOUT: file {
  511. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  512. // CHECK:STDOUT: .Core = imports.%Core
  513. // CHECK:STDOUT: .C = %C.decl
  514. // CHECK:STDOUT: .Adapter = %Adapter.decl
  515. // CHECK:STDOUT: }
  516. // CHECK:STDOUT: %Core.import = import Core
  517. // CHECK:STDOUT: %C.decl: %C.type = class_decl @C [template = constants.%C.generic] {
  518. // CHECK:STDOUT: %T.patt.loc7_9.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc7_9.2 (constants.%T.patt)]
  519. // 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)]
  520. // CHECK:STDOUT: } {
  521. // CHECK:STDOUT: %T.param: type = value_param runtime_param<invalid>
  522. // CHECK:STDOUT: %T.loc7_9.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc7_9.2 (constants.%T)]
  523. // CHECK:STDOUT: }
  524. // CHECK:STDOUT: %Adapter.decl: type = class_decl @Adapter [template = constants.%Adapter] {} {}
  525. // CHECK:STDOUT: }
  526. // CHECK:STDOUT:
  527. // CHECK:STDOUT: generic class @C(%T.loc7_9.1: type) {
  528. // CHECK:STDOUT: %T.loc7_9.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc7_9.2 (constants.%T)]
  529. // CHECK:STDOUT: %T.patt.loc7_9.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc7_9.2 (constants.%T.patt)]
  530. // CHECK:STDOUT:
  531. // CHECK:STDOUT: !definition:
  532. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type @C.%T.loc7_9.2 (%T) [symbolic = %require_complete (constants.%require_complete.db1)]
  533. // CHECK:STDOUT: %C: type = class_type @C, @C(%T.loc7_9.2) [symbolic = %C (constants.%C.37e)]
  534. // CHECK:STDOUT: %C.elem: type = unbound_element_type @C.%C (%C.37e), @C.%T.loc7_9.2 (%T) [symbolic = %C.elem (constants.%C.elem.5ab)]
  535. // CHECK:STDOUT: %struct_type.x: type = struct_type {.x: @C.%T.loc7_9.2 (%T)} [symbolic = %struct_type.x (constants.%struct_type.x.710)]
  536. // CHECK:STDOUT: %complete_type.loc9_1.2: <witness> = complete_type_witness @C.%struct_type.x (%struct_type.x.710) [symbolic = %complete_type.loc9_1.2 (constants.%complete_type.60a)]
  537. // CHECK:STDOUT:
  538. // CHECK:STDOUT: class {
  539. // CHECK:STDOUT: %.loc8: @C.%C.elem (%C.elem.5ab) = field_decl x, element0 [template]
  540. // CHECK:STDOUT: %complete_type.loc9_1.1: <witness> = complete_type_witness %struct_type.x.710 [symbolic = %complete_type.loc9_1.2 (constants.%complete_type.60a)]
  541. // CHECK:STDOUT:
  542. // CHECK:STDOUT: !members:
  543. // CHECK:STDOUT: .Self = constants.%C.37e
  544. // CHECK:STDOUT: .x = %.loc8
  545. // CHECK:STDOUT: complete_type_witness = %complete_type.loc9_1.1
  546. // CHECK:STDOUT: }
  547. // CHECK:STDOUT: }
  548. // CHECK:STDOUT:
  549. // CHECK:STDOUT: class @Adapter {
  550. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, file.%C.decl [template = constants.%C.generic]
  551. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  552. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  553. // CHECK:STDOUT: %C: type = class_type @C, @C(constants.%i32) [template = constants.%C.268]
  554. // CHECK:STDOUT: adapt_decl %C [template]
  555. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.x.b74 [template = constants.%complete_type.f6d]
  556. // CHECK:STDOUT:
  557. // CHECK:STDOUT: !members:
  558. // CHECK:STDOUT: .Self = constants.%Adapter
  559. // CHECK:STDOUT: extend %C
  560. // CHECK:STDOUT: complete_type_witness = %complete_type
  561. // CHECK:STDOUT: }
  562. // CHECK:STDOUT:
  563. // CHECK:STDOUT: specific @C(constants.%T) {
  564. // CHECK:STDOUT: %T.loc7_9.2 => constants.%T
  565. // CHECK:STDOUT: %T.patt.loc7_9.2 => constants.%T
  566. // CHECK:STDOUT: }
  567. // CHECK:STDOUT:
  568. // CHECK:STDOUT: specific @C(%T.loc7_9.2) {}
  569. // CHECK:STDOUT:
  570. // CHECK:STDOUT: specific @C(constants.%i32) {
  571. // CHECK:STDOUT: %T.loc7_9.2 => constants.%i32
  572. // CHECK:STDOUT: %T.patt.loc7_9.2 => constants.%i32
  573. // CHECK:STDOUT:
  574. // CHECK:STDOUT: !definition:
  575. // CHECK:STDOUT: %require_complete => constants.%complete_type.f8a
  576. // CHECK:STDOUT: %C => constants.%C.268
  577. // CHECK:STDOUT: %C.elem => constants.%C.elem.dd4
  578. // CHECK:STDOUT: %struct_type.x => constants.%struct_type.x.b74
  579. // CHECK:STDOUT: %complete_type.loc9_1.2 => constants.%complete_type.f6d
  580. // CHECK:STDOUT: }
  581. // CHECK:STDOUT:
  582. // CHECK:STDOUT: --- fail_todo_import_extend_adapt_specific_type.carbon
  583. // CHECK:STDOUT:
  584. // CHECK:STDOUT: constants {
  585. // CHECK:STDOUT: %Adapter: type = class_type @Adapter [template]
  586. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  587. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  588. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  589. // CHECK:STDOUT: %struct_type.x.710: type = struct_type {.x: %T} [symbolic]
  590. // CHECK:STDOUT: %complete_type.60a: <witness> = complete_type_witness %struct_type.x.710 [symbolic]
  591. // CHECK:STDOUT: %C.df4: type = class_type @C, @C(%T) [symbolic]
  592. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
  593. // CHECK:STDOUT: %C.3f8: type = class_type @C, @C(%i32) [template]
  594. // CHECK:STDOUT: %struct_type.x.6d6: type = struct_type {.x: %i32} [template]
  595. // CHECK:STDOUT: %complete_type.555: <witness> = complete_type_witness %struct_type.x.6d6 [template]
  596. // CHECK:STDOUT: %require_complete.db1: <witness> = require_complete_type %T [symbolic]
  597. // CHECK:STDOUT: %C.elem.0d5: type = unbound_element_type %C.df4, %T [symbolic]
  598. // CHECK:STDOUT: %i32.builtin: type = int_type signed, %int_32 [template]
  599. // CHECK:STDOUT: %complete_type.f8a: <witness> = complete_type_witness %i32.builtin [template]
  600. // CHECK:STDOUT: %C.elem.f99: type = unbound_element_type %C.3f8, %i32 [template]
  601. // CHECK:STDOUT: %ImportedAccess.type: type = fn_type @ImportedAccess [template]
  602. // CHECK:STDOUT: %ImportedAccess: %ImportedAccess.type = struct_value () [template]
  603. // CHECK:STDOUT: }
  604. // CHECK:STDOUT:
  605. // CHECK:STDOUT: imports {
  606. // CHECK:STDOUT: %import_ref.2081 = import_ref Main//extend_adapt_specific_type_library, C, unloaded
  607. // CHECK:STDOUT: %import_ref.abc: type = import_ref Main//extend_adapt_specific_type_library, Adapter, loaded [template = constants.%Adapter]
  608. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  609. // CHECK:STDOUT: .Int = %import_ref.d69
  610. // CHECK:STDOUT: .ImplicitAs = %import_ref.a69
  611. // CHECK:STDOUT: import Core//prelude
  612. // CHECK:STDOUT: import Core//prelude/...
  613. // CHECK:STDOUT: }
  614. // CHECK:STDOUT: %import_ref.3ee: <witness> = import_ref Main//extend_adapt_specific_type_library, loc9_1, loaded [symbolic = @C.%complete_type (constants.%complete_type.60a)]
  615. // CHECK:STDOUT: %import_ref.495 = import_ref Main//extend_adapt_specific_type_library, inst27 [no loc], unloaded
  616. // CHECK:STDOUT: %import_ref.ec6: @C.%C.elem (%C.elem.0d5) = import_ref Main//extend_adapt_specific_type_library, loc8_8, loaded [template = %.8d2]
  617. // CHECK:STDOUT: %import_ref.377: <witness> = import_ref Main//extend_adapt_specific_type_library, loc13_1, loaded [template = constants.%complete_type.555]
  618. // CHECK:STDOUT: %import_ref.feb = import_ref Main//extend_adapt_specific_type_library, inst42 [no loc], unloaded
  619. // CHECK:STDOUT: %import_ref.f9d349.2: type = import_ref Main//extend_adapt_specific_type_library, loc12_21, loaded [template = constants.%C.3f8]
  620. // CHECK:STDOUT: }
  621. // CHECK:STDOUT:
  622. // CHECK:STDOUT: file {
  623. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  624. // CHECK:STDOUT: .C = imports.%import_ref.2081
  625. // CHECK:STDOUT: .Adapter = imports.%import_ref.abc
  626. // CHECK:STDOUT: .Core = imports.%Core
  627. // CHECK:STDOUT: .ImportedAccess = %ImportedAccess.decl
  628. // CHECK:STDOUT: }
  629. // CHECK:STDOUT: %Core.import = import Core
  630. // CHECK:STDOUT: %default.import = import <invalid>
  631. // CHECK:STDOUT: %ImportedAccess.decl: %ImportedAccess.type = fn_decl @ImportedAccess [template = constants.%ImportedAccess] {
  632. // CHECK:STDOUT: %a.patt: %Adapter = binding_pattern a
  633. // CHECK:STDOUT: %a.param_patt: %Adapter = value_param_pattern %a.patt, runtime_param0
  634. // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
  635. // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param1
  636. // CHECK:STDOUT: } {
  637. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  638. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  639. // CHECK:STDOUT: %a.param: %Adapter = value_param runtime_param0
  640. // CHECK:STDOUT: %Adapter.ref: type = name_ref Adapter, imports.%import_ref.abc [template = constants.%Adapter]
  641. // CHECK:STDOUT: %a: %Adapter = bind_name a, %a.param
  642. // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param1
  643. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  644. // CHECK:STDOUT: }
  645. // CHECK:STDOUT: }
  646. // CHECK:STDOUT:
  647. // CHECK:STDOUT: class @Adapter [from "extend_adapt_specific_type_library.carbon"] {
  648. // CHECK:STDOUT: !members:
  649. // CHECK:STDOUT: .Self = imports.%import_ref.feb
  650. // CHECK:STDOUT: extend imports.%import_ref.f9d349.2
  651. // CHECK:STDOUT: complete_type_witness = imports.%import_ref.377
  652. // CHECK:STDOUT: }
  653. // CHECK:STDOUT:
  654. // CHECK:STDOUT: generic class @C(constants.%T: type) [from "extend_adapt_specific_type_library.carbon"] {
  655. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T)]
  656. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt (constants.%T.patt)]
  657. // CHECK:STDOUT:
  658. // CHECK:STDOUT: !definition:
  659. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type @C.%T (%T) [symbolic = %require_complete (constants.%require_complete.db1)]
  660. // CHECK:STDOUT: %C: type = class_type @C, @C(%T) [symbolic = %C (constants.%C.df4)]
  661. // CHECK:STDOUT: %C.elem: type = unbound_element_type @C.%C (%C.df4), @C.%T (%T) [symbolic = %C.elem (constants.%C.elem.0d5)]
  662. // CHECK:STDOUT: %struct_type.x: type = struct_type {.x: @C.%T (%T)} [symbolic = %struct_type.x (constants.%struct_type.x.710)]
  663. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness @C.%struct_type.x (%struct_type.x.710) [symbolic = %complete_type (constants.%complete_type.60a)]
  664. // CHECK:STDOUT:
  665. // CHECK:STDOUT: class {
  666. // CHECK:STDOUT: !members:
  667. // CHECK:STDOUT: .Self = imports.%import_ref.495
  668. // CHECK:STDOUT: .x = imports.%import_ref.ec6
  669. // CHECK:STDOUT: complete_type_witness = imports.%import_ref.3ee
  670. // CHECK:STDOUT: }
  671. // CHECK:STDOUT: }
  672. // CHECK:STDOUT:
  673. // CHECK:STDOUT: fn @ImportedAccess(%a.param_patt: %Adapter) -> %i32 {
  674. // CHECK:STDOUT: !entry:
  675. // CHECK:STDOUT: %a.ref: %Adapter = name_ref a, %a
  676. // CHECK:STDOUT: %x.ref: %C.elem.f99 = name_ref x, imports.%import_ref.ec6 [template = imports.%.8d2]
  677. // CHECK:STDOUT: %.loc14_11.1: %C.3f8 = converted %a.ref, <error> [template = <error>]
  678. // CHECK:STDOUT: %.loc14_11.2: %i32 = class_element_access <error>, element0 [template = <error>]
  679. // CHECK:STDOUT: return <error>
  680. // CHECK:STDOUT: }
  681. // CHECK:STDOUT:
  682. // CHECK:STDOUT: specific @C(constants.%T) {
  683. // CHECK:STDOUT: %T => constants.%T
  684. // CHECK:STDOUT: %T.patt => constants.%T
  685. // CHECK:STDOUT: }
  686. // CHECK:STDOUT:
  687. // CHECK:STDOUT: specific @C(constants.%i32) {
  688. // CHECK:STDOUT: %T => constants.%i32
  689. // CHECK:STDOUT: %T.patt => constants.%i32
  690. // CHECK:STDOUT:
  691. // CHECK:STDOUT: !definition:
  692. // CHECK:STDOUT: %require_complete => constants.%complete_type.f8a
  693. // CHECK:STDOUT: %C => constants.%C.3f8
  694. // CHECK:STDOUT: %C.elem => constants.%C.elem.f99
  695. // CHECK:STDOUT: %struct_type.x => constants.%struct_type.x.6d6
  696. // CHECK:STDOUT: %complete_type => constants.%complete_type.555
  697. // CHECK:STDOUT: }
  698. // CHECK:STDOUT:
  699. // CHECK:STDOUT: specific @C(%T) {}
  700. // CHECK:STDOUT:
  701. // CHECK:STDOUT: --- adapt_generic_type.carbon
  702. // CHECK:STDOUT:
  703. // CHECK:STDOUT: constants {
  704. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  705. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
  706. // CHECK:STDOUT: %Adapter.type: type = generic_class_type @Adapter [template]
  707. // CHECK:STDOUT: %Adapter.generic: %Adapter.type = struct_value () [template]
  708. // CHECK:STDOUT: %Adapter.f46: type = class_type @Adapter, @Adapter(%T) [symbolic]
  709. // CHECK:STDOUT: %require_complete.db1: <witness> = require_complete_type %T [symbolic]
  710. // CHECK:STDOUT: %complete_type.27d: <witness> = complete_type_witness %T [symbolic]
  711. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  712. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  713. // CHECK:STDOUT: %Adapter.1d5: type = class_type @Adapter, @Adapter(%i32) [template]
  714. // CHECK:STDOUT: %Convert.type: type = fn_type @Convert [template]
  715. // CHECK:STDOUT: %Convert: %Convert.type = struct_value () [template]
  716. // CHECK:STDOUT: %i32.builtin: type = int_type signed, %int_32 [template]
  717. // CHECK:STDOUT: %complete_type.f8a: <witness> = complete_type_witness %i32.builtin [template]
  718. // CHECK:STDOUT: %complete_type.d0d: <witness> = complete_type_witness %i32 [template]
  719. // CHECK:STDOUT: }
  720. // CHECK:STDOUT:
  721. // CHECK:STDOUT: imports {
  722. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  723. // CHECK:STDOUT: .Int = %import_ref.187
  724. // CHECK:STDOUT: import Core//prelude
  725. // CHECK:STDOUT: import Core//prelude/...
  726. // CHECK:STDOUT: }
  727. // CHECK:STDOUT: }
  728. // CHECK:STDOUT:
  729. // CHECK:STDOUT: file {
  730. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  731. // CHECK:STDOUT: .Core = imports.%Core
  732. // CHECK:STDOUT: .Adapter = %Adapter.decl
  733. // CHECK:STDOUT: .Convert = %Convert.decl
  734. // CHECK:STDOUT: }
  735. // CHECK:STDOUT: %Core.import = import Core
  736. // CHECK:STDOUT: %Adapter.decl: %Adapter.type = class_decl @Adapter [template = constants.%Adapter.generic] {
  737. // CHECK:STDOUT: %T.patt.loc4_15.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc4_15.2 (constants.%T.patt)]
  738. // 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)]
  739. // CHECK:STDOUT: } {
  740. // CHECK:STDOUT: %T.param: type = value_param runtime_param<invalid>
  741. // CHECK:STDOUT: %T.loc4_15.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc4_15.2 (constants.%T)]
  742. // CHECK:STDOUT: }
  743. // CHECK:STDOUT: %Convert.decl: %Convert.type = fn_decl @Convert [template = constants.%Convert] {
  744. // CHECK:STDOUT: %a.patt: %Adapter.1d5 = binding_pattern a
  745. // CHECK:STDOUT: %a.param_patt: %Adapter.1d5 = value_param_pattern %a.patt, runtime_param0
  746. // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
  747. // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param1
  748. // CHECK:STDOUT: } {
  749. // CHECK:STDOUT: %int_32.loc8_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  750. // CHECK:STDOUT: %i32.loc8_32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  751. // CHECK:STDOUT: %a.param: %Adapter.1d5 = value_param runtime_param0
  752. // CHECK:STDOUT: %.loc8: type = splice_block %Adapter [template = constants.%Adapter.1d5] {
  753. // CHECK:STDOUT: %Adapter.ref: %Adapter.type = name_ref Adapter, file.%Adapter.decl [template = constants.%Adapter.generic]
  754. // CHECK:STDOUT: %int_32.loc8_23: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  755. // CHECK:STDOUT: %i32.loc8_23: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  756. // CHECK:STDOUT: %Adapter: type = class_type @Adapter, @Adapter(constants.%i32) [template = constants.%Adapter.1d5]
  757. // CHECK:STDOUT: }
  758. // CHECK:STDOUT: %a: %Adapter.1d5 = bind_name a, %a.param
  759. // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param1
  760. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  761. // CHECK:STDOUT: }
  762. // CHECK:STDOUT: }
  763. // CHECK:STDOUT:
  764. // CHECK:STDOUT: generic class @Adapter(%T.loc4_15.1: type) {
  765. // CHECK:STDOUT: %T.loc4_15.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc4_15.2 (constants.%T)]
  766. // CHECK:STDOUT: %T.patt.loc4_15.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc4_15.2 (constants.%T.patt)]
  767. // CHECK:STDOUT:
  768. // CHECK:STDOUT: !definition:
  769. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type @Adapter.%T.loc4_15.2 (%T) [symbolic = %require_complete (constants.%require_complete.db1)]
  770. // 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.27d)]
  771. // CHECK:STDOUT:
  772. // CHECK:STDOUT: class {
  773. // CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc4_15.1 [symbolic = %T.loc4_15.2 (constants.%T)]
  774. // CHECK:STDOUT: adapt_decl %T.ref [template]
  775. // CHECK:STDOUT: %complete_type.loc6_1.1: <witness> = complete_type_witness %T [symbolic = %complete_type.loc6_1.2 (constants.%complete_type.27d)]
  776. // CHECK:STDOUT:
  777. // CHECK:STDOUT: !members:
  778. // CHECK:STDOUT: .Self = constants.%Adapter.f46
  779. // CHECK:STDOUT: complete_type_witness = %complete_type.loc6_1.1
  780. // CHECK:STDOUT: }
  781. // CHECK:STDOUT: }
  782. // CHECK:STDOUT:
  783. // CHECK:STDOUT: fn @Convert(%a.param_patt: %Adapter.1d5) -> %i32 {
  784. // CHECK:STDOUT: !entry:
  785. // CHECK:STDOUT: %a.ref: %Adapter.1d5 = name_ref a, %a
  786. // CHECK:STDOUT: %int_32.loc9: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  787. // CHECK:STDOUT: %i32.loc9: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  788. // CHECK:STDOUT: %.loc9_12.1: %i32 = as_compatible %a.ref
  789. // CHECK:STDOUT: %.loc9_12.2: %i32 = converted %a.ref, %.loc9_12.1
  790. // CHECK:STDOUT: return %.loc9_12.2
  791. // CHECK:STDOUT: }
  792. // CHECK:STDOUT:
  793. // CHECK:STDOUT: specific @Adapter(constants.%T) {
  794. // CHECK:STDOUT: %T.loc4_15.2 => constants.%T
  795. // CHECK:STDOUT: %T.patt.loc4_15.2 => constants.%T
  796. // CHECK:STDOUT: }
  797. // CHECK:STDOUT:
  798. // CHECK:STDOUT: specific @Adapter(constants.%i32) {
  799. // CHECK:STDOUT: %T.loc4_15.2 => constants.%i32
  800. // CHECK:STDOUT: %T.patt.loc4_15.2 => constants.%i32
  801. // CHECK:STDOUT:
  802. // CHECK:STDOUT: !definition:
  803. // CHECK:STDOUT: %require_complete => constants.%complete_type.f8a
  804. // CHECK:STDOUT: %complete_type.loc6_1.2 => constants.%complete_type.d0d
  805. // CHECK:STDOUT: }
  806. // CHECK:STDOUT:
  807. // CHECK:STDOUT: --- import_adapt_generic_type.carbon
  808. // CHECK:STDOUT:
  809. // CHECK:STDOUT: constants {
  810. // CHECK:STDOUT: %Adapter.type: type = generic_class_type @Adapter [template]
  811. // CHECK:STDOUT: %Adapter.generic: %Adapter.type = struct_value () [template]
  812. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  813. // CHECK:STDOUT: %complete_type.27d: <witness> = complete_type_witness %T [symbolic]
  814. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
  815. // CHECK:STDOUT: %require_complete.db1: <witness> = require_complete_type %T [symbolic]
  816. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  817. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  818. // CHECK:STDOUT: %Adapter.070: type = class_type @Adapter, @Adapter(%i32) [template]
  819. // CHECK:STDOUT: %ImportedConvert.type: type = fn_type @ImportedConvert [template]
  820. // CHECK:STDOUT: %ImportedConvert: %ImportedConvert.type = struct_value () [template]
  821. // CHECK:STDOUT: %i32.builtin: type = int_type signed, %int_32 [template]
  822. // CHECK:STDOUT: %complete_type.f8a: <witness> = complete_type_witness %i32.builtin [template]
  823. // CHECK:STDOUT: %complete_type.d0d: <witness> = complete_type_witness %i32 [template]
  824. // CHECK:STDOUT: %C: type = class_type @C [template]
  825. // CHECK:STDOUT: %C.elem: type = unbound_element_type %C, %i32 [template]
  826. // CHECK:STDOUT: %struct_type.n: type = struct_type {.n: %i32} [template]
  827. // CHECK:STDOUT: %complete_type.9b7: <witness> = complete_type_witness %struct_type.n [template]
  828. // CHECK:STDOUT: %Adapter.e9c: type = class_type @Adapter, @Adapter(%C) [template]
  829. // CHECK:STDOUT: %ImportedConvertLocal.type: type = fn_type @ImportedConvertLocal [template]
  830. // CHECK:STDOUT: %ImportedConvertLocal: %ImportedConvertLocal.type = struct_value () [template]
  831. // CHECK:STDOUT: %complete_type.af2: <witness> = complete_type_witness %C [template]
  832. // CHECK:STDOUT: }
  833. // CHECK:STDOUT:
  834. // CHECK:STDOUT: imports {
  835. // CHECK:STDOUT: %import_ref.ff3: %Adapter.type = import_ref Main//adapt_generic_type, Adapter, loaded [template = constants.%Adapter.generic]
  836. // CHECK:STDOUT: %import_ref.00e = import_ref Main//adapt_generic_type, Convert, unloaded
  837. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  838. // CHECK:STDOUT: .Int = %import_ref.187
  839. // CHECK:STDOUT: import Core//prelude
  840. // CHECK:STDOUT: import Core//prelude/...
  841. // CHECK:STDOUT: }
  842. // CHECK:STDOUT: %import_ref.115: <witness> = import_ref Main//adapt_generic_type, loc6_1, loaded [symbolic = @Adapter.%complete_type (constants.%complete_type.27d)]
  843. // CHECK:STDOUT: %import_ref.a89 = import_ref Main//adapt_generic_type, inst27 [no loc], unloaded
  844. // CHECK:STDOUT: }
  845. // CHECK:STDOUT:
  846. // CHECK:STDOUT: file {
  847. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  848. // CHECK:STDOUT: .Adapter = imports.%import_ref.ff3
  849. // CHECK:STDOUT: .Convert = imports.%import_ref.00e
  850. // CHECK:STDOUT: .Core = imports.%Core
  851. // CHECK:STDOUT: .ImportedConvert = %ImportedConvert.decl
  852. // CHECK:STDOUT: .C = %C.decl
  853. // CHECK:STDOUT: .ImportedConvertLocal = %ImportedConvertLocal.decl
  854. // CHECK:STDOUT: }
  855. // CHECK:STDOUT: %Core.import = import Core
  856. // CHECK:STDOUT: %default.import = import <invalid>
  857. // CHECK:STDOUT: %ImportedConvert.decl: %ImportedConvert.type = fn_decl @ImportedConvert [template = constants.%ImportedConvert] {
  858. // CHECK:STDOUT: %a.patt: %Adapter.070 = binding_pattern a
  859. // CHECK:STDOUT: %a.param_patt: %Adapter.070 = value_param_pattern %a.patt, runtime_param0
  860. // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
  861. // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param1
  862. // CHECK:STDOUT: } {
  863. // CHECK:STDOUT: %int_32.loc6_40: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  864. // CHECK:STDOUT: %i32.loc6_40: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  865. // CHECK:STDOUT: %a.param: %Adapter.070 = value_param runtime_param0
  866. // CHECK:STDOUT: %.loc6: type = splice_block %Adapter [template = constants.%Adapter.070] {
  867. // CHECK:STDOUT: %Adapter.ref: %Adapter.type = name_ref Adapter, imports.%import_ref.ff3 [template = constants.%Adapter.generic]
  868. // CHECK:STDOUT: %int_32.loc6_31: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  869. // CHECK:STDOUT: %i32.loc6_31: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  870. // CHECK:STDOUT: %Adapter: type = class_type @Adapter, @Adapter(constants.%i32) [template = constants.%Adapter.070]
  871. // CHECK:STDOUT: }
  872. // CHECK:STDOUT: %a: %Adapter.070 = bind_name a, %a.param
  873. // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param1
  874. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  875. // CHECK:STDOUT: }
  876. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  877. // CHECK:STDOUT: %ImportedConvertLocal.decl: %ImportedConvertLocal.type = fn_decl @ImportedConvertLocal [template = constants.%ImportedConvertLocal] {
  878. // CHECK:STDOUT: %a.patt: %Adapter.e9c = binding_pattern a
  879. // CHECK:STDOUT: %a.param_patt: %Adapter.e9c = value_param_pattern %a.patt, runtime_param0
  880. // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
  881. // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param1
  882. // CHECK:STDOUT: } {
  883. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  884. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  885. // CHECK:STDOUT: %a.param: %Adapter.e9c = value_param runtime_param0
  886. // CHECK:STDOUT: %.loc14: type = splice_block %Adapter [template = constants.%Adapter.e9c] {
  887. // CHECK:STDOUT: %Adapter.ref: %Adapter.type = name_ref Adapter, imports.%import_ref.ff3 [template = constants.%Adapter.generic]
  888. // CHECK:STDOUT: %C.ref.loc14: type = name_ref C, file.%C.decl [template = constants.%C]
  889. // CHECK:STDOUT: %Adapter: type = class_type @Adapter, @Adapter(constants.%C) [template = constants.%Adapter.e9c]
  890. // CHECK:STDOUT: }
  891. // CHECK:STDOUT: %a: %Adapter.e9c = bind_name a, %a.param
  892. // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param1
  893. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  894. // CHECK:STDOUT: }
  895. // CHECK:STDOUT: }
  896. // CHECK:STDOUT:
  897. // CHECK:STDOUT: generic class @Adapter(constants.%T: type) [from "adapt_generic_type.carbon"] {
  898. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T)]
  899. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt (constants.%T.patt)]
  900. // CHECK:STDOUT:
  901. // CHECK:STDOUT: !definition:
  902. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type @Adapter.%T (%T) [symbolic = %require_complete (constants.%require_complete.db1)]
  903. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness @Adapter.%T (%T) [symbolic = %complete_type (constants.%complete_type.27d)]
  904. // CHECK:STDOUT:
  905. // CHECK:STDOUT: class {
  906. // CHECK:STDOUT: !members:
  907. // CHECK:STDOUT: .Self = imports.%import_ref.a89
  908. // CHECK:STDOUT: complete_type_witness = imports.%import_ref.115
  909. // CHECK:STDOUT: }
  910. // CHECK:STDOUT: }
  911. // CHECK:STDOUT:
  912. // CHECK:STDOUT: class @C {
  913. // CHECK:STDOUT: %.loc11: %C.elem = field_decl n, element0 [template]
  914. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.n [template = constants.%complete_type.9b7]
  915. // CHECK:STDOUT:
  916. // CHECK:STDOUT: !members:
  917. // CHECK:STDOUT: .Self = constants.%C
  918. // CHECK:STDOUT: .n = %.loc11
  919. // CHECK:STDOUT: complete_type_witness = %complete_type
  920. // CHECK:STDOUT: }
  921. // CHECK:STDOUT:
  922. // CHECK:STDOUT: fn @ImportedConvert(%a.param_patt: %Adapter.070) -> %i32 {
  923. // CHECK:STDOUT: !entry:
  924. // CHECK:STDOUT: %a.ref: %Adapter.070 = name_ref a, %a
  925. // CHECK:STDOUT: %int_32.loc7: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  926. // CHECK:STDOUT: %i32.loc7: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  927. // CHECK:STDOUT: %.loc7_12.1: %i32 = as_compatible %a.ref
  928. // CHECK:STDOUT: %.loc7_12.2: %i32 = converted %a.ref, %.loc7_12.1
  929. // CHECK:STDOUT: return %.loc7_12.2
  930. // CHECK:STDOUT: }
  931. // CHECK:STDOUT:
  932. // CHECK:STDOUT: fn @ImportedConvertLocal(%a.param_patt: %Adapter.e9c) -> %i32 {
  933. // CHECK:STDOUT: !entry:
  934. // CHECK:STDOUT: %a.ref: %Adapter.e9c = name_ref a, %a
  935. // CHECK:STDOUT: %C.ref.loc15: type = name_ref C, file.%C.decl [template = constants.%C]
  936. // CHECK:STDOUT: %.loc15_13.1: %C = as_compatible %a.ref
  937. // CHECK:STDOUT: %.loc15_13.2: %C = converted %a.ref, %.loc15_13.1
  938. // CHECK:STDOUT: %n.ref: %C.elem = name_ref n, @C.%.loc11 [template = @C.%.loc11]
  939. // CHECK:STDOUT: %.loc15_18.1: ref %i32 = class_element_access %.loc15_13.2, element0
  940. // CHECK:STDOUT: %.loc15_18.2: %i32 = bind_value %.loc15_18.1
  941. // CHECK:STDOUT: return %.loc15_18.2
  942. // CHECK:STDOUT: }
  943. // CHECK:STDOUT:
  944. // CHECK:STDOUT: specific @Adapter(constants.%T) {
  945. // CHECK:STDOUT: %T => constants.%T
  946. // CHECK:STDOUT: %T.patt => constants.%T
  947. // CHECK:STDOUT: }
  948. // CHECK:STDOUT:
  949. // CHECK:STDOUT: specific @Adapter(constants.%i32) {
  950. // CHECK:STDOUT: %T => constants.%i32
  951. // CHECK:STDOUT: %T.patt => constants.%i32
  952. // CHECK:STDOUT:
  953. // CHECK:STDOUT: !definition:
  954. // CHECK:STDOUT: %require_complete => constants.%complete_type.f8a
  955. // CHECK:STDOUT: %complete_type => constants.%complete_type.d0d
  956. // CHECK:STDOUT: }
  957. // CHECK:STDOUT:
  958. // CHECK:STDOUT: specific @Adapter(constants.%C) {
  959. // CHECK:STDOUT: %T => constants.%C
  960. // CHECK:STDOUT: %T.patt => constants.%C
  961. // CHECK:STDOUT:
  962. // CHECK:STDOUT: !definition:
  963. // CHECK:STDOUT: %require_complete => constants.%complete_type.9b7
  964. // CHECK:STDOUT: %complete_type => constants.%complete_type.af2
  965. // CHECK:STDOUT: }
  966. // CHECK:STDOUT: