base_is_generic.carbon 47 KB

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