fail_adapt_bad_decl.carbon 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // AUTOUPDATE
  6. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/class/fail_adapt_bad_decl.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/fail_adapt_bad_decl.carbon
  10. // --- fail_not_type.carbon
  11. library "[[@TEST_NAME]]";
  12. class Bad {
  13. // CHECK:STDERR: fail_not_type.carbon:[[@LINE+7]]:3: ERROR: Cannot implicitly convert from `i32` to `type`.
  14. // CHECK:STDERR: adapt 100;
  15. // CHECK:STDERR: ^~~~~~~~~~
  16. // CHECK:STDERR: fail_not_type.carbon:[[@LINE+4]]:3: Type `i32` does not implement interface `ImplicitAs`.
  17. // CHECK:STDERR: adapt 100;
  18. // CHECK:STDERR: ^~~~~~~~~~
  19. // CHECK:STDERR:
  20. adapt 100;
  21. }
  22. // CHECK:STDERR: fail_not_type.carbon:[[@LINE+4]]:18: ERROR: Name `F` not found.
  23. // CHECK:STDERR: fn Use(b: Bad) { b.F(); }
  24. // CHECK:STDERR: ^~~
  25. // CHECK:STDERR:
  26. fn Use(b: Bad) { b.F(); }
  27. // --- fail_extend_not_type.carbon
  28. library "[[@TEST_NAME]]";
  29. class Bad {
  30. // CHECK:STDERR: fail_extend_not_type.carbon:[[@LINE+7]]:3: ERROR: Cannot implicitly convert from `i32` to `type`.
  31. // CHECK:STDERR: extend adapt 100;
  32. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~
  33. // CHECK:STDERR: fail_extend_not_type.carbon:[[@LINE+4]]:3: Type `i32` does not implement interface `ImplicitAs`.
  34. // CHECK:STDERR: extend adapt 100;
  35. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~
  36. // CHECK:STDERR:
  37. extend adapt 100;
  38. }
  39. // No diagnostic here, we don't know what names Bad has.
  40. fn Use(b: Bad) { b.F(); }
  41. // --- fail_repeated.carbon
  42. library "[[@TEST_NAME]]";
  43. class MultipleAdapts {
  44. adapt ();
  45. // CHECK:STDERR: fail_repeated.carbon:[[@LINE+7]]:3: ERROR: Multiple `adapt` declarations in class.
  46. // CHECK:STDERR: adapt {};
  47. // CHECK:STDERR: ^~~~~~~~~
  48. // CHECK:STDERR: fail_repeated.carbon:[[@LINE-4]]:3: Previous `adapt` declaration is here.
  49. // CHECK:STDERR: adapt ();
  50. // CHECK:STDERR: ^~~~~~~~~
  51. // CHECK:STDERR:
  52. adapt {};
  53. }
  54. class MultipleAdaptsSameType {
  55. adapt ();
  56. // CHECK:STDERR: fail_repeated.carbon:[[@LINE+7]]:3: ERROR: Multiple `adapt` declarations in class.
  57. // CHECK:STDERR: adapt ();
  58. // CHECK:STDERR: ^~~~~~~~~
  59. // CHECK:STDERR: fail_repeated.carbon:[[@LINE-4]]:3: Previous `adapt` declaration is here.
  60. // CHECK:STDERR: adapt ();
  61. // CHECK:STDERR: ^~~~~~~~~
  62. // CHECK:STDERR:
  63. adapt ();
  64. }
  65. // --- fail_bad_scope.carbon
  66. library "[[@TEST_NAME]]";
  67. // CHECK:STDERR: fail_bad_scope.carbon:[[@LINE+4]]:1: ERROR: `adapt` declaration can only be used in a class.
  68. // CHECK:STDERR: adapt {};
  69. // CHECK:STDERR: ^~~~~~~~~
  70. // CHECK:STDERR:
  71. adapt {};
  72. interface I {
  73. // CHECK:STDERR: fail_bad_scope.carbon:[[@LINE+4]]:3: ERROR: `adapt` declaration can only be used in a class.
  74. // CHECK:STDERR: adapt {};
  75. // CHECK:STDERR: ^~~~~~~~~
  76. // CHECK:STDERR:
  77. adapt {};
  78. }
  79. class C {
  80. interface I {
  81. // CHECK:STDERR: fail_bad_scope.carbon:[[@LINE+3]]:5: ERROR: `adapt` declaration can only be used in a class.
  82. // CHECK:STDERR: adapt {};
  83. // CHECK:STDERR: ^~~~~~~~~
  84. adapt {};
  85. }
  86. }
  87. // CHECK:STDOUT: --- fail_not_type.carbon
  88. // CHECK:STDOUT:
  89. // CHECK:STDOUT: constants {
  90. // CHECK:STDOUT: %Bad: type = class_type @Bad [template]
  91. // CHECK:STDOUT: %.1: i32 = int_literal 100 [template]
  92. // CHECK:STDOUT: %ImplicitAs.type: type = generic_interface_type @ImplicitAs [template]
  93. // CHECK:STDOUT: %.2: type = tuple_type () [template]
  94. // CHECK:STDOUT: %ImplicitAs: %ImplicitAs.type = struct_value () [template]
  95. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest 0 [symbolic]
  96. // CHECK:STDOUT: %.3: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic]
  97. // CHECK:STDOUT: %Self.1: @ImplicitAs.%.1 (%.3) = bind_symbolic_name Self 1 [symbolic]
  98. // CHECK:STDOUT: %Self.2: %.3 = bind_symbolic_name Self 1 [symbolic]
  99. // CHECK:STDOUT: %Convert.type.1: type = fn_type @Convert, @ImplicitAs(%Dest) [symbolic]
  100. // CHECK:STDOUT: %Convert.1: %Convert.type.1 = struct_value () [symbolic]
  101. // CHECK:STDOUT: %.4: type = assoc_entity_type %.3, %Convert.type.1 [symbolic]
  102. // CHECK:STDOUT: %.5: %.4 = assoc_entity element0, imports.%import_ref.5 [symbolic]
  103. // CHECK:STDOUT: %.6: type = interface_type @ImplicitAs, @ImplicitAs(type) [template]
  104. // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert, @ImplicitAs(type) [template]
  105. // CHECK:STDOUT: %Convert.2: %Convert.type.2 = struct_value () [template]
  106. // CHECK:STDOUT: %.7: type = assoc_entity_type %.6, %Convert.type.2 [template]
  107. // CHECK:STDOUT: %.8: %.7 = assoc_entity element0, imports.%import_ref.5 [template]
  108. // CHECK:STDOUT: %.9: %.4 = assoc_entity element0, imports.%import_ref.6 [symbolic]
  109. // CHECK:STDOUT: %Use.type: type = fn_type @Use [template]
  110. // CHECK:STDOUT: %Use: %Use.type = struct_value () [template]
  111. // CHECK:STDOUT: }
  112. // CHECK:STDOUT:
  113. // CHECK:STDOUT: imports {
  114. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  115. // CHECK:STDOUT: .ImplicitAs = %import_ref.1
  116. // CHECK:STDOUT: import Core//prelude
  117. // CHECK:STDOUT: import Core//prelude/operators
  118. // CHECK:STDOUT: import Core//prelude/types
  119. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  120. // CHECK:STDOUT: import Core//prelude/operators/as
  121. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  122. // CHECK:STDOUT: import Core//prelude/operators/comparison
  123. // CHECK:STDOUT: import Core//prelude/types/bool
  124. // CHECK:STDOUT: }
  125. // CHECK:STDOUT: %import_ref.1: %ImplicitAs.type = import_ref Core//prelude/operators/as, inst+37, loaded [template = constants.%ImplicitAs]
  126. // CHECK:STDOUT: %import_ref.2 = import_ref Core//prelude/operators/as, inst+42, unloaded
  127. // CHECK:STDOUT: %import_ref.3: @ImplicitAs.%.2 (%.4) = import_ref Core//prelude/operators/as, inst+59, loaded [symbolic = @ImplicitAs.%.3 (constants.%.9)]
  128. // CHECK:STDOUT: %import_ref.4 = import_ref Core//prelude/operators/as, inst+52, unloaded
  129. // CHECK:STDOUT: %import_ref.5 = import_ref Core//prelude/operators/as, inst+52, unloaded
  130. // CHECK:STDOUT: %import_ref.6 = import_ref Core//prelude/operators/as, inst+52, unloaded
  131. // CHECK:STDOUT: }
  132. // CHECK:STDOUT:
  133. // CHECK:STDOUT: file {
  134. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  135. // CHECK:STDOUT: .Core = imports.%Core
  136. // CHECK:STDOUT: .Bad = %Bad.decl
  137. // CHECK:STDOUT: .Use = %Use.decl
  138. // CHECK:STDOUT: }
  139. // CHECK:STDOUT: %Core.import = import Core
  140. // CHECK:STDOUT: %Bad.decl: type = class_decl @Bad [template = constants.%Bad] {}
  141. // CHECK:STDOUT: %Use.decl: %Use.type = fn_decl @Use [template = constants.%Use] {
  142. // CHECK:STDOUT: %Bad.ref: type = name_ref Bad, %Bad.decl [template = constants.%Bad]
  143. // CHECK:STDOUT: %b.loc19_8.1: %Bad = param b, runtime_param0
  144. // CHECK:STDOUT: @Use.%b: %Bad = bind_name b, %b.loc19_8.1
  145. // CHECK:STDOUT: }
  146. // CHECK:STDOUT: }
  147. // CHECK:STDOUT:
  148. // CHECK:STDOUT: generic interface @ImplicitAs(constants.%Dest: type) {
  149. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest 0 [symbolic = %Dest (constants.%Dest)]
  150. // CHECK:STDOUT:
  151. // CHECK:STDOUT: !definition:
  152. // CHECK:STDOUT: %.1: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic = %.1 (constants.%.3)]
  153. // CHECK:STDOUT: %Self: %.3 = bind_symbolic_name Self 1 [symbolic = %Self (constants.%Self.2)]
  154. // CHECK:STDOUT: %Convert.type: type = fn_type @Convert, @ImplicitAs(%Dest) [symbolic = %Convert.type (constants.%Convert.type.1)]
  155. // CHECK:STDOUT: %Convert: @ImplicitAs.%Convert.type (%Convert.type.1) = struct_value () [symbolic = %Convert (constants.%Convert.1)]
  156. // CHECK:STDOUT: %.2: type = assoc_entity_type @ImplicitAs.%.1 (%.3), @ImplicitAs.%Convert.type (%Convert.type.1) [symbolic = %.2 (constants.%.4)]
  157. // CHECK:STDOUT: %.3: @ImplicitAs.%.2 (%.4) = assoc_entity element0, imports.%import_ref.5 [symbolic = %.3 (constants.%.5)]
  158. // CHECK:STDOUT:
  159. // CHECK:STDOUT: interface {
  160. // CHECK:STDOUT: !members:
  161. // CHECK:STDOUT: .Self = imports.%import_ref.2
  162. // CHECK:STDOUT: .Convert = imports.%import_ref.3
  163. // CHECK:STDOUT: witness = (imports.%import_ref.4)
  164. // CHECK:STDOUT: }
  165. // CHECK:STDOUT: }
  166. // CHECK:STDOUT:
  167. // CHECK:STDOUT: class @Bad {
  168. // CHECK:STDOUT: %.loc12_9: i32 = int_literal 100 [template = constants.%.1]
  169. // CHECK:STDOUT: %.loc12_12.1: type = interface_type @ImplicitAs, @ImplicitAs(type) [template = constants.%.6]
  170. // CHECK:STDOUT: %.loc12_12.2: %.7 = specific_constant imports.%import_ref.3, @ImplicitAs(type) [template = constants.%.8]
  171. // CHECK:STDOUT: %Convert.ref: %.7 = name_ref Convert, %.loc12_12.2 [template = constants.%.8]
  172. // CHECK:STDOUT: %.loc12_12.3: type = converted %.loc12_9, <error> [template = <error>]
  173. // CHECK:STDOUT: adapt_decl <error>
  174. // CHECK:STDOUT:
  175. // CHECK:STDOUT: !members:
  176. // CHECK:STDOUT: .Self = constants.%Bad
  177. // CHECK:STDOUT: }
  178. // CHECK:STDOUT:
  179. // CHECK:STDOUT: generic fn @Convert(constants.%Dest: type, constants.%Self.1: @ImplicitAs.%.1 (%.3)) {
  180. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest 0 [symbolic = %Dest (constants.%Dest)]
  181. // CHECK:STDOUT: %.1: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic = %.1 (constants.%.3)]
  182. // CHECK:STDOUT: %Self: %.3 = bind_symbolic_name Self 1 [symbolic = %Self (constants.%Self.2)]
  183. // CHECK:STDOUT:
  184. // CHECK:STDOUT: fn[%self: @Convert.%Self (%Self.2)]() -> @Convert.%Dest (%Dest);
  185. // CHECK:STDOUT: }
  186. // CHECK:STDOUT:
  187. // CHECK:STDOUT: fn @Use(%b: %Bad) {
  188. // CHECK:STDOUT: !entry:
  189. // CHECK:STDOUT: %b.ref: %Bad = name_ref b, %b
  190. // CHECK:STDOUT: %F.ref: <error> = name_ref F, <error> [template = <error>]
  191. // CHECK:STDOUT: return
  192. // CHECK:STDOUT: }
  193. // CHECK:STDOUT:
  194. // CHECK:STDOUT: specific @ImplicitAs(constants.%Dest) {
  195. // CHECK:STDOUT: %Dest => constants.%Dest
  196. // CHECK:STDOUT: }
  197. // CHECK:STDOUT:
  198. // CHECK:STDOUT: specific @ImplicitAs(@ImplicitAs.%Dest) {
  199. // CHECK:STDOUT: %Dest => constants.%Dest
  200. // CHECK:STDOUT: }
  201. // CHECK:STDOUT:
  202. // CHECK:STDOUT: specific @ImplicitAs(@Convert.%Dest) {
  203. // CHECK:STDOUT: %Dest => constants.%Dest
  204. // CHECK:STDOUT: }
  205. // CHECK:STDOUT:
  206. // CHECK:STDOUT: specific @Convert(constants.%Dest, constants.%Self.1) {
  207. // CHECK:STDOUT: %Dest => constants.%Dest
  208. // CHECK:STDOUT: %.1 => constants.%.3
  209. // CHECK:STDOUT: %Self => constants.%Self.1
  210. // CHECK:STDOUT: }
  211. // CHECK:STDOUT:
  212. // CHECK:STDOUT: specific @ImplicitAs(type) {
  213. // CHECK:STDOUT: %Dest => type
  214. // CHECK:STDOUT:
  215. // CHECK:STDOUT: !definition:
  216. // CHECK:STDOUT: %.1 => constants.%.6
  217. // CHECK:STDOUT: %Self => constants.%Self.2
  218. // CHECK:STDOUT: %Convert.type => constants.%Convert.type.2
  219. // CHECK:STDOUT: %Convert => constants.%Convert.2
  220. // CHECK:STDOUT: %.2 => constants.%.7
  221. // CHECK:STDOUT: %.3 => constants.%.8
  222. // CHECK:STDOUT: }
  223. // CHECK:STDOUT:
  224. // CHECK:STDOUT: --- fail_extend_not_type.carbon
  225. // CHECK:STDOUT:
  226. // CHECK:STDOUT: constants {
  227. // CHECK:STDOUT: %Bad: type = class_type @Bad [template]
  228. // CHECK:STDOUT: %.1: i32 = int_literal 100 [template]
  229. // CHECK:STDOUT: %ImplicitAs.type: type = generic_interface_type @ImplicitAs [template]
  230. // CHECK:STDOUT: %.2: type = tuple_type () [template]
  231. // CHECK:STDOUT: %ImplicitAs: %ImplicitAs.type = struct_value () [template]
  232. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest 0 [symbolic]
  233. // CHECK:STDOUT: %.3: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic]
  234. // CHECK:STDOUT: %Self.1: @ImplicitAs.%.1 (%.3) = bind_symbolic_name Self 1 [symbolic]
  235. // CHECK:STDOUT: %Self.2: %.3 = bind_symbolic_name Self 1 [symbolic]
  236. // CHECK:STDOUT: %Convert.type.1: type = fn_type @Convert, @ImplicitAs(%Dest) [symbolic]
  237. // CHECK:STDOUT: %Convert.1: %Convert.type.1 = struct_value () [symbolic]
  238. // CHECK:STDOUT: %.4: type = assoc_entity_type %.3, %Convert.type.1 [symbolic]
  239. // CHECK:STDOUT: %.5: %.4 = assoc_entity element0, imports.%import_ref.5 [symbolic]
  240. // CHECK:STDOUT: %.6: type = interface_type @ImplicitAs, @ImplicitAs(type) [template]
  241. // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert, @ImplicitAs(type) [template]
  242. // CHECK:STDOUT: %Convert.2: %Convert.type.2 = struct_value () [template]
  243. // CHECK:STDOUT: %.7: type = assoc_entity_type %.6, %Convert.type.2 [template]
  244. // CHECK:STDOUT: %.8: %.7 = assoc_entity element0, imports.%import_ref.5 [template]
  245. // CHECK:STDOUT: %.9: %.4 = assoc_entity element0, imports.%import_ref.6 [symbolic]
  246. // CHECK:STDOUT: %Use.type: type = fn_type @Use [template]
  247. // CHECK:STDOUT: %Use: %Use.type = struct_value () [template]
  248. // CHECK:STDOUT: }
  249. // CHECK:STDOUT:
  250. // CHECK:STDOUT: imports {
  251. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  252. // CHECK:STDOUT: .ImplicitAs = %import_ref.1
  253. // CHECK:STDOUT: import Core//prelude
  254. // CHECK:STDOUT: import Core//prelude/operators
  255. // CHECK:STDOUT: import Core//prelude/types
  256. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  257. // CHECK:STDOUT: import Core//prelude/operators/as
  258. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  259. // CHECK:STDOUT: import Core//prelude/operators/comparison
  260. // CHECK:STDOUT: import Core//prelude/types/bool
  261. // CHECK:STDOUT: }
  262. // CHECK:STDOUT: %import_ref.1: %ImplicitAs.type = import_ref Core//prelude/operators/as, inst+37, loaded [template = constants.%ImplicitAs]
  263. // CHECK:STDOUT: %import_ref.2 = import_ref Core//prelude/operators/as, inst+42, unloaded
  264. // CHECK:STDOUT: %import_ref.3: @ImplicitAs.%.2 (%.4) = import_ref Core//prelude/operators/as, inst+59, loaded [symbolic = @ImplicitAs.%.3 (constants.%.9)]
  265. // CHECK:STDOUT: %import_ref.4 = import_ref Core//prelude/operators/as, inst+52, unloaded
  266. // CHECK:STDOUT: %import_ref.5 = import_ref Core//prelude/operators/as, inst+52, unloaded
  267. // CHECK:STDOUT: %import_ref.6 = import_ref Core//prelude/operators/as, inst+52, unloaded
  268. // CHECK:STDOUT: }
  269. // CHECK:STDOUT:
  270. // CHECK:STDOUT: file {
  271. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  272. // CHECK:STDOUT: .Core = imports.%Core
  273. // CHECK:STDOUT: .Bad = %Bad.decl
  274. // CHECK:STDOUT: .Use = %Use.decl
  275. // CHECK:STDOUT: }
  276. // CHECK:STDOUT: %Core.import = import Core
  277. // CHECK:STDOUT: %Bad.decl: type = class_decl @Bad [template = constants.%Bad] {}
  278. // CHECK:STDOUT: %Use.decl: %Use.type = fn_decl @Use [template = constants.%Use] {
  279. // CHECK:STDOUT: %Bad.ref: type = name_ref Bad, %Bad.decl [template = constants.%Bad]
  280. // CHECK:STDOUT: %b.loc16_8.1: %Bad = param b, runtime_param0
  281. // CHECK:STDOUT: @Use.%b: %Bad = bind_name b, %b.loc16_8.1
  282. // CHECK:STDOUT: }
  283. // CHECK:STDOUT: }
  284. // CHECK:STDOUT:
  285. // CHECK:STDOUT: generic interface @ImplicitAs(constants.%Dest: type) {
  286. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest 0 [symbolic = %Dest (constants.%Dest)]
  287. // CHECK:STDOUT:
  288. // CHECK:STDOUT: !definition:
  289. // CHECK:STDOUT: %.1: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic = %.1 (constants.%.3)]
  290. // CHECK:STDOUT: %Self: %.3 = bind_symbolic_name Self 1 [symbolic = %Self (constants.%Self.2)]
  291. // CHECK:STDOUT: %Convert.type: type = fn_type @Convert, @ImplicitAs(%Dest) [symbolic = %Convert.type (constants.%Convert.type.1)]
  292. // CHECK:STDOUT: %Convert: @ImplicitAs.%Convert.type (%Convert.type.1) = struct_value () [symbolic = %Convert (constants.%Convert.1)]
  293. // CHECK:STDOUT: %.2: type = assoc_entity_type @ImplicitAs.%.1 (%.3), @ImplicitAs.%Convert.type (%Convert.type.1) [symbolic = %.2 (constants.%.4)]
  294. // CHECK:STDOUT: %.3: @ImplicitAs.%.2 (%.4) = assoc_entity element0, imports.%import_ref.5 [symbolic = %.3 (constants.%.5)]
  295. // CHECK:STDOUT:
  296. // CHECK:STDOUT: interface {
  297. // CHECK:STDOUT: !members:
  298. // CHECK:STDOUT: .Self = imports.%import_ref.2
  299. // CHECK:STDOUT: .Convert = imports.%import_ref.3
  300. // CHECK:STDOUT: witness = (imports.%import_ref.4)
  301. // CHECK:STDOUT: }
  302. // CHECK:STDOUT: }
  303. // CHECK:STDOUT:
  304. // CHECK:STDOUT: class @Bad {
  305. // CHECK:STDOUT: %.loc12_16: i32 = int_literal 100 [template = constants.%.1]
  306. // CHECK:STDOUT: %.loc12_19.1: type = interface_type @ImplicitAs, @ImplicitAs(type) [template = constants.%.6]
  307. // CHECK:STDOUT: %.loc12_19.2: %.7 = specific_constant imports.%import_ref.3, @ImplicitAs(type) [template = constants.%.8]
  308. // CHECK:STDOUT: %Convert.ref: %.7 = name_ref Convert, %.loc12_19.2 [template = constants.%.8]
  309. // CHECK:STDOUT: %.loc12_19.3: type = converted %.loc12_16, <error> [template = <error>]
  310. // CHECK:STDOUT: adapt_decl <error>
  311. // CHECK:STDOUT:
  312. // CHECK:STDOUT: !members:
  313. // CHECK:STDOUT: .Self = constants.%Bad
  314. // CHECK:STDOUT: has_error
  315. // CHECK:STDOUT: }
  316. // CHECK:STDOUT:
  317. // CHECK:STDOUT: generic fn @Convert(constants.%Dest: type, constants.%Self.1: @ImplicitAs.%.1 (%.3)) {
  318. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest 0 [symbolic = %Dest (constants.%Dest)]
  319. // CHECK:STDOUT: %.1: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic = %.1 (constants.%.3)]
  320. // CHECK:STDOUT: %Self: %.3 = bind_symbolic_name Self 1 [symbolic = %Self (constants.%Self.2)]
  321. // CHECK:STDOUT:
  322. // CHECK:STDOUT: fn[%self: @Convert.%Self (%Self.2)]() -> @Convert.%Dest (%Dest);
  323. // CHECK:STDOUT: }
  324. // CHECK:STDOUT:
  325. // CHECK:STDOUT: fn @Use(%b: %Bad) {
  326. // CHECK:STDOUT: !entry:
  327. // CHECK:STDOUT: %b.ref: %Bad = name_ref b, %b
  328. // CHECK:STDOUT: %F.ref: <error> = name_ref F, <error> [template = <error>]
  329. // CHECK:STDOUT: return
  330. // CHECK:STDOUT: }
  331. // CHECK:STDOUT:
  332. // CHECK:STDOUT: specific @ImplicitAs(constants.%Dest) {
  333. // CHECK:STDOUT: %Dest => constants.%Dest
  334. // CHECK:STDOUT: }
  335. // CHECK:STDOUT:
  336. // CHECK:STDOUT: specific @ImplicitAs(@ImplicitAs.%Dest) {
  337. // CHECK:STDOUT: %Dest => constants.%Dest
  338. // CHECK:STDOUT: }
  339. // CHECK:STDOUT:
  340. // CHECK:STDOUT: specific @ImplicitAs(@Convert.%Dest) {
  341. // CHECK:STDOUT: %Dest => constants.%Dest
  342. // CHECK:STDOUT: }
  343. // CHECK:STDOUT:
  344. // CHECK:STDOUT: specific @Convert(constants.%Dest, constants.%Self.1) {
  345. // CHECK:STDOUT: %Dest => constants.%Dest
  346. // CHECK:STDOUT: %.1 => constants.%.3
  347. // CHECK:STDOUT: %Self => constants.%Self.1
  348. // CHECK:STDOUT: }
  349. // CHECK:STDOUT:
  350. // CHECK:STDOUT: specific @ImplicitAs(type) {
  351. // CHECK:STDOUT: %Dest => type
  352. // CHECK:STDOUT:
  353. // CHECK:STDOUT: !definition:
  354. // CHECK:STDOUT: %.1 => constants.%.6
  355. // CHECK:STDOUT: %Self => constants.%Self.2
  356. // CHECK:STDOUT: %Convert.type => constants.%Convert.type.2
  357. // CHECK:STDOUT: %Convert => constants.%Convert.2
  358. // CHECK:STDOUT: %.2 => constants.%.7
  359. // CHECK:STDOUT: %.3 => constants.%.8
  360. // CHECK:STDOUT: }
  361. // CHECK:STDOUT:
  362. // CHECK:STDOUT: --- fail_repeated.carbon
  363. // CHECK:STDOUT:
  364. // CHECK:STDOUT: constants {
  365. // CHECK:STDOUT: %MultipleAdapts: type = class_type @MultipleAdapts [template]
  366. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  367. // CHECK:STDOUT: %.2: type = struct_type {} [template]
  368. // CHECK:STDOUT: %MultipleAdaptsSameType: type = class_type @MultipleAdaptsSameType [template]
  369. // CHECK:STDOUT: }
  370. // CHECK:STDOUT:
  371. // CHECK:STDOUT: imports {
  372. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  373. // CHECK:STDOUT: import Core//prelude
  374. // CHECK:STDOUT: import Core//prelude/operators
  375. // CHECK:STDOUT: import Core//prelude/types
  376. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  377. // CHECK:STDOUT: import Core//prelude/operators/as
  378. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  379. // CHECK:STDOUT: import Core//prelude/operators/comparison
  380. // CHECK:STDOUT: import Core//prelude/types/bool
  381. // CHECK:STDOUT: }
  382. // CHECK:STDOUT: }
  383. // CHECK:STDOUT:
  384. // CHECK:STDOUT: file {
  385. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  386. // CHECK:STDOUT: .Core = imports.%Core
  387. // CHECK:STDOUT: .MultipleAdapts = %MultipleAdapts.decl
  388. // CHECK:STDOUT: .MultipleAdaptsSameType = %MultipleAdaptsSameType.decl
  389. // CHECK:STDOUT: }
  390. // CHECK:STDOUT: %Core.import = import Core
  391. // CHECK:STDOUT: %MultipleAdapts.decl: type = class_decl @MultipleAdapts [template = constants.%MultipleAdapts] {}
  392. // CHECK:STDOUT: %MultipleAdaptsSameType.decl: type = class_decl @MultipleAdaptsSameType [template = constants.%MultipleAdaptsSameType] {}
  393. // CHECK:STDOUT: }
  394. // CHECK:STDOUT:
  395. // CHECK:STDOUT: class @MultipleAdapts {
  396. // CHECK:STDOUT: %.loc5_10: %.1 = tuple_literal ()
  397. // CHECK:STDOUT: %.loc5_11: type = converted %.loc5_10, constants.%.1 [template = constants.%.1]
  398. // CHECK:STDOUT: adapt_decl %.1
  399. // CHECK:STDOUT: %.loc13: %.2 = struct_literal ()
  400. // CHECK:STDOUT:
  401. // CHECK:STDOUT: !members:
  402. // CHECK:STDOUT: .Self = constants.%MultipleAdapts
  403. // CHECK:STDOUT: }
  404. // CHECK:STDOUT:
  405. // CHECK:STDOUT: class @MultipleAdaptsSameType {
  406. // CHECK:STDOUT: %.loc17_10: %.1 = tuple_literal ()
  407. // CHECK:STDOUT: %.loc17_11: type = converted %.loc17_10, constants.%.1 [template = constants.%.1]
  408. // CHECK:STDOUT: adapt_decl %.1
  409. // CHECK:STDOUT: %.loc25: %.1 = tuple_literal ()
  410. // CHECK:STDOUT:
  411. // CHECK:STDOUT: !members:
  412. // CHECK:STDOUT: .Self = constants.%MultipleAdaptsSameType
  413. // CHECK:STDOUT: }
  414. // CHECK:STDOUT:
  415. // CHECK:STDOUT: --- fail_bad_scope.carbon
  416. // CHECK:STDOUT:
  417. // CHECK:STDOUT: constants {
  418. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  419. // CHECK:STDOUT: %.2: type = interface_type @I.1 [template]
  420. // CHECK:STDOUT: %Self.1: %.2 = bind_symbolic_name Self 0 [symbolic]
  421. // CHECK:STDOUT: %C: type = class_type @C [template]
  422. // CHECK:STDOUT: %.3: type = interface_type @I.2 [template]
  423. // CHECK:STDOUT: %Self.2: %.3 = bind_symbolic_name Self 0 [symbolic]
  424. // CHECK:STDOUT: }
  425. // CHECK:STDOUT:
  426. // CHECK:STDOUT: imports {
  427. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  428. // CHECK:STDOUT: import Core//prelude
  429. // CHECK:STDOUT: import Core//prelude/operators
  430. // CHECK:STDOUT: import Core//prelude/types
  431. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  432. // CHECK:STDOUT: import Core//prelude/operators/as
  433. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  434. // CHECK:STDOUT: import Core//prelude/operators/comparison
  435. // CHECK:STDOUT: import Core//prelude/types/bool
  436. // CHECK:STDOUT: }
  437. // CHECK:STDOUT: }
  438. // CHECK:STDOUT:
  439. // CHECK:STDOUT: file {
  440. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  441. // CHECK:STDOUT: .Core = imports.%Core
  442. // CHECK:STDOUT: .I = %I.decl
  443. // CHECK:STDOUT: .C = %C.decl
  444. // CHECK:STDOUT: }
  445. // CHECK:STDOUT: %Core.import = import Core
  446. // CHECK:STDOUT: %.loc8: %.1 = struct_literal ()
  447. // CHECK:STDOUT: %I.decl: type = interface_decl @I.1 [template = constants.%.2] {}
  448. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {}
  449. // CHECK:STDOUT: }
  450. // CHECK:STDOUT:
  451. // CHECK:STDOUT: interface @I.1 {
  452. // CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 0 [symbolic = constants.%Self.1]
  453. // CHECK:STDOUT: %.loc15: %.1 = struct_literal ()
  454. // CHECK:STDOUT:
  455. // CHECK:STDOUT: !members:
  456. // CHECK:STDOUT: .Self = %Self
  457. // CHECK:STDOUT: witness = ()
  458. // CHECK:STDOUT: }
  459. // CHECK:STDOUT:
  460. // CHECK:STDOUT: interface @I.2 {
  461. // CHECK:STDOUT: %Self: %.3 = bind_symbolic_name Self 0 [symbolic = constants.%Self.2]
  462. // CHECK:STDOUT: %.loc23: %.1 = struct_literal ()
  463. // CHECK:STDOUT:
  464. // CHECK:STDOUT: !members:
  465. // CHECK:STDOUT: .Self = %Self
  466. // CHECK:STDOUT: witness = ()
  467. // CHECK:STDOUT: }
  468. // CHECK:STDOUT:
  469. // CHECK:STDOUT: class @C {
  470. // CHECK:STDOUT: %I.decl: type = interface_decl @I.2 [template = constants.%.3] {}
  471. // CHECK:STDOUT:
  472. // CHECK:STDOUT: !members:
  473. // CHECK:STDOUT: .Self = constants.%C
  474. // CHECK:STDOUT: .I = %I.decl
  475. // CHECK:STDOUT: }
  476. // CHECK:STDOUT: