fail_adapt_with_subobjects.carbon 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  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/adapter/fail_adapt_with_subobjects.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/adapter/fail_adapt_with_subobjects.carbon
  14. // --- fail_adapt_with_base.carbon
  15. library "[[@TEST_NAME]]";
  16. base class Base {}
  17. class AdaptWithBase {
  18. // CHECK:STDERR: fail_adapt_with_base.carbon:[[@LINE+3]]:3: error: adapter with base class [AdaptWithBase]
  19. // CHECK:STDERR: adapt i32;
  20. // CHECK:STDERR: ^~~~~~~~~~
  21. adapt i32;
  22. // CHECK:STDERR: fail_adapt_with_base.carbon:[[@LINE+4]]:3: note: `base` declaration is here [AdaptWithBaseHere]
  23. // CHECK:STDERR: extend base: Base;
  24. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~
  25. // CHECK:STDERR:
  26. extend base: Base;
  27. }
  28. // --- fail_adapt_with_fields.carbon
  29. library "[[@TEST_NAME]]";
  30. class AdaptWithField {
  31. // CHECK:STDERR: fail_adapt_with_fields.carbon:[[@LINE+3]]:3: error: adapter with fields [AdaptWithFields]
  32. // CHECK:STDERR: adapt i32;
  33. // CHECK:STDERR: ^~~~~~~~~~
  34. adapt i32;
  35. // CHECK:STDERR: fail_adapt_with_fields.carbon:[[@LINE+4]]:7: note: first field declaration is here [AdaptWithFieldHere]
  36. // CHECK:STDERR: var n: i32;
  37. // CHECK:STDERR: ^~~~~~
  38. // CHECK:STDERR:
  39. var n: i32;
  40. }
  41. class AdaptWithFields {
  42. // CHECK:STDERR: fail_adapt_with_fields.carbon:[[@LINE+3]]:3: error: adapter with fields [AdaptWithFields]
  43. // CHECK:STDERR: adapt i32;
  44. // CHECK:STDERR: ^~~~~~~~~~
  45. adapt i32;
  46. // CHECK:STDERR: fail_adapt_with_fields.carbon:[[@LINE+4]]:7: note: first field declaration is here [AdaptWithFieldHere]
  47. // CHECK:STDERR: var a: i32;
  48. // CHECK:STDERR: ^~~~~~
  49. // CHECK:STDERR:
  50. var a: i32;
  51. var b: i32;
  52. var c: i32;
  53. }
  54. // --- fail_adapt_with_base_and_fields.carbon
  55. library "[[@TEST_NAME]]";
  56. base class Base {}
  57. class AdaptWithBaseAndFields {
  58. extend base: Base;
  59. var n: i32;
  60. // CHECK:STDERR: fail_adapt_with_base_and_fields.carbon:[[@LINE+7]]:3: error: adapter with base class [AdaptWithBase]
  61. // CHECK:STDERR: adapt {};
  62. // CHECK:STDERR: ^~~~~~~~~
  63. // CHECK:STDERR: fail_adapt_with_base_and_fields.carbon:[[@LINE-5]]:3: note: `base` declaration is here [AdaptWithBaseHere]
  64. // CHECK:STDERR: extend base: Base;
  65. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~
  66. // CHECK:STDERR:
  67. adapt {};
  68. }
  69. // CHECK:STDOUT: --- fail_adapt_with_base.carbon
  70. // CHECK:STDOUT:
  71. // CHECK:STDOUT: constants {
  72. // CHECK:STDOUT: %Base: type = class_type @Base [concrete]
  73. // CHECK:STDOUT: %Destroy.type: type = facet_type <@Destroy> [concrete]
  74. // CHECK:STDOUT: %pattern_type.f6d: type = pattern_type auto [concrete]
  75. // CHECK:STDOUT: %Destroy.impl_witness.090: <witness> = impl_witness @Base.%Destroy.impl_witness_table [concrete]
  76. // CHECK:STDOUT: %ptr.11f: type = ptr_type %Base [concrete]
  77. // CHECK:STDOUT: %pattern_type.1b9: type = pattern_type %ptr.11f [concrete]
  78. // CHECK:STDOUT: %Base.as.Destroy.impl.Op.type: type = fn_type @Base.as.Destroy.impl.Op [concrete]
  79. // CHECK:STDOUT: %Base.as.Destroy.impl.Op: %Base.as.Destroy.impl.Op.type = struct_value () [concrete]
  80. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  81. // CHECK:STDOUT: %complete_type.357: <witness> = complete_type_witness %empty_struct_type [concrete]
  82. // CHECK:STDOUT: %AdaptWithBase: type = class_type @AdaptWithBase [concrete]
  83. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  84. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  85. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  86. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  87. // CHECK:STDOUT: %AdaptWithBase.elem: type = unbound_element_type %AdaptWithBase, %Base [concrete]
  88. // CHECK:STDOUT: %Destroy.impl_witness.0a2: <witness> = impl_witness @AdaptWithBase.%Destroy.impl_witness_table [concrete]
  89. // CHECK:STDOUT: %ptr.52c: type = ptr_type %AdaptWithBase [concrete]
  90. // CHECK:STDOUT: %pattern_type.d4d: type = pattern_type %ptr.52c [concrete]
  91. // CHECK:STDOUT: %AdaptWithBase.as.Destroy.impl.Op.type: type = fn_type @AdaptWithBase.as.Destroy.impl.Op [concrete]
  92. // CHECK:STDOUT: %AdaptWithBase.as.Destroy.impl.Op: %AdaptWithBase.as.Destroy.impl.Op.type = struct_value () [concrete]
  93. // CHECK:STDOUT: }
  94. // CHECK:STDOUT:
  95. // CHECK:STDOUT: imports {
  96. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  97. // CHECK:STDOUT: .Destroy = %Core.Destroy
  98. // CHECK:STDOUT: .Int = %Core.Int
  99. // CHECK:STDOUT: import Core//prelude
  100. // CHECK:STDOUT: import Core//prelude/...
  101. // CHECK:STDOUT: }
  102. // CHECK:STDOUT: %Core.Destroy: type = import_ref Core//prelude/parts/destroy, Destroy, loaded [concrete = constants.%Destroy.type]
  103. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/parts/int, Int, loaded [concrete = constants.%Int.generic]
  104. // CHECK:STDOUT: }
  105. // CHECK:STDOUT:
  106. // CHECK:STDOUT: file {
  107. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  108. // CHECK:STDOUT: .Core = imports.%Core
  109. // CHECK:STDOUT: .Base = %Base.decl
  110. // CHECK:STDOUT: .AdaptWithBase = %AdaptWithBase.decl
  111. // CHECK:STDOUT: }
  112. // CHECK:STDOUT: %Core.import = import Core
  113. // CHECK:STDOUT: %Base.decl: type = class_decl @Base [concrete = constants.%Base] {} {}
  114. // CHECK:STDOUT: %AdaptWithBase.decl: type = class_decl @AdaptWithBase [concrete = constants.%AdaptWithBase] {} {}
  115. // CHECK:STDOUT: }
  116. // CHECK:STDOUT:
  117. // CHECK:STDOUT: impl @Base.as.Destroy.impl: @Base.%Self.ref as constants.%Destroy.type {
  118. // CHECK:STDOUT: %Base.as.Destroy.impl.Op.decl: %Base.as.Destroy.impl.Op.type = fn_decl @Base.as.Destroy.impl.Op [concrete = constants.%Base.as.Destroy.impl.Op] {
  119. // CHECK:STDOUT: %self.patt: %pattern_type.1b9 = binding_pattern self [concrete]
  120. // CHECK:STDOUT: %self.param_patt: %pattern_type.1b9 = value_param_pattern %self.patt, call_param0 [concrete]
  121. // CHECK:STDOUT: %.loc4: %pattern_type.f6d = addr_pattern %self.param_patt [concrete]
  122. // CHECK:STDOUT: } {
  123. // CHECK:STDOUT: %self.param: %ptr.11f = value_param call_param0
  124. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%Base [concrete = constants.%Base]
  125. // CHECK:STDOUT: %self: %ptr.11f = bind_name self, %self.param
  126. // CHECK:STDOUT: }
  127. // CHECK:STDOUT:
  128. // CHECK:STDOUT: !members:
  129. // CHECK:STDOUT: .Op = %Base.as.Destroy.impl.Op.decl
  130. // CHECK:STDOUT: witness = @Base.%Destroy.impl_witness
  131. // CHECK:STDOUT: }
  132. // CHECK:STDOUT:
  133. // CHECK:STDOUT: impl @AdaptWithBase.as.Destroy.impl: @AdaptWithBase.%Self.ref as constants.%Destroy.type {
  134. // CHECK:STDOUT: %AdaptWithBase.as.Destroy.impl.Op.decl: %AdaptWithBase.as.Destroy.impl.Op.type = fn_decl @AdaptWithBase.as.Destroy.impl.Op [concrete = constants.%AdaptWithBase.as.Destroy.impl.Op] {
  135. // CHECK:STDOUT: %self.patt: %pattern_type.d4d = binding_pattern self [concrete]
  136. // CHECK:STDOUT: %self.param_patt: %pattern_type.d4d = value_param_pattern %self.patt, call_param0 [concrete]
  137. // CHECK:STDOUT: %.loc6: %pattern_type.f6d = addr_pattern %self.param_patt [concrete]
  138. // CHECK:STDOUT: } {
  139. // CHECK:STDOUT: %self.param: %ptr.52c = value_param call_param0
  140. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%AdaptWithBase [concrete = constants.%AdaptWithBase]
  141. // CHECK:STDOUT: %self: %ptr.52c = bind_name self, %self.param
  142. // CHECK:STDOUT: }
  143. // CHECK:STDOUT:
  144. // CHECK:STDOUT: !members:
  145. // CHECK:STDOUT: .Op = %AdaptWithBase.as.Destroy.impl.Op.decl
  146. // CHECK:STDOUT: witness = @AdaptWithBase.%Destroy.impl_witness
  147. // CHECK:STDOUT: }
  148. // CHECK:STDOUT:
  149. // CHECK:STDOUT: class @Base {
  150. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%Base [concrete = constants.%Base]
  151. // CHECK:STDOUT: impl_decl @Base.as.Destroy.impl [concrete] {} {}
  152. // CHECK:STDOUT: %Destroy.impl_witness_table = impl_witness_table (@Base.as.Destroy.impl.%Base.as.Destroy.impl.Op.decl), @Base.as.Destroy.impl [concrete]
  153. // CHECK:STDOUT: %Destroy.impl_witness: <witness> = impl_witness %Destroy.impl_witness_table [concrete = constants.%Destroy.impl_witness.090]
  154. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type.357]
  155. // CHECK:STDOUT: complete_type_witness = %complete_type
  156. // CHECK:STDOUT:
  157. // CHECK:STDOUT: !members:
  158. // CHECK:STDOUT: .Self = constants.%Base
  159. // CHECK:STDOUT: }
  160. // CHECK:STDOUT:
  161. // CHECK:STDOUT: class @AdaptWithBase {
  162. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  163. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  164. // CHECK:STDOUT: adapt_decl %i32 [concrete]
  165. // CHECK:STDOUT: %Base.ref: type = name_ref Base, file.%Base.decl [concrete = constants.%Base]
  166. // CHECK:STDOUT: %.loc15: %AdaptWithBase.elem = base_decl %Base.ref, element<none> [concrete]
  167. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%AdaptWithBase [concrete = constants.%AdaptWithBase]
  168. // CHECK:STDOUT: impl_decl @AdaptWithBase.as.Destroy.impl [concrete] {} {}
  169. // CHECK:STDOUT: %Destroy.impl_witness_table = impl_witness_table (@AdaptWithBase.as.Destroy.impl.%AdaptWithBase.as.Destroy.impl.Op.decl), @AdaptWithBase.as.Destroy.impl [concrete]
  170. // CHECK:STDOUT: %Destroy.impl_witness: <witness> = impl_witness %Destroy.impl_witness_table [concrete = constants.%Destroy.impl_witness.0a2]
  171. // CHECK:STDOUT: complete_type_witness = <error>
  172. // CHECK:STDOUT:
  173. // CHECK:STDOUT: !members:
  174. // CHECK:STDOUT: .Self = constants.%AdaptWithBase
  175. // CHECK:STDOUT: .Base = <poisoned>
  176. // CHECK:STDOUT: .base = %.loc15
  177. // CHECK:STDOUT: extend %Base.ref
  178. // CHECK:STDOUT: }
  179. // CHECK:STDOUT:
  180. // CHECK:STDOUT: fn @Base.as.Destroy.impl.Op(%self.param: %ptr.11f) = "no_op";
  181. // CHECK:STDOUT:
  182. // CHECK:STDOUT: fn @AdaptWithBase.as.Destroy.impl.Op(%self.param: %ptr.52c) = "no_op";
  183. // CHECK:STDOUT:
  184. // CHECK:STDOUT: --- fail_adapt_with_fields.carbon
  185. // CHECK:STDOUT:
  186. // CHECK:STDOUT: constants {
  187. // CHECK:STDOUT: %AdaptWithField: type = class_type @AdaptWithField [concrete]
  188. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  189. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  190. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  191. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  192. // CHECK:STDOUT: %AdaptWithField.elem: type = unbound_element_type %AdaptWithField, %i32 [concrete]
  193. // CHECK:STDOUT: %Destroy.type: type = facet_type <@Destroy> [concrete]
  194. // CHECK:STDOUT: %pattern_type.f6d: type = pattern_type auto [concrete]
  195. // CHECK:STDOUT: %Destroy.impl_witness.90f: <witness> = impl_witness @AdaptWithField.%Destroy.impl_witness_table [concrete]
  196. // CHECK:STDOUT: %ptr.849: type = ptr_type %AdaptWithField [concrete]
  197. // CHECK:STDOUT: %pattern_type.55a: type = pattern_type %ptr.849 [concrete]
  198. // CHECK:STDOUT: %AdaptWithField.as.Destroy.impl.Op.type: type = fn_type @AdaptWithField.as.Destroy.impl.Op [concrete]
  199. // CHECK:STDOUT: %AdaptWithField.as.Destroy.impl.Op: %AdaptWithField.as.Destroy.impl.Op.type = struct_value () [concrete]
  200. // CHECK:STDOUT: %AdaptWithFields: type = class_type @AdaptWithFields [concrete]
  201. // CHECK:STDOUT: %AdaptWithFields.elem: type = unbound_element_type %AdaptWithFields, %i32 [concrete]
  202. // CHECK:STDOUT: %Destroy.impl_witness.f27: <witness> = impl_witness @AdaptWithFields.%Destroy.impl_witness_table [concrete]
  203. // CHECK:STDOUT: %ptr.521: type = ptr_type %AdaptWithFields [concrete]
  204. // CHECK:STDOUT: %pattern_type.1a9: type = pattern_type %ptr.521 [concrete]
  205. // CHECK:STDOUT: %AdaptWithFields.as.Destroy.impl.Op.type: type = fn_type @AdaptWithFields.as.Destroy.impl.Op [concrete]
  206. // CHECK:STDOUT: %AdaptWithFields.as.Destroy.impl.Op: %AdaptWithFields.as.Destroy.impl.Op.type = struct_value () [concrete]
  207. // CHECK:STDOUT: }
  208. // CHECK:STDOUT:
  209. // CHECK:STDOUT: imports {
  210. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  211. // CHECK:STDOUT: .Int = %Core.Int
  212. // CHECK:STDOUT: .Destroy = %Core.Destroy
  213. // CHECK:STDOUT: import Core//prelude
  214. // CHECK:STDOUT: import Core//prelude/...
  215. // CHECK:STDOUT: }
  216. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/parts/int, Int, loaded [concrete = constants.%Int.generic]
  217. // CHECK:STDOUT: %Core.Destroy: type = import_ref Core//prelude/parts/destroy, Destroy, loaded [concrete = constants.%Destroy.type]
  218. // CHECK:STDOUT: }
  219. // CHECK:STDOUT:
  220. // CHECK:STDOUT: file {
  221. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  222. // CHECK:STDOUT: .Core = imports.%Core
  223. // CHECK:STDOUT: .AdaptWithField = %AdaptWithField.decl
  224. // CHECK:STDOUT: .AdaptWithFields = %AdaptWithFields.decl
  225. // CHECK:STDOUT: }
  226. // CHECK:STDOUT: %Core.import = import Core
  227. // CHECK:STDOUT: %AdaptWithField.decl: type = class_decl @AdaptWithField [concrete = constants.%AdaptWithField] {} {}
  228. // CHECK:STDOUT: %AdaptWithFields.decl: type = class_decl @AdaptWithFields [concrete = constants.%AdaptWithFields] {} {}
  229. // CHECK:STDOUT: }
  230. // CHECK:STDOUT:
  231. // CHECK:STDOUT: impl @AdaptWithField.as.Destroy.impl: @AdaptWithField.%Self.ref as constants.%Destroy.type {
  232. // CHECK:STDOUT: %AdaptWithField.as.Destroy.impl.Op.decl: %AdaptWithField.as.Destroy.impl.Op.type = fn_decl @AdaptWithField.as.Destroy.impl.Op [concrete = constants.%AdaptWithField.as.Destroy.impl.Op] {
  233. // CHECK:STDOUT: %self.patt: %pattern_type.55a = binding_pattern self [concrete]
  234. // CHECK:STDOUT: %self.param_patt: %pattern_type.55a = value_param_pattern %self.patt, call_param0 [concrete]
  235. // CHECK:STDOUT: %.loc4: %pattern_type.f6d = addr_pattern %self.param_patt [concrete]
  236. // CHECK:STDOUT: } {
  237. // CHECK:STDOUT: %self.param: %ptr.849 = value_param call_param0
  238. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%AdaptWithField [concrete = constants.%AdaptWithField]
  239. // CHECK:STDOUT: %self: %ptr.849 = bind_name self, %self.param
  240. // CHECK:STDOUT: }
  241. // CHECK:STDOUT:
  242. // CHECK:STDOUT: !members:
  243. // CHECK:STDOUT: .Op = %AdaptWithField.as.Destroy.impl.Op.decl
  244. // CHECK:STDOUT: witness = @AdaptWithField.%Destroy.impl_witness
  245. // CHECK:STDOUT: }
  246. // CHECK:STDOUT:
  247. // CHECK:STDOUT: impl @AdaptWithFields.as.Destroy.impl: @AdaptWithFields.%Self.ref as constants.%Destroy.type {
  248. // CHECK:STDOUT: %AdaptWithFields.as.Destroy.impl.Op.decl: %AdaptWithFields.as.Destroy.impl.Op.type = fn_decl @AdaptWithFields.as.Destroy.impl.Op [concrete = constants.%AdaptWithFields.as.Destroy.impl.Op] {
  249. // CHECK:STDOUT: %self.patt: %pattern_type.1a9 = binding_pattern self [concrete]
  250. // CHECK:STDOUT: %self.param_patt: %pattern_type.1a9 = value_param_pattern %self.patt, call_param0 [concrete]
  251. // CHECK:STDOUT: %.loc16: %pattern_type.f6d = addr_pattern %self.param_patt [concrete]
  252. // CHECK:STDOUT: } {
  253. // CHECK:STDOUT: %self.param: %ptr.521 = value_param call_param0
  254. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%AdaptWithFields [concrete = constants.%AdaptWithFields]
  255. // CHECK:STDOUT: %self: %ptr.521 = bind_name self, %self.param
  256. // CHECK:STDOUT: }
  257. // CHECK:STDOUT:
  258. // CHECK:STDOUT: !members:
  259. // CHECK:STDOUT: .Op = %AdaptWithFields.as.Destroy.impl.Op.decl
  260. // CHECK:STDOUT: witness = @AdaptWithFields.%Destroy.impl_witness
  261. // CHECK:STDOUT: }
  262. // CHECK:STDOUT:
  263. // CHECK:STDOUT: class @AdaptWithField {
  264. // CHECK:STDOUT: %int_32.loc8: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  265. // CHECK:STDOUT: %i32.loc8: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  266. // CHECK:STDOUT: adapt_decl %i32.loc8 [concrete]
  267. // CHECK:STDOUT: %int_32.loc13: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  268. // CHECK:STDOUT: %i32.loc13: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  269. // CHECK:STDOUT: %.loc13: %AdaptWithField.elem = field_decl n, element<none> [concrete]
  270. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%AdaptWithField [concrete = constants.%AdaptWithField]
  271. // CHECK:STDOUT: impl_decl @AdaptWithField.as.Destroy.impl [concrete] {} {}
  272. // CHECK:STDOUT: %Destroy.impl_witness_table = impl_witness_table (@AdaptWithField.as.Destroy.impl.%AdaptWithField.as.Destroy.impl.Op.decl), @AdaptWithField.as.Destroy.impl [concrete]
  273. // CHECK:STDOUT: %Destroy.impl_witness: <witness> = impl_witness %Destroy.impl_witness_table [concrete = constants.%Destroy.impl_witness.90f]
  274. // CHECK:STDOUT: complete_type_witness = <error>
  275. // CHECK:STDOUT:
  276. // CHECK:STDOUT: !members:
  277. // CHECK:STDOUT: .Self = constants.%AdaptWithField
  278. // CHECK:STDOUT: .n = %.loc13
  279. // CHECK:STDOUT: }
  280. // CHECK:STDOUT:
  281. // CHECK:STDOUT: class @AdaptWithFields {
  282. // CHECK:STDOUT: %int_32.loc20: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  283. // CHECK:STDOUT: %i32.loc20: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  284. // CHECK:STDOUT: adapt_decl %i32.loc20 [concrete]
  285. // CHECK:STDOUT: %int_32.loc25: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  286. // CHECK:STDOUT: %i32.loc25: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  287. // CHECK:STDOUT: %.loc25: %AdaptWithFields.elem = field_decl a, element<none> [concrete]
  288. // CHECK:STDOUT: %int_32.loc26: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  289. // CHECK:STDOUT: %i32.loc26: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  290. // CHECK:STDOUT: %.loc26: %AdaptWithFields.elem = field_decl b, element<none> [concrete]
  291. // CHECK:STDOUT: %int_32.loc27: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  292. // CHECK:STDOUT: %i32.loc27: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  293. // CHECK:STDOUT: %.loc27: %AdaptWithFields.elem = field_decl c, element<none> [concrete]
  294. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%AdaptWithFields [concrete = constants.%AdaptWithFields]
  295. // CHECK:STDOUT: impl_decl @AdaptWithFields.as.Destroy.impl [concrete] {} {}
  296. // CHECK:STDOUT: %Destroy.impl_witness_table = impl_witness_table (@AdaptWithFields.as.Destroy.impl.%AdaptWithFields.as.Destroy.impl.Op.decl), @AdaptWithFields.as.Destroy.impl [concrete]
  297. // CHECK:STDOUT: %Destroy.impl_witness: <witness> = impl_witness %Destroy.impl_witness_table [concrete = constants.%Destroy.impl_witness.f27]
  298. // CHECK:STDOUT: complete_type_witness = <error>
  299. // CHECK:STDOUT:
  300. // CHECK:STDOUT: !members:
  301. // CHECK:STDOUT: .Self = constants.%AdaptWithFields
  302. // CHECK:STDOUT: .a = %.loc25
  303. // CHECK:STDOUT: .b = %.loc26
  304. // CHECK:STDOUT: .c = %.loc27
  305. // CHECK:STDOUT: }
  306. // CHECK:STDOUT:
  307. // CHECK:STDOUT: fn @AdaptWithField.as.Destroy.impl.Op(%self.param: %ptr.849) = "no_op";
  308. // CHECK:STDOUT:
  309. // CHECK:STDOUT: fn @AdaptWithFields.as.Destroy.impl.Op(%self.param: %ptr.521) = "no_op";
  310. // CHECK:STDOUT:
  311. // CHECK:STDOUT: --- fail_adapt_with_base_and_fields.carbon
  312. // CHECK:STDOUT:
  313. // CHECK:STDOUT: constants {
  314. // CHECK:STDOUT: %Base: type = class_type @Base [concrete]
  315. // CHECK:STDOUT: %Destroy.type: type = facet_type <@Destroy> [concrete]
  316. // CHECK:STDOUT: %pattern_type.f6d: type = pattern_type auto [concrete]
  317. // CHECK:STDOUT: %Destroy.impl_witness.090: <witness> = impl_witness @Base.%Destroy.impl_witness_table [concrete]
  318. // CHECK:STDOUT: %ptr.11f: type = ptr_type %Base [concrete]
  319. // CHECK:STDOUT: %pattern_type.1b9: type = pattern_type %ptr.11f [concrete]
  320. // CHECK:STDOUT: %Base.as.Destroy.impl.Op.type: type = fn_type @Base.as.Destroy.impl.Op [concrete]
  321. // CHECK:STDOUT: %Base.as.Destroy.impl.Op: %Base.as.Destroy.impl.Op.type = struct_value () [concrete]
  322. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  323. // CHECK:STDOUT: %complete_type.357: <witness> = complete_type_witness %empty_struct_type [concrete]
  324. // CHECK:STDOUT: %AdaptWithBaseAndFields: type = class_type @AdaptWithBaseAndFields [concrete]
  325. // CHECK:STDOUT: %AdaptWithBaseAndFields.elem.767: type = unbound_element_type %AdaptWithBaseAndFields, %Base [concrete]
  326. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  327. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  328. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  329. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  330. // CHECK:STDOUT: %AdaptWithBaseAndFields.elem.ddf: type = unbound_element_type %AdaptWithBaseAndFields, %i32 [concrete]
  331. // CHECK:STDOUT: %Destroy.impl_witness.fe6: <witness> = impl_witness @AdaptWithBaseAndFields.%Destroy.impl_witness_table [concrete]
  332. // CHECK:STDOUT: %ptr.cbb: type = ptr_type %AdaptWithBaseAndFields [concrete]
  333. // CHECK:STDOUT: %pattern_type.926: type = pattern_type %ptr.cbb [concrete]
  334. // CHECK:STDOUT: %AdaptWithBaseAndFields.as.Destroy.impl.Op.type: type = fn_type @AdaptWithBaseAndFields.as.Destroy.impl.Op [concrete]
  335. // CHECK:STDOUT: %AdaptWithBaseAndFields.as.Destroy.impl.Op: %AdaptWithBaseAndFields.as.Destroy.impl.Op.type = struct_value () [concrete]
  336. // CHECK:STDOUT: }
  337. // CHECK:STDOUT:
  338. // CHECK:STDOUT: imports {
  339. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  340. // CHECK:STDOUT: .Destroy = %Core.Destroy
  341. // CHECK:STDOUT: .Int = %Core.Int
  342. // CHECK:STDOUT: import Core//prelude
  343. // CHECK:STDOUT: import Core//prelude/...
  344. // CHECK:STDOUT: }
  345. // CHECK:STDOUT: %Core.Destroy: type = import_ref Core//prelude/parts/destroy, Destroy, loaded [concrete = constants.%Destroy.type]
  346. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/parts/int, Int, loaded [concrete = constants.%Int.generic]
  347. // CHECK:STDOUT: }
  348. // CHECK:STDOUT:
  349. // CHECK:STDOUT: file {
  350. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  351. // CHECK:STDOUT: .Core = imports.%Core
  352. // CHECK:STDOUT: .Base = %Base.decl
  353. // CHECK:STDOUT: .AdaptWithBaseAndFields = %AdaptWithBaseAndFields.decl
  354. // CHECK:STDOUT: }
  355. // CHECK:STDOUT: %Core.import = import Core
  356. // CHECK:STDOUT: %Base.decl: type = class_decl @Base [concrete = constants.%Base] {} {}
  357. // CHECK:STDOUT: %AdaptWithBaseAndFields.decl: type = class_decl @AdaptWithBaseAndFields [concrete = constants.%AdaptWithBaseAndFields] {} {}
  358. // CHECK:STDOUT: }
  359. // CHECK:STDOUT:
  360. // CHECK:STDOUT: impl @Base.as.Destroy.impl: @Base.%Self.ref as constants.%Destroy.type {
  361. // CHECK:STDOUT: %Base.as.Destroy.impl.Op.decl: %Base.as.Destroy.impl.Op.type = fn_decl @Base.as.Destroy.impl.Op [concrete = constants.%Base.as.Destroy.impl.Op] {
  362. // CHECK:STDOUT: %self.patt: %pattern_type.1b9 = binding_pattern self [concrete]
  363. // CHECK:STDOUT: %self.param_patt: %pattern_type.1b9 = value_param_pattern %self.patt, call_param0 [concrete]
  364. // CHECK:STDOUT: %.loc4: %pattern_type.f6d = addr_pattern %self.param_patt [concrete]
  365. // CHECK:STDOUT: } {
  366. // CHECK:STDOUT: %self.param: %ptr.11f = value_param call_param0
  367. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%Base [concrete = constants.%Base]
  368. // CHECK:STDOUT: %self: %ptr.11f = bind_name self, %self.param
  369. // CHECK:STDOUT: }
  370. // CHECK:STDOUT:
  371. // CHECK:STDOUT: !members:
  372. // CHECK:STDOUT: .Op = %Base.as.Destroy.impl.Op.decl
  373. // CHECK:STDOUT: witness = @Base.%Destroy.impl_witness
  374. // CHECK:STDOUT: }
  375. // CHECK:STDOUT:
  376. // CHECK:STDOUT: impl @AdaptWithBaseAndFields.as.Destroy.impl: @AdaptWithBaseAndFields.%Self.ref as constants.%Destroy.type {
  377. // CHECK:STDOUT: %AdaptWithBaseAndFields.as.Destroy.impl.Op.decl: %AdaptWithBaseAndFields.as.Destroy.impl.Op.type = fn_decl @AdaptWithBaseAndFields.as.Destroy.impl.Op [concrete = constants.%AdaptWithBaseAndFields.as.Destroy.impl.Op] {
  378. // CHECK:STDOUT: %self.patt: %pattern_type.926 = binding_pattern self [concrete]
  379. // CHECK:STDOUT: %self.param_patt: %pattern_type.926 = value_param_pattern %self.patt, call_param0 [concrete]
  380. // CHECK:STDOUT: %.loc6: %pattern_type.f6d = addr_pattern %self.param_patt [concrete]
  381. // CHECK:STDOUT: } {
  382. // CHECK:STDOUT: %self.param: %ptr.cbb = value_param call_param0
  383. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%AdaptWithBaseAndFields [concrete = constants.%AdaptWithBaseAndFields]
  384. // CHECK:STDOUT: %self: %ptr.cbb = bind_name self, %self.param
  385. // CHECK:STDOUT: }
  386. // CHECK:STDOUT:
  387. // CHECK:STDOUT: !members:
  388. // CHECK:STDOUT: .Op = %AdaptWithBaseAndFields.as.Destroy.impl.Op.decl
  389. // CHECK:STDOUT: witness = @AdaptWithBaseAndFields.%Destroy.impl_witness
  390. // CHECK:STDOUT: }
  391. // CHECK:STDOUT:
  392. // CHECK:STDOUT: class @Base {
  393. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%Base [concrete = constants.%Base]
  394. // CHECK:STDOUT: impl_decl @Base.as.Destroy.impl [concrete] {} {}
  395. // CHECK:STDOUT: %Destroy.impl_witness_table = impl_witness_table (@Base.as.Destroy.impl.%Base.as.Destroy.impl.Op.decl), @Base.as.Destroy.impl [concrete]
  396. // CHECK:STDOUT: %Destroy.impl_witness: <witness> = impl_witness %Destroy.impl_witness_table [concrete = constants.%Destroy.impl_witness.090]
  397. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type.357]
  398. // CHECK:STDOUT: complete_type_witness = %complete_type
  399. // CHECK:STDOUT:
  400. // CHECK:STDOUT: !members:
  401. // CHECK:STDOUT: .Self = constants.%Base
  402. // CHECK:STDOUT: }
  403. // CHECK:STDOUT:
  404. // CHECK:STDOUT: class @AdaptWithBaseAndFields {
  405. // CHECK:STDOUT: %Base.ref: type = name_ref Base, file.%Base.decl [concrete = constants.%Base]
  406. // CHECK:STDOUT: %.loc7: %AdaptWithBaseAndFields.elem.767 = base_decl %Base.ref, element<none> [concrete]
  407. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  408. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  409. // CHECK:STDOUT: %.loc8: %AdaptWithBaseAndFields.elem.ddf = field_decl n, element<none> [concrete]
  410. // CHECK:STDOUT: %.loc16_10: %empty_struct_type = struct_literal ()
  411. // CHECK:STDOUT: %.loc16_11: type = converted %.loc16_10, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  412. // CHECK:STDOUT: adapt_decl %.loc16_11 [concrete]
  413. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%AdaptWithBaseAndFields [concrete = constants.%AdaptWithBaseAndFields]
  414. // CHECK:STDOUT: impl_decl @AdaptWithBaseAndFields.as.Destroy.impl [concrete] {} {}
  415. // CHECK:STDOUT: %Destroy.impl_witness_table = impl_witness_table (@AdaptWithBaseAndFields.as.Destroy.impl.%AdaptWithBaseAndFields.as.Destroy.impl.Op.decl), @AdaptWithBaseAndFields.as.Destroy.impl [concrete]
  416. // CHECK:STDOUT: %Destroy.impl_witness: <witness> = impl_witness %Destroy.impl_witness_table [concrete = constants.%Destroy.impl_witness.fe6]
  417. // CHECK:STDOUT: complete_type_witness = <error>
  418. // CHECK:STDOUT:
  419. // CHECK:STDOUT: !members:
  420. // CHECK:STDOUT: .Self = constants.%AdaptWithBaseAndFields
  421. // CHECK:STDOUT: .Base = <poisoned>
  422. // CHECK:STDOUT: .base = %.loc7
  423. // CHECK:STDOUT: .n = %.loc8
  424. // CHECK:STDOUT: extend %Base.ref
  425. // CHECK:STDOUT: }
  426. // CHECK:STDOUT:
  427. // CHECK:STDOUT: fn @Base.as.Destroy.impl.Op(%self.param: %ptr.11f) = "no_op";
  428. // CHECK:STDOUT:
  429. // CHECK:STDOUT: fn @AdaptWithBaseAndFields.as.Destroy.impl.Op(%self.param: %ptr.cbb) = "no_op";
  430. // CHECK:STDOUT: