base.carbon 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/int.carbon
  6. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  7. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  8. //
  9. // AUTOUPDATE
  10. // TIP: To test this file alone, run:
  11. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/class/inheritance/base.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/inheritance/base.carbon
  14. // --- base.carbon
  15. package Base;
  16. base class Base {
  17. var b: i32;
  18. }
  19. class Derived {
  20. extend base: Base;
  21. var d: i32;
  22. }
  23. fn Make() -> Derived {
  24. return {.base = {.b = 4}, .d = 7};
  25. }
  26. fn Access(d: Derived) -> (i32, i32) {
  27. return (d.d, d.base.b);
  28. }
  29. // --- fail_base_after_field.carbon
  30. package BaseAfterField;
  31. base class Base {
  32. }
  33. class Derived {
  34. var d: i32;
  35. // CHECK:STDERR: fail_base_after_field.carbon:[[@LINE+4]]:3: error: `base` declaration must appear before field declarations [BaseDeclAfterFieldDecl]
  36. // CHECK:STDERR: extend base: Base;
  37. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~
  38. // CHECK:STDERR:
  39. extend base: Base;
  40. }
  41. // CHECK:STDOUT: --- base.carbon
  42. // CHECK:STDOUT:
  43. // CHECK:STDOUT: constants {
  44. // CHECK:STDOUT: %Base: type = class_type @Base [concrete]
  45. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  46. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  47. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  48. // CHECK:STDOUT: %N: Core.IntLiteral = symbolic_binding N, 0 [symbolic]
  49. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  50. // CHECK:STDOUT: %Base.elem: type = unbound_element_type %Base, %i32 [concrete]
  51. // CHECK:STDOUT: %struct_type.b.0a3: type = struct_type {.b: %i32} [concrete]
  52. // CHECK:STDOUT: %complete_type.ba8: <witness> = complete_type_witness %struct_type.b.0a3 [concrete]
  53. // CHECK:STDOUT: %Derived: type = class_type @Derived [concrete]
  54. // CHECK:STDOUT: %Derived.elem.b58: type = unbound_element_type %Derived, %Base [concrete]
  55. // CHECK:STDOUT: %Derived.elem.683: type = unbound_element_type %Derived, %i32 [concrete]
  56. // CHECK:STDOUT: %struct_type.base.d.81a: type = struct_type {.base: %Base, .d: %i32} [concrete]
  57. // CHECK:STDOUT: %complete_type.3b4: <witness> = complete_type_witness %struct_type.base.d.81a [concrete]
  58. // CHECK:STDOUT: %.c4f: Core.Form = init_form %Derived [concrete]
  59. // CHECK:STDOUT: %pattern_type.db9: type = pattern_type %Derived [concrete]
  60. // CHECK:STDOUT: %Make.type: type = fn_type @Make [concrete]
  61. // CHECK:STDOUT: %Make: %Make.type = struct_value () [concrete]
  62. // CHECK:STDOUT: %int_4.0c1: Core.IntLiteral = int_value 4 [concrete]
  63. // CHECK:STDOUT: %struct_type.b.a15: type = struct_type {.b: Core.IntLiteral} [concrete]
  64. // CHECK:STDOUT: %struct.a2e: %struct_type.b.a15 = struct_value (%int_4.0c1) [concrete]
  65. // CHECK:STDOUT: %int_7.29f: Core.IntLiteral = int_value 7 [concrete]
  66. // CHECK:STDOUT: %struct_type.base.d.a20: type = struct_type {.base: %struct_type.b.a15, .d: Core.IntLiteral} [concrete]
  67. // CHECK:STDOUT: %struct.ab7: %struct_type.base.d.a20 = struct_value (%struct.a2e, %int_7.29f) [concrete]
  68. // CHECK:STDOUT: %.dfa: type = partial_type %Base [concrete]
  69. // CHECK:STDOUT: %ImplicitAs.type.cc7: type = generic_interface_type @ImplicitAs [concrete]
  70. // CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.cc7 = struct_value () [concrete]
  71. // CHECK:STDOUT: %ImplicitAs.type.e8c: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
  72. // CHECK:STDOUT: %To: Core.IntLiteral = symbolic_binding To, 0 [symbolic]
  73. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.4e6: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%To) [symbolic]
  74. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.3c2: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.4e6 = struct_value () [symbolic]
  75. // CHECK:STDOUT: %ImplicitAs.impl_witness.6bc: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.74f, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete]
  76. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.e0d: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete]
  77. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.0b5: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.e0d = struct_value () [concrete]
  78. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.e8c = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.6bc) [concrete]
  79. // CHECK:STDOUT: %ImplicitAs.WithSelf.Convert.type.b37: type = fn_type @ImplicitAs.WithSelf.Convert, @ImplicitAs.WithSelf(%i32, %ImplicitAs.facet) [concrete]
  80. // CHECK:STDOUT: %.545: type = fn_type_with_self_type %ImplicitAs.WithSelf.Convert.type.b37, %ImplicitAs.facet [concrete]
  81. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.f0c: <bound method> = bound_method %int_4.0c1, %Core.IntLiteral.as.ImplicitAs.impl.Convert.0b5 [concrete]
  82. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn: <specific function> = specific_function %Core.IntLiteral.as.ImplicitAs.impl.Convert.0b5, @Core.IntLiteral.as.ImplicitAs.impl.Convert(%int_32) [concrete]
  83. // CHECK:STDOUT: %bound_method.6d7: <bound method> = bound_method %int_4.0c1, %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete]
  84. // CHECK:STDOUT: %int_4.940: %i32 = int_value 4 [concrete]
  85. // CHECK:STDOUT: %struct.5f8: %.dfa = struct_value (%int_4.940) [concrete]
  86. // CHECK:STDOUT: %Base.val: %Base = struct_value (%int_4.940) [concrete]
  87. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.1e0: <bound method> = bound_method %int_7.29f, %Core.IntLiteral.as.ImplicitAs.impl.Convert.0b5 [concrete]
  88. // CHECK:STDOUT: %bound_method.bf2: <bound method> = bound_method %int_7.29f, %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete]
  89. // CHECK:STDOUT: %int_7.0b1: %i32 = int_value 7 [concrete]
  90. // CHECK:STDOUT: %Derived.val: %Derived = struct_value (%Base.val, %int_7.0b1) [concrete]
  91. // CHECK:STDOUT: %tuple.type.24b: type = tuple_type (type, type) [concrete]
  92. // CHECK:STDOUT: %tuple.95a: %tuple.type.24b = tuple_value (%i32, %i32) [concrete]
  93. // CHECK:STDOUT: %tuple.type.d07: type = tuple_type (%i32, %i32) [concrete]
  94. // CHECK:STDOUT: %.f32: Core.Form = init_form %tuple.type.d07 [concrete]
  95. // CHECK:STDOUT: %pattern_type.511: type = pattern_type %tuple.type.d07 [concrete]
  96. // CHECK:STDOUT: %Access.type: type = fn_type @Access [concrete]
  97. // CHECK:STDOUT: %Access: %Access.type = struct_value () [concrete]
  98. // CHECK:STDOUT: %Copy.type: type = facet_type <@Copy> [concrete]
  99. // CHECK:STDOUT: %Int.as.Copy.impl.Op.type.824: type = fn_type @Int.as.Copy.impl.Op, @Int.as.Copy.impl(%N) [symbolic]
  100. // CHECK:STDOUT: %Int.as.Copy.impl.Op.9b9: %Int.as.Copy.impl.Op.type.824 = struct_value () [symbolic]
  101. // CHECK:STDOUT: %Copy.impl_witness.f17: <witness> = impl_witness imports.%Copy.impl_witness_table.e76, @Int.as.Copy.impl(%int_32) [concrete]
  102. // CHECK:STDOUT: %Int.as.Copy.impl.Op.type.546: type = fn_type @Int.as.Copy.impl.Op, @Int.as.Copy.impl(%int_32) [concrete]
  103. // CHECK:STDOUT: %Int.as.Copy.impl.Op.664: %Int.as.Copy.impl.Op.type.546 = struct_value () [concrete]
  104. // CHECK:STDOUT: %Copy.facet: %Copy.type = facet_value %i32, (%Copy.impl_witness.f17) [concrete]
  105. // CHECK:STDOUT: %Copy.WithSelf.Op.type.081: type = fn_type @Copy.WithSelf.Op, @Copy.WithSelf(%Copy.facet) [concrete]
  106. // CHECK:STDOUT: %.8e2: type = fn_type_with_self_type %Copy.WithSelf.Op.type.081, %Copy.facet [concrete]
  107. // CHECK:STDOUT: %Int.as.Copy.impl.Op.specific_fn: <specific function> = specific_function %Int.as.Copy.impl.Op.664, @Int.as.Copy.impl.Op(%int_32) [concrete]
  108. // CHECK:STDOUT: }
  109. // CHECK:STDOUT:
  110. // CHECK:STDOUT: imports {
  111. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  112. // CHECK:STDOUT: .Int = %Core.Int
  113. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  114. // CHECK:STDOUT: .Copy = %Core.Copy
  115. // CHECK:STDOUT: import Core//prelude
  116. // CHECK:STDOUT: import Core//prelude/...
  117. // CHECK:STDOUT: }
  118. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/parts/int, Int, loaded [concrete = constants.%Int.generic]
  119. // CHECK:STDOUT: %Core.ImplicitAs: %ImplicitAs.type.cc7 = import_ref Core//prelude/parts/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic]
  120. // CHECK:STDOUT: %Core.import_ref.42d: @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.4e6) = import_ref Core//prelude/parts/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.3c2)]
  121. // CHECK:STDOUT: %ImplicitAs.impl_witness_table.74f = impl_witness_table (%Core.import_ref.42d), @Core.IntLiteral.as.ImplicitAs.impl [concrete]
  122. // CHECK:STDOUT: %Core.Copy: type = import_ref Core//prelude/parts/copy, Copy, loaded [concrete = constants.%Copy.type]
  123. // CHECK:STDOUT: %Core.import_ref.18d: @Int.as.Copy.impl.%Int.as.Copy.impl.Op.type (%Int.as.Copy.impl.Op.type.824) = import_ref Core//prelude/parts/int, loc{{\d+_\d+}}, loaded [symbolic = @Int.as.Copy.impl.%Int.as.Copy.impl.Op (constants.%Int.as.Copy.impl.Op.9b9)]
  124. // CHECK:STDOUT: %Copy.impl_witness_table.e76 = impl_witness_table (%Core.import_ref.18d), @Int.as.Copy.impl [concrete]
  125. // CHECK:STDOUT: }
  126. // CHECK:STDOUT:
  127. // CHECK:STDOUT: file {
  128. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  129. // CHECK:STDOUT: .Core = imports.%Core
  130. // CHECK:STDOUT: .Base = %Base.decl
  131. // CHECK:STDOUT: .Derived = %Derived.decl
  132. // CHECK:STDOUT: .Make = %Make.decl
  133. // CHECK:STDOUT: .Access = %Access.decl
  134. // CHECK:STDOUT: }
  135. // CHECK:STDOUT: %Core.import = import Core
  136. // CHECK:STDOUT: %Base.decl: type = class_decl @Base [concrete = constants.%Base] {} {}
  137. // CHECK:STDOUT: %Derived.decl: type = class_decl @Derived [concrete = constants.%Derived] {} {}
  138. // CHECK:STDOUT: %Make.decl: %Make.type = fn_decl @Make [concrete = constants.%Make] {
  139. // CHECK:STDOUT: %return.param_patt: %pattern_type.db9 = out_param_pattern [concrete]
  140. // CHECK:STDOUT: %return.patt: %pattern_type.db9 = return_slot_pattern %return.param_patt, %Derived.ref [concrete]
  141. // CHECK:STDOUT: } {
  142. // CHECK:STDOUT: %Derived.ref: type = name_ref Derived, file.%Derived.decl [concrete = constants.%Derived]
  143. // CHECK:STDOUT: %.loc13: Core.Form = init_form %Derived.ref [concrete = constants.%.c4f]
  144. // CHECK:STDOUT: %return.param: ref %Derived = out_param call_param0
  145. // CHECK:STDOUT: %return: ref %Derived = return_slot %return.param
  146. // CHECK:STDOUT: }
  147. // CHECK:STDOUT: %Access.decl: %Access.type = fn_decl @Access [concrete = constants.%Access] {
  148. // CHECK:STDOUT: %d.param_patt: %pattern_type.db9 = value_param_pattern [concrete]
  149. // CHECK:STDOUT: %d.patt: %pattern_type.db9 = at_binding_pattern d, %d.param_patt [concrete]
  150. // CHECK:STDOUT: %return.param_patt: %pattern_type.511 = out_param_pattern [concrete]
  151. // CHECK:STDOUT: %return.patt: %pattern_type.511 = return_slot_pattern %return.param_patt, %.loc17_35.2 [concrete]
  152. // CHECK:STDOUT: } {
  153. // CHECK:STDOUT: %i32.loc17_27: type = type_literal constants.%i32 [concrete = constants.%i32]
  154. // CHECK:STDOUT: %i32.loc17_32: type = type_literal constants.%i32 [concrete = constants.%i32]
  155. // CHECK:STDOUT: %.loc17_35.1: %tuple.type.24b = tuple_literal (%i32.loc17_27, %i32.loc17_32) [concrete = constants.%tuple.95a]
  156. // CHECK:STDOUT: %.loc17_35.2: type = converted %.loc17_35.1, constants.%tuple.type.d07 [concrete = constants.%tuple.type.d07]
  157. // CHECK:STDOUT: %.loc17_35.3: Core.Form = init_form %.loc17_35.2 [concrete = constants.%.f32]
  158. // CHECK:STDOUT: %d.param: %Derived = value_param call_param0
  159. // CHECK:STDOUT: %Derived.ref: type = name_ref Derived, file.%Derived.decl [concrete = constants.%Derived]
  160. // CHECK:STDOUT: %d: %Derived = value_binding d, %d.param
  161. // CHECK:STDOUT: %return.param: ref %tuple.type.d07 = out_param call_param1
  162. // CHECK:STDOUT: %return: ref %tuple.type.d07 = return_slot %return.param
  163. // CHECK:STDOUT: }
  164. // CHECK:STDOUT: }
  165. // CHECK:STDOUT:
  166. // CHECK:STDOUT: class @Base {
  167. // CHECK:STDOUT: %i32: type = type_literal constants.%i32 [concrete = constants.%i32]
  168. // CHECK:STDOUT: %.loc4: %Base.elem = field_decl b, element0 [concrete]
  169. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%struct_type.b.0a3 [concrete = constants.%complete_type.ba8]
  170. // CHECK:STDOUT: complete_type_witness = %complete_type
  171. // CHECK:STDOUT:
  172. // CHECK:STDOUT: !members:
  173. // CHECK:STDOUT: .Self = constants.%Base
  174. // CHECK:STDOUT: .b = %.loc4
  175. // CHECK:STDOUT: }
  176. // CHECK:STDOUT:
  177. // CHECK:STDOUT: class @Derived {
  178. // CHECK:STDOUT: %Base.ref: type = name_ref Base, file.%Base.decl [concrete = constants.%Base]
  179. // CHECK:STDOUT: %.loc8: %Derived.elem.b58 = base_decl %Base.ref, element0 [concrete]
  180. // CHECK:STDOUT: %i32: type = type_literal constants.%i32 [concrete = constants.%i32]
  181. // CHECK:STDOUT: %.loc10: %Derived.elem.683 = field_decl d, element1 [concrete]
  182. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%struct_type.base.d.81a [concrete = constants.%complete_type.3b4]
  183. // CHECK:STDOUT: complete_type_witness = %complete_type
  184. // CHECK:STDOUT:
  185. // CHECK:STDOUT: !members:
  186. // CHECK:STDOUT: .Self = constants.%Derived
  187. // CHECK:STDOUT: .Base = <poisoned>
  188. // CHECK:STDOUT: .base = %.loc8
  189. // CHECK:STDOUT: .d = %.loc10
  190. // CHECK:STDOUT: extend %Base.ref
  191. // CHECK:STDOUT: }
  192. // CHECK:STDOUT:
  193. // CHECK:STDOUT: fn @Make() -> out %return.param: %Derived {
  194. // CHECK:STDOUT: !entry:
  195. // CHECK:STDOUT: %int_4: Core.IntLiteral = int_value 4 [concrete = constants.%int_4.0c1]
  196. // CHECK:STDOUT: %.loc14_26.1: %struct_type.b.a15 = struct_literal (%int_4) [concrete = constants.%struct.a2e]
  197. // CHECK:STDOUT: %int_7: Core.IntLiteral = int_value 7 [concrete = constants.%int_7.29f]
  198. // CHECK:STDOUT: %.loc14_35.1: %struct_type.base.d.a20 = struct_literal (%.loc14_26.1, %int_7) [concrete = constants.%struct.ab7]
  199. // CHECK:STDOUT: %impl.elem0.loc14_26: %.545 = impl_witness_access constants.%ImplicitAs.impl_witness.6bc, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.0b5]
  200. // CHECK:STDOUT: %bound_method.loc14_26.1: <bound method> = bound_method %int_4, %impl.elem0.loc14_26 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.f0c]
  201. // CHECK:STDOUT: %specific_fn.loc14_26: <specific function> = specific_function %impl.elem0.loc14_26, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn]
  202. // CHECK:STDOUT: %bound_method.loc14_26.2: <bound method> = bound_method %int_4, %specific_fn.loc14_26 [concrete = constants.%bound_method.6d7]
  203. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc14_26: init %i32 = call %bound_method.loc14_26.2(%int_4) [concrete = constants.%int_4.940]
  204. // CHECK:STDOUT: %.loc14_26.2: init %i32 = converted %int_4, %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc14_26 [concrete = constants.%int_4.940]
  205. // CHECK:STDOUT: %.loc14_35.2: ref %.dfa = class_element_access %return.param, element0
  206. // CHECK:STDOUT: %.loc14_26.3: ref %i32 = class_element_access %.loc14_35.2, element0
  207. // CHECK:STDOUT: %.loc14_26.4: init %i32 to %.loc14_26.3 = in_place_init %.loc14_26.2 [concrete = constants.%int_4.940]
  208. // CHECK:STDOUT: %.loc14_26.5: init %.dfa to %.loc14_35.2 = class_init (%.loc14_26.4) [concrete = constants.%struct.5f8]
  209. // CHECK:STDOUT: %.loc14_35.3: init %.dfa = converted %.loc14_26.1, %.loc14_26.5 [concrete = constants.%struct.5f8]
  210. // CHECK:STDOUT: %.loc14_35.4: init %Base = as_compatible %.loc14_35.3 [concrete = constants.%Base.val]
  211. // CHECK:STDOUT: %impl.elem0.loc14_35: %.545 = impl_witness_access constants.%ImplicitAs.impl_witness.6bc, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.0b5]
  212. // CHECK:STDOUT: %bound_method.loc14_35.1: <bound method> = bound_method %int_7, %impl.elem0.loc14_35 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.1e0]
  213. // CHECK:STDOUT: %specific_fn.loc14_35: <specific function> = specific_function %impl.elem0.loc14_35, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn]
  214. // CHECK:STDOUT: %bound_method.loc14_35.2: <bound method> = bound_method %int_7, %specific_fn.loc14_35 [concrete = constants.%bound_method.bf2]
  215. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc14_35: init %i32 = call %bound_method.loc14_35.2(%int_7) [concrete = constants.%int_7.0b1]
  216. // CHECK:STDOUT: %.loc14_35.5: init %i32 = converted %int_7, %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc14_35 [concrete = constants.%int_7.0b1]
  217. // CHECK:STDOUT: %.loc14_35.6: ref %i32 = class_element_access %return.param, element1
  218. // CHECK:STDOUT: %.loc14_35.7: init %i32 to %.loc14_35.6 = in_place_init %.loc14_35.5 [concrete = constants.%int_7.0b1]
  219. // CHECK:STDOUT: %.loc14_35.8: init %Derived to %return.param = class_init (%.loc14_35.4, %.loc14_35.7) [concrete = constants.%Derived.val]
  220. // CHECK:STDOUT: %.loc14_36: init %Derived = converted %.loc14_35.1, %.loc14_35.8 [concrete = constants.%Derived.val]
  221. // CHECK:STDOUT: return %.loc14_36 to %return.param
  222. // CHECK:STDOUT: }
  223. // CHECK:STDOUT:
  224. // CHECK:STDOUT: fn @Access(%d.param: %Derived) -> out %return.param: %tuple.type.d07 {
  225. // CHECK:STDOUT: !entry:
  226. // CHECK:STDOUT: %d.ref.loc18_11: %Derived = name_ref d, %d
  227. // CHECK:STDOUT: %d.ref.loc18_12: %Derived.elem.683 = name_ref d, @Derived.%.loc10 [concrete = @Derived.%.loc10]
  228. // CHECK:STDOUT: %.loc18_12.1: ref %i32 = class_element_access %d.ref.loc18_11, element1
  229. // CHECK:STDOUT: %.loc18_12.2: %i32 = acquire_value %.loc18_12.1
  230. // CHECK:STDOUT: %d.ref.loc18_16: %Derived = name_ref d, %d
  231. // CHECK:STDOUT: %base.ref: %Derived.elem.b58 = name_ref base, @Derived.%.loc8 [concrete = @Derived.%.loc8]
  232. // CHECK:STDOUT: %.loc18_17.1: ref %Base = class_element_access %d.ref.loc18_16, element0
  233. // CHECK:STDOUT: %.loc18_17.2: %Base = acquire_value %.loc18_17.1
  234. // CHECK:STDOUT: %b.ref: %Base.elem = name_ref b, @Base.%.loc4 [concrete = @Base.%.loc4]
  235. // CHECK:STDOUT: %.loc18_22.1: ref %i32 = class_element_access %.loc18_17.2, element0
  236. // CHECK:STDOUT: %.loc18_22.2: %i32 = acquire_value %.loc18_22.1
  237. // CHECK:STDOUT: %.loc18_24.1: %tuple.type.d07 = tuple_literal (%.loc18_12.2, %.loc18_22.2)
  238. // CHECK:STDOUT: %impl.elem0.loc18_12: %.8e2 = impl_witness_access constants.%Copy.impl_witness.f17, element0 [concrete = constants.%Int.as.Copy.impl.Op.664]
  239. // CHECK:STDOUT: %bound_method.loc18_12.1: <bound method> = bound_method %.loc18_12.2, %impl.elem0.loc18_12
  240. // CHECK:STDOUT: %specific_fn.loc18_12: <specific function> = specific_function %impl.elem0.loc18_12, @Int.as.Copy.impl.Op(constants.%int_32) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn]
  241. // CHECK:STDOUT: %bound_method.loc18_12.2: <bound method> = bound_method %.loc18_12.2, %specific_fn.loc18_12
  242. // CHECK:STDOUT: %Int.as.Copy.impl.Op.call.loc18_12: init %i32 = call %bound_method.loc18_12.2(%.loc18_12.2)
  243. // CHECK:STDOUT: %tuple.elem0: ref %i32 = tuple_access %return.param, element0
  244. // CHECK:STDOUT: %.loc18_24.2: init %i32 to %tuple.elem0 = in_place_init %Int.as.Copy.impl.Op.call.loc18_12
  245. // CHECK:STDOUT: %impl.elem0.loc18_22: %.8e2 = impl_witness_access constants.%Copy.impl_witness.f17, element0 [concrete = constants.%Int.as.Copy.impl.Op.664]
  246. // CHECK:STDOUT: %bound_method.loc18_22.1: <bound method> = bound_method %.loc18_22.2, %impl.elem0.loc18_22
  247. // CHECK:STDOUT: %specific_fn.loc18_22: <specific function> = specific_function %impl.elem0.loc18_22, @Int.as.Copy.impl.Op(constants.%int_32) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn]
  248. // CHECK:STDOUT: %bound_method.loc18_22.2: <bound method> = bound_method %.loc18_22.2, %specific_fn.loc18_22
  249. // CHECK:STDOUT: %Int.as.Copy.impl.Op.call.loc18_22: init %i32 = call %bound_method.loc18_22.2(%.loc18_22.2)
  250. // CHECK:STDOUT: %tuple.elem1: ref %i32 = tuple_access %return.param, element1
  251. // CHECK:STDOUT: %.loc18_24.3: init %i32 to %tuple.elem1 = in_place_init %Int.as.Copy.impl.Op.call.loc18_22
  252. // CHECK:STDOUT: %.loc18_24.4: init %tuple.type.d07 to %return.param = tuple_init (%.loc18_24.2, %.loc18_24.3)
  253. // CHECK:STDOUT: %.loc18_25: init %tuple.type.d07 = converted %.loc18_24.1, %.loc18_24.4
  254. // CHECK:STDOUT: return %.loc18_25 to %return.param
  255. // CHECK:STDOUT: }
  256. // CHECK:STDOUT:
  257. // CHECK:STDOUT: --- fail_base_after_field.carbon
  258. // CHECK:STDOUT:
  259. // CHECK:STDOUT: constants {
  260. // CHECK:STDOUT: %Base: type = class_type @Base [concrete]
  261. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  262. // CHECK:STDOUT: %complete_type.357: <witness> = complete_type_witness %empty_struct_type [concrete]
  263. // CHECK:STDOUT: %Derived: type = class_type @Derived [concrete]
  264. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  265. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  266. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  267. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  268. // CHECK:STDOUT: %Derived.elem: type = unbound_element_type %Derived, %i32 [concrete]
  269. // CHECK:STDOUT: %struct_type.d: type = struct_type {.d: %i32} [concrete]
  270. // CHECK:STDOUT: %complete_type.860: <witness> = complete_type_witness %struct_type.d [concrete]
  271. // CHECK:STDOUT: }
  272. // CHECK:STDOUT:
  273. // CHECK:STDOUT: imports {
  274. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  275. // CHECK:STDOUT: .Int = %Core.Int
  276. // CHECK:STDOUT: import Core//prelude
  277. // CHECK:STDOUT: import Core//prelude/...
  278. // CHECK:STDOUT: }
  279. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/parts/int, Int, loaded [concrete = constants.%Int.generic]
  280. // CHECK:STDOUT: }
  281. // CHECK:STDOUT:
  282. // CHECK:STDOUT: file {
  283. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  284. // CHECK:STDOUT: .Core = imports.%Core
  285. // CHECK:STDOUT: .Base = %Base.decl
  286. // CHECK:STDOUT: .Derived = %Derived.decl
  287. // CHECK:STDOUT: }
  288. // CHECK:STDOUT: %Core.import = import Core
  289. // CHECK:STDOUT: %Base.decl: type = class_decl @Base [concrete = constants.%Base] {} {}
  290. // CHECK:STDOUT: %Derived.decl: type = class_decl @Derived [concrete = constants.%Derived] {} {}
  291. // CHECK:STDOUT: }
  292. // CHECK:STDOUT:
  293. // CHECK:STDOUT: class @Base {
  294. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type.357]
  295. // CHECK:STDOUT: complete_type_witness = %complete_type
  296. // CHECK:STDOUT:
  297. // CHECK:STDOUT: !members:
  298. // CHECK:STDOUT: .Self = constants.%Base
  299. // CHECK:STDOUT: }
  300. // CHECK:STDOUT:
  301. // CHECK:STDOUT: class @Derived {
  302. // CHECK:STDOUT: %i32: type = type_literal constants.%i32 [concrete = constants.%i32]
  303. // CHECK:STDOUT: %.loc7: %Derived.elem = field_decl d, element0 [concrete]
  304. // CHECK:STDOUT: %Base.ref: type = name_ref Base, file.%Base.decl [concrete = constants.%Base]
  305. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%struct_type.d [concrete = constants.%complete_type.860]
  306. // CHECK:STDOUT: complete_type_witness = %complete_type
  307. // CHECK:STDOUT:
  308. // CHECK:STDOUT: !members:
  309. // CHECK:STDOUT: .Self = constants.%Derived
  310. // CHECK:STDOUT: .d = %.loc7
  311. // CHECK:STDOUT: .Base = <poisoned>
  312. // CHECK:STDOUT: }
  313. // CHECK:STDOUT: