access_modifers.carbon 58 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837
  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/access_modifers.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/access_modifers.carbon
  14. // --- fail_private_field_access.carbon
  15. library "[[@TEST_NAME]]";
  16. class Circle {
  17. private var radius: i32;
  18. private let SOME_INTERNAL_CONSTANT: i32 = 5;
  19. private fn SomeInternalFunction() -> i32 {
  20. return 0;
  21. }
  22. fn Make() -> Self {
  23. return {.radius = 5};
  24. }
  25. }
  26. fn Run() {
  27. let circle: Circle = Circle.Make();
  28. // CHECK:STDERR: fail_private_field_access.carbon:[[@LINE+7]]:21: error: cannot access private member `radius` of type `Circle` [ClassInvalidMemberAccess]
  29. // CHECK:STDERR: let radius: i32 = circle.radius;
  30. // CHECK:STDERR: ^~~~~~~~~~~~~
  31. // CHECK:STDERR: fail_private_field_access.carbon:[[@LINE-17]]:15: note: declared here [ClassMemberDeclaration]
  32. // CHECK:STDERR: private var radius: i32;
  33. // CHECK:STDERR: ^~~~~~~~~~~
  34. // CHECK:STDERR:
  35. let radius: i32 = circle.radius;
  36. // CHECK:STDERR: fail_private_field_access.carbon:[[@LINE+7]]:3: error: cannot access private member `radius` of type `Circle` [ClassInvalidMemberAccess]
  37. // CHECK:STDERR: circle.radius = 5;
  38. // CHECK:STDERR: ^~~~~~~~~~~~~
  39. // CHECK:STDERR: fail_private_field_access.carbon:[[@LINE-25]]:15: note: declared here [ClassMemberDeclaration]
  40. // CHECK:STDERR: private var radius: i32;
  41. // CHECK:STDERR: ^~~~~~~~~~~
  42. // CHECK:STDERR:
  43. circle.radius = 5;
  44. // CHECK:STDERR: fail_private_field_access.carbon:[[@LINE+7]]:3: error: cannot access private member `SOME_INTERNAL_CONSTANT` of type `Circle` [ClassInvalidMemberAccess]
  45. // CHECK:STDERR: circle.SOME_INTERNAL_CONSTANT;
  46. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  47. // CHECK:STDERR: fail_private_field_access.carbon:[[@LINE-32]]:15: note: declared here [ClassMemberDeclaration]
  48. // CHECK:STDERR: private let SOME_INTERNAL_CONSTANT: i32 = 5;
  49. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~
  50. // CHECK:STDERR:
  51. circle.SOME_INTERNAL_CONSTANT;
  52. // CHECK:STDERR: fail_private_field_access.carbon:[[@LINE+7]]:3: error: cannot access private member `SomeInternalFunction` of type `Circle` [ClassInvalidMemberAccess]
  53. // CHECK:STDERR: circle.SomeInternalFunction();
  54. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~
  55. // CHECK:STDERR: fail_private_field_access.carbon:[[@LINE-39]]:3: note: declared here [ClassMemberDeclaration]
  56. // CHECK:STDERR: private fn SomeInternalFunction() -> i32 {
  57. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  58. // CHECK:STDERR:
  59. circle.SomeInternalFunction();
  60. }
  61. // --- fail_protected_field_access.carbon
  62. library "[[@TEST_NAME]]";
  63. class A {
  64. protected var x: i32;
  65. }
  66. fn Run() {
  67. // CHECK:STDERR: fail_protected_field_access.carbon:[[@LINE+7]]:16: error: cannot access protected member `x` of type `A` [ClassInvalidMemberAccess]
  68. // CHECK:STDERR: let x: i32 = A.x;
  69. // CHECK:STDERR: ^~~
  70. // CHECK:STDERR: fail_protected_field_access.carbon:[[@LINE-7]]:17: note: declared here [ClassMemberDeclaration]
  71. // CHECK:STDERR: protected var x: i32;
  72. // CHECK:STDERR: ^~~~~~
  73. // CHECK:STDERR:
  74. let x: i32 = A.x;
  75. }
  76. // --- instance_private_field_access_on_self.carbon
  77. library "[[@TEST_NAME]]";
  78. class Circle {
  79. private var radius: i32;
  80. fn GetRadius[self: Self]() -> i32 {
  81. return self.radius;
  82. }
  83. private fn SomeInternalFunction() -> i32 {
  84. return 0;
  85. }
  86. fn Compute[self: Self]() -> i32 {
  87. return self.SomeInternalFunction();
  88. }
  89. }
  90. // --- public_global_access.carbon
  91. library "[[@TEST_NAME]]";
  92. class A {
  93. let x: i32 = 5;
  94. }
  95. let x: i32 = A.x;
  96. // --- fail_global_access.carbon
  97. library "[[@TEST_NAME]]";
  98. class A {
  99. protected let x: i32 = 5;
  100. private let y: i32 = 5;
  101. }
  102. // CHECK:STDERR: fail_global_access.carbon:[[@LINE+7]]:14: error: cannot access protected member `x` of type `A` [ClassInvalidMemberAccess]
  103. // CHECK:STDERR: let x: i32 = A.x;
  104. // CHECK:STDERR: ^~~
  105. // CHECK:STDERR: fail_global_access.carbon:[[@LINE-7]]:17: note: declared here [ClassMemberDeclaration]
  106. // CHECK:STDERR: protected let x: i32 = 5;
  107. // CHECK:STDERR: ^
  108. // CHECK:STDERR:
  109. let x: i32 = A.x;
  110. // CHECK:STDERR: fail_global_access.carbon:[[@LINE+7]]:14: error: cannot access private member `y` of type `A` [ClassInvalidMemberAccess]
  111. // CHECK:STDERR: let y: i32 = A.y;
  112. // CHECK:STDERR: ^~~
  113. // CHECK:STDERR: fail_global_access.carbon:[[@LINE-14]]:15: note: declared here [ClassMemberDeclaration]
  114. // CHECK:STDERR: private let y: i32 = 5;
  115. // CHECK:STDERR: ^
  116. // CHECK:STDERR:
  117. let y: i32 = A.y;
  118. // --- self_access.carbon
  119. library "[[@TEST_NAME]]";
  120. class A {
  121. private fn F() {}
  122. private fn G() { Self.F(); }
  123. }
  124. // CHECK:STDOUT: --- fail_private_field_access.carbon
  125. // CHECK:STDOUT:
  126. // CHECK:STDOUT: constants {
  127. // CHECK:STDOUT: %Circle: type = class_type @Circle [concrete]
  128. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  129. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  130. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  131. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  132. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  133. // CHECK:STDOUT: %Circle.elem: type = unbound_element_type %Circle, %i32 [concrete]
  134. // CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
  135. // CHECK:STDOUT: %int_5.64b: Core.IntLiteral = int_value 5 [concrete]
  136. // CHECK:STDOUT: %ImplicitAs.type.cc7: type = generic_interface_type @ImplicitAs [concrete]
  137. // CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.cc7 = struct_value () [concrete]
  138. // CHECK:STDOUT: %ImplicitAs.type.d14: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
  139. // CHECK:STDOUT: %ImplicitAs.Convert.type.1b6: type = fn_type @ImplicitAs.Convert, @ImplicitAs(%i32) [concrete]
  140. // CHECK:STDOUT: %To: Core.IntLiteral = symbolic_binding To, 0 [symbolic]
  141. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.f51: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%To) [symbolic]
  142. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.2a1: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.f51 = struct_value () [symbolic]
  143. // CHECK:STDOUT: %ImplicitAs.impl_witness.bc9: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.132, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete]
  144. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.51e: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete]
  145. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.e9b: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.51e = struct_value () [concrete]
  146. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.d14 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.bc9) [concrete]
  147. // CHECK:STDOUT: %.322: type = fn_type_with_self_type %ImplicitAs.Convert.type.1b6, %ImplicitAs.facet [concrete]
  148. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.451: <bound method> = bound_method %int_5.64b, %Core.IntLiteral.as.ImplicitAs.impl.Convert.e9b [concrete]
  149. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn: <specific function> = specific_function %Core.IntLiteral.as.ImplicitAs.impl.Convert.e9b, @Core.IntLiteral.as.ImplicitAs.impl.Convert(%int_32) [concrete]
  150. // CHECK:STDOUT: %bound_method.c57: <bound method> = bound_method %int_5.64b, %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete]
  151. // CHECK:STDOUT: %int_5.0f6: %i32 = int_value 5 [concrete]
  152. // CHECK:STDOUT: %Circle.SomeInternalFunction.type: type = fn_type @Circle.SomeInternalFunction [concrete]
  153. // CHECK:STDOUT: %Circle.SomeInternalFunction: %Circle.SomeInternalFunction.type = struct_value () [concrete]
  154. // CHECK:STDOUT: %pattern_type.ce2: type = pattern_type %Circle [concrete]
  155. // CHECK:STDOUT: %Circle.Make.type: type = fn_type @Circle.Make [concrete]
  156. // CHECK:STDOUT: %Circle.Make: %Circle.Make.type = struct_value () [concrete]
  157. // CHECK:STDOUT: %struct_type.radius.251: type = struct_type {.radius: %i32} [concrete]
  158. // CHECK:STDOUT: %complete_type.5a5: <witness> = complete_type_witness %struct_type.radius.251 [concrete]
  159. // CHECK:STDOUT: %int_0.5c6: Core.IntLiteral = int_value 0 [concrete]
  160. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.0b3: <bound method> = bound_method %int_0.5c6, %Core.IntLiteral.as.ImplicitAs.impl.Convert.e9b [concrete]
  161. // CHECK:STDOUT: %bound_method.9be: <bound method> = bound_method %int_0.5c6, %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete]
  162. // CHECK:STDOUT: %int_0.6a9: %i32 = int_value 0 [concrete]
  163. // CHECK:STDOUT: %struct_type.radius.f47: type = struct_type {.radius: Core.IntLiteral} [concrete]
  164. // CHECK:STDOUT: %struct: %struct_type.radius.f47 = struct_value (%int_5.64b) [concrete]
  165. // CHECK:STDOUT: %Circle.val: %Circle = struct_value (%int_5.0f6) [concrete]
  166. // CHECK:STDOUT: %Run.type: type = fn_type @Run [concrete]
  167. // CHECK:STDOUT: %Run: %Run.type = struct_value () [concrete]
  168. // CHECK:STDOUT: %Destroy.type: type = facet_type <@Destroy> [concrete]
  169. // CHECK:STDOUT: %type_where: type = facet_type <type where .Self impls <CanDestroy>> [concrete]
  170. // CHECK:STDOUT: %facet_value: %type_where = facet_value %Circle, () [concrete]
  171. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.type.d7d: type = fn_type @DestroyT.binding.as_type.as.Destroy.impl.Op, @DestroyT.binding.as_type.as.Destroy.impl(%facet_value) [concrete]
  172. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.c1a: %DestroyT.binding.as_type.as.Destroy.impl.Op.type.d7d = struct_value () [concrete]
  173. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.specific_fn: <specific function> = specific_function %DestroyT.binding.as_type.as.Destroy.impl.Op.c1a, @DestroyT.binding.as_type.as.Destroy.impl.Op(%facet_value) [concrete]
  174. // CHECK:STDOUT: }
  175. // CHECK:STDOUT:
  176. // CHECK:STDOUT: imports {
  177. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  178. // CHECK:STDOUT: .Int = %Core.Int
  179. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  180. // CHECK:STDOUT: .Destroy = %Core.Destroy
  181. // CHECK:STDOUT: import Core//prelude
  182. // CHECK:STDOUT: import Core//prelude/...
  183. // CHECK:STDOUT: }
  184. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/parts/int, Int, loaded [concrete = constants.%Int.generic]
  185. // CHECK:STDOUT: %Core.ImplicitAs: %ImplicitAs.type.cc7 = import_ref Core//prelude/parts/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic]
  186. // CHECK:STDOUT: %Core.import_ref.e24: @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.f51) = 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.2a1)]
  187. // CHECK:STDOUT: %ImplicitAs.impl_witness_table.132 = impl_witness_table (%Core.import_ref.e24), @Core.IntLiteral.as.ImplicitAs.impl [concrete]
  188. // CHECK:STDOUT: %Core.Destroy: type = import_ref Core//prelude/parts/destroy, Destroy, loaded [concrete = constants.%Destroy.type]
  189. // CHECK:STDOUT: }
  190. // CHECK:STDOUT:
  191. // CHECK:STDOUT: file {
  192. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  193. // CHECK:STDOUT: .Core = imports.%Core
  194. // CHECK:STDOUT: .Circle = %Circle.decl
  195. // CHECK:STDOUT: .Run = %Run.decl
  196. // CHECK:STDOUT: }
  197. // CHECK:STDOUT: %Core.import = import Core
  198. // CHECK:STDOUT: %Circle.decl: type = class_decl @Circle [concrete = constants.%Circle] {} {}
  199. // CHECK:STDOUT: %Run.decl: %Run.type = fn_decl @Run [concrete = constants.%Run] {} {}
  200. // CHECK:STDOUT: }
  201. // CHECK:STDOUT:
  202. // CHECK:STDOUT: class @Circle {
  203. // CHECK:STDOUT: %int_32.loc5: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  204. // CHECK:STDOUT: %i32.loc5: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  205. // CHECK:STDOUT: %.loc5: %Circle.elem = field_decl radius, element0 [concrete]
  206. // CHECK:STDOUT: name_binding_decl {
  207. // CHECK:STDOUT: %SOME_INTERNAL_CONSTANT.patt: %pattern_type.7ce = value_binding_pattern SOME_INTERNAL_CONSTANT [concrete]
  208. // CHECK:STDOUT: }
  209. // CHECK:STDOUT: %int_5: Core.IntLiteral = int_value 5 [concrete = constants.%int_5.64b]
  210. // CHECK:STDOUT: %.loc6_39: type = splice_block %i32.loc6 [concrete = constants.%i32] {
  211. // CHECK:STDOUT: %int_32.loc6: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  212. // CHECK:STDOUT: %i32.loc6: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  213. // CHECK:STDOUT: }
  214. // CHECK:STDOUT: %impl.elem0: %.322 = impl_witness_access constants.%ImplicitAs.impl_witness.bc9, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.e9b]
  215. // CHECK:STDOUT: %bound_method.loc6_45.1: <bound method> = bound_method %int_5, %impl.elem0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.451]
  216. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn]
  217. // CHECK:STDOUT: %bound_method.loc6_45.2: <bound method> = bound_method %int_5, %specific_fn [concrete = constants.%bound_method.c57]
  218. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call: init %i32 = call %bound_method.loc6_45.2(%int_5) [concrete = constants.%int_5.0f6]
  219. // CHECK:STDOUT: %.loc6_45.1: %i32 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call [concrete = constants.%int_5.0f6]
  220. // CHECK:STDOUT: %.loc6_45.2: %i32 = converted %int_5, %.loc6_45.1 [concrete = constants.%int_5.0f6]
  221. // CHECK:STDOUT: %SOME_INTERNAL_CONSTANT: %i32 = value_binding SOME_INTERNAL_CONSTANT, %.loc6_45.2
  222. // CHECK:STDOUT: %Circle.SomeInternalFunction.decl: %Circle.SomeInternalFunction.type = fn_decl @Circle.SomeInternalFunction [concrete = constants.%Circle.SomeInternalFunction] {
  223. // CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern [concrete]
  224. // CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern %return.patt, call_param0 [concrete]
  225. // CHECK:STDOUT: } {
  226. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  227. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  228. // CHECK:STDOUT: %return.param: ref %i32 = out_param call_param0
  229. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  230. // CHECK:STDOUT: }
  231. // CHECK:STDOUT: %Circle.Make.decl: %Circle.Make.type = fn_decl @Circle.Make [concrete = constants.%Circle.Make] {
  232. // CHECK:STDOUT: %return.patt: %pattern_type.ce2 = return_slot_pattern [concrete]
  233. // CHECK:STDOUT: %return.param_patt: %pattern_type.ce2 = out_param_pattern %return.patt, call_param0 [concrete]
  234. // CHECK:STDOUT: } {
  235. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%Circle [concrete = constants.%Circle]
  236. // CHECK:STDOUT: %return.param: ref %Circle = out_param call_param0
  237. // CHECK:STDOUT: %return: ref %Circle = return_slot %return.param
  238. // CHECK:STDOUT: }
  239. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%struct_type.radius.251 [concrete = constants.%complete_type.5a5]
  240. // CHECK:STDOUT: complete_type_witness = %complete_type
  241. // CHECK:STDOUT:
  242. // CHECK:STDOUT: !members:
  243. // CHECK:STDOUT: .Self = constants.%Circle
  244. // CHECK:STDOUT: .radius [private] = %.loc5
  245. // CHECK:STDOUT: .SOME_INTERNAL_CONSTANT [private] = %SOME_INTERNAL_CONSTANT
  246. // CHECK:STDOUT: .SomeInternalFunction [private] = %Circle.SomeInternalFunction.decl
  247. // CHECK:STDOUT: .Make = %Circle.Make.decl
  248. // CHECK:STDOUT: }
  249. // CHECK:STDOUT:
  250. // CHECK:STDOUT: fn @Circle.SomeInternalFunction() -> %i32 {
  251. // CHECK:STDOUT: !entry:
  252. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0.5c6]
  253. // CHECK:STDOUT: %impl.elem0: %.322 = impl_witness_access constants.%ImplicitAs.impl_witness.bc9, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.e9b]
  254. // CHECK:STDOUT: %bound_method.loc9_13.1: <bound method> = bound_method %int_0, %impl.elem0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.0b3]
  255. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn]
  256. // CHECK:STDOUT: %bound_method.loc9_13.2: <bound method> = bound_method %int_0, %specific_fn [concrete = constants.%bound_method.9be]
  257. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call: init %i32 = call %bound_method.loc9_13.2(%int_0) [concrete = constants.%int_0.6a9]
  258. // CHECK:STDOUT: %.loc9: init %i32 = converted %int_0, %Core.IntLiteral.as.ImplicitAs.impl.Convert.call [concrete = constants.%int_0.6a9]
  259. // CHECK:STDOUT: return %.loc9 to %return
  260. // CHECK:STDOUT: }
  261. // CHECK:STDOUT:
  262. // CHECK:STDOUT: fn @Circle.Make() -> %return.param: %Circle {
  263. // CHECK:STDOUT: !entry:
  264. // CHECK:STDOUT: %int_5: Core.IntLiteral = int_value 5 [concrete = constants.%int_5.64b]
  265. // CHECK:STDOUT: %.loc13_24.1: %struct_type.radius.f47 = struct_literal (%int_5) [concrete = constants.%struct]
  266. // CHECK:STDOUT: %impl.elem0: %.322 = impl_witness_access constants.%ImplicitAs.impl_witness.bc9, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.e9b]
  267. // CHECK:STDOUT: %bound_method.loc13_24.1: <bound method> = bound_method %int_5, %impl.elem0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.451]
  268. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn]
  269. // CHECK:STDOUT: %bound_method.loc13_24.2: <bound method> = bound_method %int_5, %specific_fn [concrete = constants.%bound_method.c57]
  270. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call: init %i32 = call %bound_method.loc13_24.2(%int_5) [concrete = constants.%int_5.0f6]
  271. // CHECK:STDOUT: %.loc13_24.2: init %i32 = converted %int_5, %Core.IntLiteral.as.ImplicitAs.impl.Convert.call [concrete = constants.%int_5.0f6]
  272. // CHECK:STDOUT: %.loc13_24.3: ref %i32 = class_element_access %return, element0
  273. // CHECK:STDOUT: %.loc13_24.4: init %i32 = initialize_from %.loc13_24.2 to %.loc13_24.3 [concrete = constants.%int_5.0f6]
  274. // CHECK:STDOUT: %.loc13_24.5: init %Circle = class_init (%.loc13_24.4), %return [concrete = constants.%Circle.val]
  275. // CHECK:STDOUT: %.loc13_25: init %Circle = converted %.loc13_24.1, %.loc13_24.5 [concrete = constants.%Circle.val]
  276. // CHECK:STDOUT: return %.loc13_25 to %return
  277. // CHECK:STDOUT: }
  278. // CHECK:STDOUT:
  279. // CHECK:STDOUT: fn @Run() {
  280. // CHECK:STDOUT: !entry:
  281. // CHECK:STDOUT: name_binding_decl {
  282. // CHECK:STDOUT: %circle.patt: %pattern_type.ce2 = value_binding_pattern circle [concrete]
  283. // CHECK:STDOUT: }
  284. // CHECK:STDOUT: %Circle.ref.loc18_24: type = name_ref Circle, file.%Circle.decl [concrete = constants.%Circle]
  285. // CHECK:STDOUT: %Make.ref: %Circle.Make.type = name_ref Make, @Circle.%Circle.Make.decl [concrete = constants.%Circle.Make]
  286. // CHECK:STDOUT: %.loc18_36.1: ref %Circle = temporary_storage
  287. // CHECK:STDOUT: %Circle.Make.call: init %Circle = call %Make.ref() to %.loc18_36.1
  288. // CHECK:STDOUT: %Circle.ref.loc18_15: type = name_ref Circle, file.%Circle.decl [concrete = constants.%Circle]
  289. // CHECK:STDOUT: %.loc18_36.2: ref %Circle = temporary %.loc18_36.1, %Circle.Make.call
  290. // CHECK:STDOUT: %.loc18_36.3: %Circle = acquire_value %.loc18_36.2
  291. // CHECK:STDOUT: %circle: %Circle = value_binding circle, %.loc18_36.3
  292. // CHECK:STDOUT: name_binding_decl {
  293. // CHECK:STDOUT: %radius.patt: %pattern_type.7ce = value_binding_pattern radius [concrete]
  294. // CHECK:STDOUT: }
  295. // CHECK:STDOUT: %circle.ref.loc26: %Circle = name_ref circle, %circle
  296. // CHECK:STDOUT: %radius.ref.loc26: <error> = name_ref radius, <error> [concrete = <error>]
  297. // CHECK:STDOUT: %.loc26: type = splice_block %i32 [concrete = constants.%i32] {
  298. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  299. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  300. // CHECK:STDOUT: }
  301. // CHECK:STDOUT: %radius: %i32 = value_binding radius, <error> [concrete = <error>]
  302. // CHECK:STDOUT: %circle.ref.loc34: %Circle = name_ref circle, %circle
  303. // CHECK:STDOUT: %radius.ref.loc34: <error> = name_ref radius, <error> [concrete = <error>]
  304. // CHECK:STDOUT: %int_5: Core.IntLiteral = int_value 5 [concrete = constants.%int_5.64b]
  305. // CHECK:STDOUT: assign %radius.ref.loc34, <error>
  306. // CHECK:STDOUT: %circle.ref.loc42: %Circle = name_ref circle, %circle
  307. // CHECK:STDOUT: %SOME_INTERNAL_CONSTANT.ref: <error> = name_ref SOME_INTERNAL_CONSTANT, <error> [concrete = <error>]
  308. // CHECK:STDOUT: %circle.ref.loc51: %Circle = name_ref circle, %circle
  309. // CHECK:STDOUT: %SomeInternalFunction.ref: <error> = name_ref SomeInternalFunction, <error> [concrete = <error>]
  310. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.bound: <bound method> = bound_method %.loc18_36.2, constants.%DestroyT.binding.as_type.as.Destroy.impl.Op.c1a
  311. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.specific_fn: <specific function> = specific_function constants.%DestroyT.binding.as_type.as.Destroy.impl.Op.c1a, @DestroyT.binding.as_type.as.Destroy.impl.Op(constants.%facet_value) [concrete = constants.%DestroyT.binding.as_type.as.Destroy.impl.Op.specific_fn]
  312. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %.loc18_36.2, %DestroyT.binding.as_type.as.Destroy.impl.Op.specific_fn
  313. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.call: init %empty_tuple.type = call %bound_method(%.loc18_36.2)
  314. // CHECK:STDOUT: return
  315. // CHECK:STDOUT: }
  316. // CHECK:STDOUT:
  317. // CHECK:STDOUT: --- fail_protected_field_access.carbon
  318. // CHECK:STDOUT:
  319. // CHECK:STDOUT: constants {
  320. // CHECK:STDOUT: %A: type = class_type @A [concrete]
  321. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  322. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  323. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  324. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  325. // CHECK:STDOUT: %A.elem: type = unbound_element_type %A, %i32 [concrete]
  326. // CHECK:STDOUT: %struct_type.x: type = struct_type {.x: %i32} [concrete]
  327. // CHECK:STDOUT: %complete_type.1ec: <witness> = complete_type_witness %struct_type.x [concrete]
  328. // CHECK:STDOUT: %Run.type: type = fn_type @Run [concrete]
  329. // CHECK:STDOUT: %Run: %Run.type = struct_value () [concrete]
  330. // CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
  331. // CHECK:STDOUT: }
  332. // CHECK:STDOUT:
  333. // CHECK:STDOUT: imports {
  334. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  335. // CHECK:STDOUT: .Int = %Core.Int
  336. // CHECK:STDOUT: import Core//prelude
  337. // CHECK:STDOUT: import Core//prelude/...
  338. // CHECK:STDOUT: }
  339. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/parts/int, Int, loaded [concrete = constants.%Int.generic]
  340. // CHECK:STDOUT: }
  341. // CHECK:STDOUT:
  342. // CHECK:STDOUT: file {
  343. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  344. // CHECK:STDOUT: .Core = imports.%Core
  345. // CHECK:STDOUT: .A = %A.decl
  346. // CHECK:STDOUT: .Run = %Run.decl
  347. // CHECK:STDOUT: }
  348. // CHECK:STDOUT: %Core.import = import Core
  349. // CHECK:STDOUT: %A.decl: type = class_decl @A [concrete = constants.%A] {} {}
  350. // CHECK:STDOUT: %Run.decl: %Run.type = fn_decl @Run [concrete = constants.%Run] {} {}
  351. // CHECK:STDOUT: }
  352. // CHECK:STDOUT:
  353. // CHECK:STDOUT: class @A {
  354. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  355. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  356. // CHECK:STDOUT: %.loc5: %A.elem = field_decl x, element0 [concrete]
  357. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%struct_type.x [concrete = constants.%complete_type.1ec]
  358. // CHECK:STDOUT: complete_type_witness = %complete_type
  359. // CHECK:STDOUT:
  360. // CHECK:STDOUT: !members:
  361. // CHECK:STDOUT: .Self = constants.%A
  362. // CHECK:STDOUT: .x [protected] = %.loc5
  363. // CHECK:STDOUT: }
  364. // CHECK:STDOUT:
  365. // CHECK:STDOUT: fn @Run() {
  366. // CHECK:STDOUT: !entry:
  367. // CHECK:STDOUT: name_binding_decl {
  368. // CHECK:STDOUT: %x.patt: %pattern_type.7ce = value_binding_pattern x [concrete]
  369. // CHECK:STDOUT: }
  370. // CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [concrete = constants.%A]
  371. // CHECK:STDOUT: %x.ref: <error> = name_ref x, <error> [concrete = <error>]
  372. // CHECK:STDOUT: %.loc16: type = splice_block %i32 [concrete = constants.%i32] {
  373. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  374. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  375. // CHECK:STDOUT: }
  376. // CHECK:STDOUT: %x: %i32 = value_binding x, <error> [concrete = <error>]
  377. // CHECK:STDOUT: return
  378. // CHECK:STDOUT: }
  379. // CHECK:STDOUT:
  380. // CHECK:STDOUT: --- instance_private_field_access_on_self.carbon
  381. // CHECK:STDOUT:
  382. // CHECK:STDOUT: constants {
  383. // CHECK:STDOUT: %Circle: type = class_type @Circle [concrete]
  384. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  385. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  386. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  387. // CHECK:STDOUT: %N: Core.IntLiteral = symbolic_binding N, 0 [symbolic]
  388. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  389. // CHECK:STDOUT: %Circle.elem: type = unbound_element_type %Circle, %i32 [concrete]
  390. // CHECK:STDOUT: %pattern_type.ce2: type = pattern_type %Circle [concrete]
  391. // CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
  392. // CHECK:STDOUT: %Circle.GetRadius.type: type = fn_type @Circle.GetRadius [concrete]
  393. // CHECK:STDOUT: %Circle.GetRadius: %Circle.GetRadius.type = struct_value () [concrete]
  394. // CHECK:STDOUT: %Circle.SomeInternalFunction.type: type = fn_type @Circle.SomeInternalFunction [concrete]
  395. // CHECK:STDOUT: %Circle.SomeInternalFunction: %Circle.SomeInternalFunction.type = struct_value () [concrete]
  396. // CHECK:STDOUT: %Circle.Compute.type: type = fn_type @Circle.Compute [concrete]
  397. // CHECK:STDOUT: %Circle.Compute: %Circle.Compute.type = struct_value () [concrete]
  398. // CHECK:STDOUT: %struct_type.radius: type = struct_type {.radius: %i32} [concrete]
  399. // CHECK:STDOUT: %complete_type.5a5: <witness> = complete_type_witness %struct_type.radius [concrete]
  400. // CHECK:STDOUT: %Copy.type: type = facet_type <@Copy> [concrete]
  401. // CHECK:STDOUT: %Copy.Op.type: type = fn_type @Copy.Op [concrete]
  402. // CHECK:STDOUT: %Int.as.Copy.impl.Op.type.24b: type = fn_type @Int.as.Copy.impl.Op, @Int.as.Copy.impl(%N) [symbolic]
  403. // CHECK:STDOUT: %Int.as.Copy.impl.Op.c95: %Int.as.Copy.impl.Op.type.24b = struct_value () [symbolic]
  404. // CHECK:STDOUT: %Copy.impl_witness.fb7: <witness> = impl_witness imports.%Copy.impl_witness_table.b6a, @Int.as.Copy.impl(%int_32) [concrete]
  405. // CHECK:STDOUT: %Int.as.Copy.impl.Op.type.469: type = fn_type @Int.as.Copy.impl.Op, @Int.as.Copy.impl(%int_32) [concrete]
  406. // CHECK:STDOUT: %Int.as.Copy.impl.Op.dfd: %Int.as.Copy.impl.Op.type.469 = struct_value () [concrete]
  407. // CHECK:STDOUT: %Copy.facet: %Copy.type = facet_value %i32, (%Copy.impl_witness.fb7) [concrete]
  408. // CHECK:STDOUT: %.65f: type = fn_type_with_self_type %Copy.Op.type, %Copy.facet [concrete]
  409. // CHECK:STDOUT: %Int.as.Copy.impl.Op.specific_fn: <specific function> = specific_function %Int.as.Copy.impl.Op.dfd, @Int.as.Copy.impl.Op(%int_32) [concrete]
  410. // CHECK:STDOUT: %int_0.5c6: Core.IntLiteral = int_value 0 [concrete]
  411. // CHECK:STDOUT: %ImplicitAs.type.cc7: type = generic_interface_type @ImplicitAs [concrete]
  412. // CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.cc7 = struct_value () [concrete]
  413. // CHECK:STDOUT: %ImplicitAs.type.d14: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
  414. // CHECK:STDOUT: %ImplicitAs.Convert.type.1b6: type = fn_type @ImplicitAs.Convert, @ImplicitAs(%i32) [concrete]
  415. // CHECK:STDOUT: %To: Core.IntLiteral = symbolic_binding To, 0 [symbolic]
  416. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.f51: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%To) [symbolic]
  417. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.2a1: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.f51 = struct_value () [symbolic]
  418. // CHECK:STDOUT: %ImplicitAs.impl_witness.bc9: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.132, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete]
  419. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.51e: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete]
  420. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.e9b: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.51e = struct_value () [concrete]
  421. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.d14 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.bc9) [concrete]
  422. // CHECK:STDOUT: %.322: type = fn_type_with_self_type %ImplicitAs.Convert.type.1b6, %ImplicitAs.facet [concrete]
  423. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.bound: <bound method> = bound_method %int_0.5c6, %Core.IntLiteral.as.ImplicitAs.impl.Convert.e9b [concrete]
  424. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn: <specific function> = specific_function %Core.IntLiteral.as.ImplicitAs.impl.Convert.e9b, @Core.IntLiteral.as.ImplicitAs.impl.Convert(%int_32) [concrete]
  425. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_0.5c6, %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete]
  426. // CHECK:STDOUT: %int_0.6a9: %i32 = int_value 0 [concrete]
  427. // CHECK:STDOUT: }
  428. // CHECK:STDOUT:
  429. // CHECK:STDOUT: imports {
  430. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  431. // CHECK:STDOUT: .Int = %Core.Int
  432. // CHECK:STDOUT: .Copy = %Core.Copy
  433. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  434. // CHECK:STDOUT: import Core//prelude
  435. // CHECK:STDOUT: import Core//prelude/...
  436. // CHECK:STDOUT: }
  437. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/parts/int, Int, loaded [concrete = constants.%Int.generic]
  438. // CHECK:STDOUT: %Core.Copy: type = import_ref Core//prelude/parts/copy, Copy, loaded [concrete = constants.%Copy.type]
  439. // CHECK:STDOUT: %Core.import_ref.d12: @Int.as.Copy.impl.%Int.as.Copy.impl.Op.type (%Int.as.Copy.impl.Op.type.24b) = 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.c95)]
  440. // CHECK:STDOUT: %Copy.impl_witness_table.b6a = impl_witness_table (%Core.import_ref.d12), @Int.as.Copy.impl [concrete]
  441. // CHECK:STDOUT: %Core.ImplicitAs: %ImplicitAs.type.cc7 = import_ref Core//prelude/parts/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic]
  442. // CHECK:STDOUT: %Core.import_ref.e24: @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.f51) = 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.2a1)]
  443. // CHECK:STDOUT: %ImplicitAs.impl_witness_table.132 = impl_witness_table (%Core.import_ref.e24), @Core.IntLiteral.as.ImplicitAs.impl [concrete]
  444. // CHECK:STDOUT: }
  445. // CHECK:STDOUT:
  446. // CHECK:STDOUT: file {
  447. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  448. // CHECK:STDOUT: .Core = imports.%Core
  449. // CHECK:STDOUT: .Circle = %Circle.decl
  450. // CHECK:STDOUT: }
  451. // CHECK:STDOUT: %Core.import = import Core
  452. // CHECK:STDOUT: %Circle.decl: type = class_decl @Circle [concrete = constants.%Circle] {} {}
  453. // CHECK:STDOUT: }
  454. // CHECK:STDOUT:
  455. // CHECK:STDOUT: class @Circle {
  456. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  457. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  458. // CHECK:STDOUT: %.loc5: %Circle.elem = field_decl radius, element0 [concrete]
  459. // CHECK:STDOUT: %Circle.GetRadius.decl: %Circle.GetRadius.type = fn_decl @Circle.GetRadius [concrete = constants.%Circle.GetRadius] {
  460. // CHECK:STDOUT: %self.patt: %pattern_type.ce2 = value_binding_pattern self [concrete]
  461. // CHECK:STDOUT: %self.param_patt: %pattern_type.ce2 = value_param_pattern %self.patt, call_param0 [concrete]
  462. // CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern [concrete]
  463. // CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern %return.patt, call_param1 [concrete]
  464. // CHECK:STDOUT: } {
  465. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  466. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  467. // CHECK:STDOUT: %self.param: %Circle = value_param call_param0
  468. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%Circle [concrete = constants.%Circle]
  469. // CHECK:STDOUT: %self: %Circle = value_binding self, %self.param
  470. // CHECK:STDOUT: %return.param: ref %i32 = out_param call_param1
  471. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  472. // CHECK:STDOUT: }
  473. // CHECK:STDOUT: %Circle.SomeInternalFunction.decl: %Circle.SomeInternalFunction.type = fn_decl @Circle.SomeInternalFunction [concrete = constants.%Circle.SomeInternalFunction] {
  474. // CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern [concrete]
  475. // CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern %return.patt, call_param0 [concrete]
  476. // CHECK:STDOUT: } {
  477. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  478. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  479. // CHECK:STDOUT: %return.param: ref %i32 = out_param call_param0
  480. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  481. // CHECK:STDOUT: }
  482. // CHECK:STDOUT: %Circle.Compute.decl: %Circle.Compute.type = fn_decl @Circle.Compute [concrete = constants.%Circle.Compute] {
  483. // CHECK:STDOUT: %self.patt: %pattern_type.ce2 = value_binding_pattern self [concrete]
  484. // CHECK:STDOUT: %self.param_patt: %pattern_type.ce2 = value_param_pattern %self.patt, call_param0 [concrete]
  485. // CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern [concrete]
  486. // CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern %return.patt, call_param1 [concrete]
  487. // CHECK:STDOUT: } {
  488. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  489. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  490. // CHECK:STDOUT: %self.param: %Circle = value_param call_param0
  491. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%Circle [concrete = constants.%Circle]
  492. // CHECK:STDOUT: %self: %Circle = value_binding self, %self.param
  493. // CHECK:STDOUT: %return.param: ref %i32 = out_param call_param1
  494. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  495. // CHECK:STDOUT: }
  496. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%struct_type.radius [concrete = constants.%complete_type.5a5]
  497. // CHECK:STDOUT: complete_type_witness = %complete_type
  498. // CHECK:STDOUT:
  499. // CHECK:STDOUT: !members:
  500. // CHECK:STDOUT: .Self = constants.%Circle
  501. // CHECK:STDOUT: .radius [private] = %.loc5
  502. // CHECK:STDOUT: .GetRadius = %Circle.GetRadius.decl
  503. // CHECK:STDOUT: .SomeInternalFunction [private] = %Circle.SomeInternalFunction.decl
  504. // CHECK:STDOUT: .Compute = %Circle.Compute.decl
  505. // CHECK:STDOUT: }
  506. // CHECK:STDOUT:
  507. // CHECK:STDOUT: fn @Circle.GetRadius(%self.param: %Circle) -> %i32 {
  508. // CHECK:STDOUT: !entry:
  509. // CHECK:STDOUT: %self.ref: %Circle = name_ref self, %self
  510. // CHECK:STDOUT: %radius.ref: %Circle.elem = name_ref radius, @Circle.%.loc5 [concrete = @Circle.%.loc5]
  511. // CHECK:STDOUT: %.loc8_16.1: ref %i32 = class_element_access %self.ref, element0
  512. // CHECK:STDOUT: %.loc8_16.2: %i32 = acquire_value %.loc8_16.1
  513. // CHECK:STDOUT: %impl.elem0: %.65f = impl_witness_access constants.%Copy.impl_witness.fb7, element0 [concrete = constants.%Int.as.Copy.impl.Op.dfd]
  514. // CHECK:STDOUT: %bound_method.loc8_16.1: <bound method> = bound_method %.loc8_16.2, %impl.elem0
  515. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Int.as.Copy.impl.Op(constants.%int_32) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn]
  516. // CHECK:STDOUT: %bound_method.loc8_16.2: <bound method> = bound_method %.loc8_16.2, %specific_fn
  517. // CHECK:STDOUT: %Int.as.Copy.impl.Op.call: init %i32 = call %bound_method.loc8_16.2(%.loc8_16.2)
  518. // CHECK:STDOUT: return %Int.as.Copy.impl.Op.call to %return
  519. // CHECK:STDOUT: }
  520. // CHECK:STDOUT:
  521. // CHECK:STDOUT: fn @Circle.SomeInternalFunction() -> %i32 {
  522. // CHECK:STDOUT: !entry:
  523. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0.5c6]
  524. // CHECK:STDOUT: %impl.elem0: %.322 = impl_witness_access constants.%ImplicitAs.impl_witness.bc9, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.e9b]
  525. // CHECK:STDOUT: %bound_method.loc12_13.1: <bound method> = bound_method %int_0, %impl.elem0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound]
  526. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn]
  527. // CHECK:STDOUT: %bound_method.loc12_13.2: <bound method> = bound_method %int_0, %specific_fn [concrete = constants.%bound_method]
  528. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call: init %i32 = call %bound_method.loc12_13.2(%int_0) [concrete = constants.%int_0.6a9]
  529. // CHECK:STDOUT: %.loc12: init %i32 = converted %int_0, %Core.IntLiteral.as.ImplicitAs.impl.Convert.call [concrete = constants.%int_0.6a9]
  530. // CHECK:STDOUT: return %.loc12 to %return
  531. // CHECK:STDOUT: }
  532. // CHECK:STDOUT:
  533. // CHECK:STDOUT: fn @Circle.Compute(%self.param: %Circle) -> %i32 {
  534. // CHECK:STDOUT: !entry:
  535. // CHECK:STDOUT: %self.ref: %Circle = name_ref self, %self
  536. // CHECK:STDOUT: %SomeInternalFunction.ref: %Circle.SomeInternalFunction.type = name_ref SomeInternalFunction, @Circle.%Circle.SomeInternalFunction.decl [concrete = constants.%Circle.SomeInternalFunction]
  537. // CHECK:STDOUT: %Circle.SomeInternalFunction.call: init %i32 = call %SomeInternalFunction.ref()
  538. // CHECK:STDOUT: return %Circle.SomeInternalFunction.call to %return
  539. // CHECK:STDOUT: }
  540. // CHECK:STDOUT:
  541. // CHECK:STDOUT: --- public_global_access.carbon
  542. // CHECK:STDOUT:
  543. // CHECK:STDOUT: constants {
  544. // CHECK:STDOUT: %A: type = class_type @A [concrete]
  545. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  546. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  547. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  548. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  549. // CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
  550. // CHECK:STDOUT: %int_5.64b: Core.IntLiteral = int_value 5 [concrete]
  551. // CHECK:STDOUT: %ImplicitAs.type.cc7: type = generic_interface_type @ImplicitAs [concrete]
  552. // CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.cc7 = struct_value () [concrete]
  553. // CHECK:STDOUT: %ImplicitAs.type.d14: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
  554. // CHECK:STDOUT: %ImplicitAs.Convert.type.1b6: type = fn_type @ImplicitAs.Convert, @ImplicitAs(%i32) [concrete]
  555. // CHECK:STDOUT: %To: Core.IntLiteral = symbolic_binding To, 0 [symbolic]
  556. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.f51: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%To) [symbolic]
  557. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.2a1: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.f51 = struct_value () [symbolic]
  558. // CHECK:STDOUT: %ImplicitAs.impl_witness.bc9: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.132, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete]
  559. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.51e: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete]
  560. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.e9b: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.51e = struct_value () [concrete]
  561. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.d14 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.bc9) [concrete]
  562. // CHECK:STDOUT: %.322: type = fn_type_with_self_type %ImplicitAs.Convert.type.1b6, %ImplicitAs.facet [concrete]
  563. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.bound: <bound method> = bound_method %int_5.64b, %Core.IntLiteral.as.ImplicitAs.impl.Convert.e9b [concrete]
  564. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn: <specific function> = specific_function %Core.IntLiteral.as.ImplicitAs.impl.Convert.e9b, @Core.IntLiteral.as.ImplicitAs.impl.Convert(%int_32) [concrete]
  565. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_5.64b, %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete]
  566. // CHECK:STDOUT: %int_5.0f6: %i32 = int_value 5 [concrete]
  567. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  568. // CHECK:STDOUT: %complete_type.357: <witness> = complete_type_witness %empty_struct_type [concrete]
  569. // CHECK:STDOUT: }
  570. // CHECK:STDOUT:
  571. // CHECK:STDOUT: imports {
  572. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  573. // CHECK:STDOUT: .Int = %Core.Int
  574. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  575. // CHECK:STDOUT: import Core//prelude
  576. // CHECK:STDOUT: import Core//prelude/...
  577. // CHECK:STDOUT: }
  578. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/parts/int, Int, loaded [concrete = constants.%Int.generic]
  579. // CHECK:STDOUT: %Core.ImplicitAs: %ImplicitAs.type.cc7 = import_ref Core//prelude/parts/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic]
  580. // CHECK:STDOUT: %Core.import_ref.e24: @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.f51) = 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.2a1)]
  581. // CHECK:STDOUT: %ImplicitAs.impl_witness_table.132 = impl_witness_table (%Core.import_ref.e24), @Core.IntLiteral.as.ImplicitAs.impl [concrete]
  582. // CHECK:STDOUT: }
  583. // CHECK:STDOUT:
  584. // CHECK:STDOUT: file {
  585. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  586. // CHECK:STDOUT: .Core = imports.%Core
  587. // CHECK:STDOUT: .A = %A.decl
  588. // CHECK:STDOUT: .x = %x
  589. // CHECK:STDOUT: }
  590. // CHECK:STDOUT: %Core.import = import Core
  591. // CHECK:STDOUT: %A.decl: type = class_decl @A [concrete = constants.%A] {} {}
  592. // CHECK:STDOUT: name_binding_decl {
  593. // CHECK:STDOUT: %x.patt: %pattern_type.7ce = value_binding_pattern x [concrete]
  594. // CHECK:STDOUT: }
  595. // CHECK:STDOUT: %.loc8: type = splice_block %i32 [concrete = constants.%i32] {
  596. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  597. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  598. // CHECK:STDOUT: }
  599. // CHECK:STDOUT: %x: %i32 = value_binding x, @__global_init.%x.ref
  600. // CHECK:STDOUT: }
  601. // CHECK:STDOUT:
  602. // CHECK:STDOUT: class @A {
  603. // CHECK:STDOUT: name_binding_decl {
  604. // CHECK:STDOUT: %x.patt: %pattern_type.7ce = value_binding_pattern x [concrete]
  605. // CHECK:STDOUT: }
  606. // CHECK:STDOUT: %int_5: Core.IntLiteral = int_value 5 [concrete = constants.%int_5.64b]
  607. // CHECK:STDOUT: %.loc5_10: type = splice_block %i32 [concrete = constants.%i32] {
  608. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  609. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  610. // CHECK:STDOUT: }
  611. // CHECK:STDOUT: %impl.elem0: %.322 = impl_witness_access constants.%ImplicitAs.impl_witness.bc9, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.e9b]
  612. // CHECK:STDOUT: %bound_method.loc5_16.1: <bound method> = bound_method %int_5, %impl.elem0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound]
  613. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn]
  614. // CHECK:STDOUT: %bound_method.loc5_16.2: <bound method> = bound_method %int_5, %specific_fn [concrete = constants.%bound_method]
  615. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call: init %i32 = call %bound_method.loc5_16.2(%int_5) [concrete = constants.%int_5.0f6]
  616. // CHECK:STDOUT: %.loc5_16.1: %i32 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call [concrete = constants.%int_5.0f6]
  617. // CHECK:STDOUT: %.loc5_16.2: %i32 = converted %int_5, %.loc5_16.1 [concrete = constants.%int_5.0f6]
  618. // CHECK:STDOUT: %x: %i32 = value_binding x, %.loc5_16.2
  619. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type.357]
  620. // CHECK:STDOUT: complete_type_witness = %complete_type
  621. // CHECK:STDOUT:
  622. // CHECK:STDOUT: !members:
  623. // CHECK:STDOUT: .Self = constants.%A
  624. // CHECK:STDOUT: .x = %x
  625. // CHECK:STDOUT: }
  626. // CHECK:STDOUT:
  627. // CHECK:STDOUT: fn @__global_init() {
  628. // CHECK:STDOUT: !entry:
  629. // CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [concrete = constants.%A]
  630. // CHECK:STDOUT: %x.ref: %i32 = name_ref x, @A.%x
  631. // CHECK:STDOUT: return
  632. // CHECK:STDOUT: }
  633. // CHECK:STDOUT:
  634. // CHECK:STDOUT: --- fail_global_access.carbon
  635. // CHECK:STDOUT:
  636. // CHECK:STDOUT: constants {
  637. // CHECK:STDOUT: %A: type = class_type @A [concrete]
  638. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  639. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  640. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  641. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  642. // CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
  643. // CHECK:STDOUT: %int_5.64b: Core.IntLiteral = int_value 5 [concrete]
  644. // CHECK:STDOUT: %ImplicitAs.type.cc7: type = generic_interface_type @ImplicitAs [concrete]
  645. // CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.cc7 = struct_value () [concrete]
  646. // CHECK:STDOUT: %ImplicitAs.type.d14: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
  647. // CHECK:STDOUT: %ImplicitAs.Convert.type.1b6: type = fn_type @ImplicitAs.Convert, @ImplicitAs(%i32) [concrete]
  648. // CHECK:STDOUT: %To: Core.IntLiteral = symbolic_binding To, 0 [symbolic]
  649. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.f51: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%To) [symbolic]
  650. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.2a1: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.f51 = struct_value () [symbolic]
  651. // CHECK:STDOUT: %ImplicitAs.impl_witness.bc9: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.132, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete]
  652. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.51e: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete]
  653. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.e9b: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.51e = struct_value () [concrete]
  654. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.d14 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.bc9) [concrete]
  655. // CHECK:STDOUT: %.322: type = fn_type_with_self_type %ImplicitAs.Convert.type.1b6, %ImplicitAs.facet [concrete]
  656. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.bound: <bound method> = bound_method %int_5.64b, %Core.IntLiteral.as.ImplicitAs.impl.Convert.e9b [concrete]
  657. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn: <specific function> = specific_function %Core.IntLiteral.as.ImplicitAs.impl.Convert.e9b, @Core.IntLiteral.as.ImplicitAs.impl.Convert(%int_32) [concrete]
  658. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_5.64b, %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete]
  659. // CHECK:STDOUT: %int_5.0f6: %i32 = int_value 5 [concrete]
  660. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  661. // CHECK:STDOUT: %complete_type.357: <witness> = complete_type_witness %empty_struct_type [concrete]
  662. // CHECK:STDOUT: }
  663. // CHECK:STDOUT:
  664. // CHECK:STDOUT: imports {
  665. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  666. // CHECK:STDOUT: .Int = %Core.Int
  667. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  668. // CHECK:STDOUT: import Core//prelude
  669. // CHECK:STDOUT: import Core//prelude/...
  670. // CHECK:STDOUT: }
  671. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/parts/int, Int, loaded [concrete = constants.%Int.generic]
  672. // CHECK:STDOUT: %Core.ImplicitAs: %ImplicitAs.type.cc7 = import_ref Core//prelude/parts/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic]
  673. // CHECK:STDOUT: %Core.import_ref.e24: @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.f51) = 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.2a1)]
  674. // CHECK:STDOUT: %ImplicitAs.impl_witness_table.132 = impl_witness_table (%Core.import_ref.e24), @Core.IntLiteral.as.ImplicitAs.impl [concrete]
  675. // CHECK:STDOUT: }
  676. // CHECK:STDOUT:
  677. // CHECK:STDOUT: file {
  678. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  679. // CHECK:STDOUT: .Core = imports.%Core
  680. // CHECK:STDOUT: .A = %A.decl
  681. // CHECK:STDOUT: .x = %x
  682. // CHECK:STDOUT: .y = %y
  683. // CHECK:STDOUT: }
  684. // CHECK:STDOUT: %Core.import = import Core
  685. // CHECK:STDOUT: %A.decl: type = class_decl @A [concrete = constants.%A] {} {}
  686. // CHECK:STDOUT: name_binding_decl {
  687. // CHECK:STDOUT: %x.patt: %pattern_type.7ce = value_binding_pattern x [concrete]
  688. // CHECK:STDOUT: }
  689. // CHECK:STDOUT: %.loc16: type = splice_block %i32.loc16 [concrete = constants.%i32] {
  690. // CHECK:STDOUT: %int_32.loc16: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  691. // CHECK:STDOUT: %i32.loc16: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  692. // CHECK:STDOUT: }
  693. // CHECK:STDOUT: %x: %i32 = value_binding x, <error> [concrete = <error>]
  694. // CHECK:STDOUT: name_binding_decl {
  695. // CHECK:STDOUT: %y.patt: %pattern_type.7ce = value_binding_pattern y [concrete]
  696. // CHECK:STDOUT: }
  697. // CHECK:STDOUT: %.loc24: type = splice_block %i32.loc24 [concrete = constants.%i32] {
  698. // CHECK:STDOUT: %int_32.loc24: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  699. // CHECK:STDOUT: %i32.loc24: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  700. // CHECK:STDOUT: }
  701. // CHECK:STDOUT: %y: %i32 = value_binding y, <error> [concrete = <error>]
  702. // CHECK:STDOUT: }
  703. // CHECK:STDOUT:
  704. // CHECK:STDOUT: class @A {
  705. // CHECK:STDOUT: name_binding_decl {
  706. // CHECK:STDOUT: %x.patt: %pattern_type.7ce = value_binding_pattern x [concrete]
  707. // CHECK:STDOUT: }
  708. // CHECK:STDOUT: %int_5.loc5: Core.IntLiteral = int_value 5 [concrete = constants.%int_5.64b]
  709. // CHECK:STDOUT: %.loc5_20: type = splice_block %i32.loc5 [concrete = constants.%i32] {
  710. // CHECK:STDOUT: %int_32.loc5: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  711. // CHECK:STDOUT: %i32.loc5: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  712. // CHECK:STDOUT: }
  713. // CHECK:STDOUT: %impl.elem0.loc5: %.322 = impl_witness_access constants.%ImplicitAs.impl_witness.bc9, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.e9b]
  714. // CHECK:STDOUT: %bound_method.loc5_26.1: <bound method> = bound_method %int_5.loc5, %impl.elem0.loc5 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound]
  715. // CHECK:STDOUT: %specific_fn.loc5: <specific function> = specific_function %impl.elem0.loc5, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn]
  716. // CHECK:STDOUT: %bound_method.loc5_26.2: <bound method> = bound_method %int_5.loc5, %specific_fn.loc5 [concrete = constants.%bound_method]
  717. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc5: init %i32 = call %bound_method.loc5_26.2(%int_5.loc5) [concrete = constants.%int_5.0f6]
  718. // CHECK:STDOUT: %.loc5_26.1: %i32 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc5 [concrete = constants.%int_5.0f6]
  719. // CHECK:STDOUT: %.loc5_26.2: %i32 = converted %int_5.loc5, %.loc5_26.1 [concrete = constants.%int_5.0f6]
  720. // CHECK:STDOUT: %x: %i32 = value_binding x, %.loc5_26.2
  721. // CHECK:STDOUT: name_binding_decl {
  722. // CHECK:STDOUT: %y.patt: %pattern_type.7ce = value_binding_pattern y [concrete]
  723. // CHECK:STDOUT: }
  724. // CHECK:STDOUT: %int_5.loc6: Core.IntLiteral = int_value 5 [concrete = constants.%int_5.64b]
  725. // CHECK:STDOUT: %.loc6_18: type = splice_block %i32.loc6 [concrete = constants.%i32] {
  726. // CHECK:STDOUT: %int_32.loc6: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  727. // CHECK:STDOUT: %i32.loc6: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  728. // CHECK:STDOUT: }
  729. // CHECK:STDOUT: %impl.elem0.loc6: %.322 = impl_witness_access constants.%ImplicitAs.impl_witness.bc9, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.e9b]
  730. // CHECK:STDOUT: %bound_method.loc6_24.1: <bound method> = bound_method %int_5.loc6, %impl.elem0.loc6 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound]
  731. // CHECK:STDOUT: %specific_fn.loc6: <specific function> = specific_function %impl.elem0.loc6, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn]
  732. // CHECK:STDOUT: %bound_method.loc6_24.2: <bound method> = bound_method %int_5.loc6, %specific_fn.loc6 [concrete = constants.%bound_method]
  733. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc6: init %i32 = call %bound_method.loc6_24.2(%int_5.loc6) [concrete = constants.%int_5.0f6]
  734. // CHECK:STDOUT: %.loc6_24.1: %i32 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc6 [concrete = constants.%int_5.0f6]
  735. // CHECK:STDOUT: %.loc6_24.2: %i32 = converted %int_5.loc6, %.loc6_24.1 [concrete = constants.%int_5.0f6]
  736. // CHECK:STDOUT: %y: %i32 = value_binding y, %.loc6_24.2
  737. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type.357]
  738. // CHECK:STDOUT: complete_type_witness = %complete_type
  739. // CHECK:STDOUT:
  740. // CHECK:STDOUT: !members:
  741. // CHECK:STDOUT: .Self = constants.%A
  742. // CHECK:STDOUT: .x [protected] = %x
  743. // CHECK:STDOUT: .y [private] = %y
  744. // CHECK:STDOUT: }
  745. // CHECK:STDOUT:
  746. // CHECK:STDOUT: fn @__global_init() {
  747. // CHECK:STDOUT: !entry:
  748. // CHECK:STDOUT: %A.ref.loc16: type = name_ref A, file.%A.decl [concrete = constants.%A]
  749. // CHECK:STDOUT: %x.ref: <error> = name_ref x, <error> [concrete = <error>]
  750. // CHECK:STDOUT: %A.ref.loc24: type = name_ref A, file.%A.decl [concrete = constants.%A]
  751. // CHECK:STDOUT: %y.ref: <error> = name_ref y, <error> [concrete = <error>]
  752. // CHECK:STDOUT: return
  753. // CHECK:STDOUT: }
  754. // CHECK:STDOUT:
  755. // CHECK:STDOUT: --- self_access.carbon
  756. // CHECK:STDOUT:
  757. // CHECK:STDOUT: constants {
  758. // CHECK:STDOUT: %A: type = class_type @A [concrete]
  759. // CHECK:STDOUT: %A.F.type: type = fn_type @A.F [concrete]
  760. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  761. // CHECK:STDOUT: %A.F: %A.F.type = struct_value () [concrete]
  762. // CHECK:STDOUT: %A.G.type: type = fn_type @A.G [concrete]
  763. // CHECK:STDOUT: %A.G: %A.G.type = struct_value () [concrete]
  764. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  765. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  766. // CHECK:STDOUT: }
  767. // CHECK:STDOUT:
  768. // CHECK:STDOUT: imports {
  769. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  770. // CHECK:STDOUT: import Core//prelude
  771. // CHECK:STDOUT: import Core//prelude/...
  772. // CHECK:STDOUT: }
  773. // CHECK:STDOUT: }
  774. // CHECK:STDOUT:
  775. // CHECK:STDOUT: file {
  776. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  777. // CHECK:STDOUT: .Core = imports.%Core
  778. // CHECK:STDOUT: .A = %A.decl
  779. // CHECK:STDOUT: }
  780. // CHECK:STDOUT: %Core.import = import Core
  781. // CHECK:STDOUT: %A.decl: type = class_decl @A [concrete = constants.%A] {} {}
  782. // CHECK:STDOUT: }
  783. // CHECK:STDOUT:
  784. // CHECK:STDOUT: class @A {
  785. // CHECK:STDOUT: %A.F.decl: %A.F.type = fn_decl @A.F [concrete = constants.%A.F] {} {}
  786. // CHECK:STDOUT: %A.G.decl: %A.G.type = fn_decl @A.G [concrete = constants.%A.G] {} {}
  787. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type]
  788. // CHECK:STDOUT: complete_type_witness = %complete_type
  789. // CHECK:STDOUT:
  790. // CHECK:STDOUT: !members:
  791. // CHECK:STDOUT: .Self = constants.%A
  792. // CHECK:STDOUT: .F [private] = %A.F.decl
  793. // CHECK:STDOUT: .G [private] = %A.G.decl
  794. // CHECK:STDOUT: }
  795. // CHECK:STDOUT:
  796. // CHECK:STDOUT: fn @A.F() {
  797. // CHECK:STDOUT: !entry:
  798. // CHECK:STDOUT: return
  799. // CHECK:STDOUT: }
  800. // CHECK:STDOUT:
  801. // CHECK:STDOUT: fn @A.G() {
  802. // CHECK:STDOUT: !entry:
  803. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%A [concrete = constants.%A]
  804. // CHECK:STDOUT: %F.ref: %A.F.type = name_ref F, @A.%A.F.decl [concrete = constants.%A.F]
  805. // CHECK:STDOUT: %A.F.call: init %empty_tuple.type = call %F.ref()
  806. // CHECK:STDOUT: return
  807. // CHECK:STDOUT: }
  808. // CHECK:STDOUT: