fail_adapt_bad_decl.carbon 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  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` [ImplicitAsConversionFailure]
  14. // CHECK:STDERR: adapt 100;
  15. // CHECK:STDERR: ^~~~~~~~~~
  16. // CHECK:STDERR: fail_not_type.carbon:[[@LINE+4]]:3: note: type `i32` does not implement interface `ImplicitAs` [MissingImplInMemberAccessNote]
  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 [NameNotFound]
  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` [ImplicitAsConversionFailure]
  31. // CHECK:STDERR: extend adapt 100;
  32. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~
  33. // CHECK:STDERR: fail_extend_not_type.carbon:[[@LINE+4]]:3: note: type `i32` does not implement interface `ImplicitAs` [MissingImplInMemberAccessNote]
  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 [AdaptDeclRepeated]
  46. // CHECK:STDERR: adapt {};
  47. // CHECK:STDERR: ^~~~~~~~~
  48. // CHECK:STDERR: fail_repeated.carbon:[[@LINE-4]]:3: note: previous `adapt` declaration is here [ClassSpecificDeclPrevious]
  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 [AdaptDeclRepeated]
  57. // CHECK:STDERR: adapt ();
  58. // CHECK:STDERR: ^~~~~~~~~
  59. // CHECK:STDERR: fail_repeated.carbon:[[@LINE-4]]:3: note: previous `adapt` declaration is here [ClassSpecificDeclPrevious]
  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 outside class [ClassSpecificDeclOutsideClass]
  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 outside class [ClassSpecificDeclOutsideClass]
  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 outside class [ClassSpecificDeclOutsideClass]
  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_value 100 [template]
  92. // CHECK:STDOUT: %ImplicitAs.type.1: type = generic_interface_type @ImplicitAs [template]
  93. // CHECK:STDOUT: %.2: type = tuple_type () [template]
  94. // CHECK:STDOUT: %ImplicitAs: %ImplicitAs.type.1 = struct_value () [template]
  95. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic]
  96. // CHECK:STDOUT: %ImplicitAs.type.2: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic]
  97. // CHECK:STDOUT: %Self.1: @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2) = bind_symbolic_name Self, 1 [symbolic]
  98. // CHECK:STDOUT: %Dest.patt: type = symbolic_binding_pattern Dest, 0 [symbolic]
  99. // CHECK:STDOUT: %Self.2: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic]
  100. // CHECK:STDOUT: %Convert.type.1: type = fn_type @Convert, @ImplicitAs(%Dest) [symbolic]
  101. // CHECK:STDOUT: %Convert.1: %Convert.type.1 = struct_value () [symbolic]
  102. // CHECK:STDOUT: %.3: type = assoc_entity_type %ImplicitAs.type.2, %Convert.type.1 [symbolic]
  103. // CHECK:STDOUT: %.4: %.3 = assoc_entity element0, imports.%import_ref.5 [symbolic]
  104. // CHECK:STDOUT: %ImplicitAs.type.3: type = interface_type @ImplicitAs, @ImplicitAs(type) [template]
  105. // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert, @ImplicitAs(type) [template]
  106. // CHECK:STDOUT: %Convert.2: %Convert.type.2 = struct_value () [template]
  107. // CHECK:STDOUT: %.5: type = assoc_entity_type %ImplicitAs.type.3, %Convert.type.2 [template]
  108. // CHECK:STDOUT: %.6: %.5 = assoc_entity element0, imports.%import_ref.5 [template]
  109. // CHECK:STDOUT: %.7: %.3 = assoc_entity element0, imports.%import_ref.6 [symbolic]
  110. // CHECK:STDOUT: %Use.type: type = fn_type @Use [template]
  111. // CHECK:STDOUT: %Use: %Use.type = struct_value () [template]
  112. // CHECK:STDOUT: }
  113. // CHECK:STDOUT:
  114. // CHECK:STDOUT: imports {
  115. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  116. // CHECK:STDOUT: .ImplicitAs = %import_ref.1
  117. // CHECK:STDOUT: import Core//prelude
  118. // CHECK:STDOUT: import Core//prelude/...
  119. // CHECK:STDOUT: }
  120. // CHECK:STDOUT: %import_ref.1: %ImplicitAs.type.1 = import_ref Core//prelude/operators/as, inst+49, loaded [template = constants.%ImplicitAs]
  121. // CHECK:STDOUT: %import_ref.2 = import_ref Core//prelude/operators/as, inst+55, unloaded
  122. // CHECK:STDOUT: %import_ref.3: @ImplicitAs.%.1 (%.3) = import_ref Core//prelude/operators/as, inst+77, loaded [symbolic = @ImplicitAs.%.2 (constants.%.7)]
  123. // CHECK:STDOUT: %import_ref.4 = import_ref Core//prelude/operators/as, inst+70, unloaded
  124. // CHECK:STDOUT: %import_ref.5 = import_ref Core//prelude/operators/as, inst+70, unloaded
  125. // CHECK:STDOUT: %import_ref.6 = import_ref Core//prelude/operators/as, inst+70, unloaded
  126. // CHECK:STDOUT: }
  127. // CHECK:STDOUT:
  128. // CHECK:STDOUT: file {
  129. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  130. // CHECK:STDOUT: .Core = imports.%Core
  131. // CHECK:STDOUT: .Bad = %Bad.decl
  132. // CHECK:STDOUT: .Use = %Use.decl
  133. // CHECK:STDOUT: }
  134. // CHECK:STDOUT: %Core.import = import Core
  135. // CHECK:STDOUT: %Bad.decl: type = class_decl @Bad [template = constants.%Bad] {} {}
  136. // CHECK:STDOUT: %Use.decl: %Use.type = fn_decl @Use [template = constants.%Use] {
  137. // CHECK:STDOUT: %b.patt: %Bad = binding_pattern b
  138. // CHECK:STDOUT: %b.param_patt: %Bad = value_param_pattern %b.patt, runtime_param0
  139. // CHECK:STDOUT: } {
  140. // CHECK:STDOUT: %Bad.ref: type = name_ref Bad, file.%Bad.decl [template = constants.%Bad]
  141. // CHECK:STDOUT: %b.param: %Bad = value_param runtime_param0
  142. // CHECK:STDOUT: %b: %Bad = bind_name b, %b.param
  143. // CHECK:STDOUT: }
  144. // CHECK:STDOUT: }
  145. // CHECK:STDOUT:
  146. // CHECK:STDOUT: generic interface @ImplicitAs(constants.%Dest: type) {
  147. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic = %Dest (constants.%Dest)]
  148. // CHECK:STDOUT: %Dest.patt: type = symbolic_binding_pattern Dest, 0 [symbolic = %Dest.patt (constants.%Dest.patt)]
  149. // CHECK:STDOUT:
  150. // CHECK:STDOUT: !definition:
  151. // CHECK:STDOUT: %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic = %ImplicitAs.type (constants.%ImplicitAs.type.2)]
  152. // CHECK:STDOUT: %Self: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.2)]
  153. // CHECK:STDOUT: %Convert.type: type = fn_type @Convert, @ImplicitAs(%Dest) [symbolic = %Convert.type (constants.%Convert.type.1)]
  154. // CHECK:STDOUT: %Convert: @ImplicitAs.%Convert.type (%Convert.type.1) = struct_value () [symbolic = %Convert (constants.%Convert.1)]
  155. // CHECK:STDOUT: %.1: type = assoc_entity_type @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2), @ImplicitAs.%Convert.type (%Convert.type.1) [symbolic = %.1 (constants.%.3)]
  156. // CHECK:STDOUT: %.2: @ImplicitAs.%.1 (%.3) = assoc_entity element0, imports.%import_ref.5 [symbolic = %.2 (constants.%.4)]
  157. // CHECK:STDOUT:
  158. // CHECK:STDOUT: interface {
  159. // CHECK:STDOUT: !members:
  160. // CHECK:STDOUT: .Self = imports.%import_ref.2
  161. // CHECK:STDOUT: .Convert = imports.%import_ref.3
  162. // CHECK:STDOUT: witness = (imports.%import_ref.4)
  163. // CHECK:STDOUT: }
  164. // CHECK:STDOUT: }
  165. // CHECK:STDOUT:
  166. // CHECK:STDOUT: class @Bad {
  167. // CHECK:STDOUT: %.loc12_9: i32 = int_value 100 [template = constants.%.1]
  168. // CHECK:STDOUT: %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(type) [template = constants.%ImplicitAs.type.3]
  169. // CHECK:STDOUT: %.loc12_12.1: %.5 = specific_constant imports.%import_ref.3, @ImplicitAs(type) [template = constants.%.6]
  170. // CHECK:STDOUT: %Convert.ref: %.5 = name_ref Convert, %.loc12_12.1 [template = constants.%.6]
  171. // CHECK:STDOUT: %.loc12_12.2: type = converted %.loc12_9, <error> [template = <error>]
  172. // CHECK:STDOUT: adapt_decl <error>
  173. // CHECK:STDOUT: %.loc13: <witness> = complete_type_witness <error> [template = <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.%ImplicitAs.type (%ImplicitAs.type.2)) {
  180. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic = %Dest (constants.%Dest)]
  181. // CHECK:STDOUT: %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic = %ImplicitAs.type (constants.%ImplicitAs.type.2)]
  182. // CHECK:STDOUT: %Self: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.2)]
  183. // CHECK:STDOUT:
  184. // CHECK:STDOUT: fn[%self.param_patt: @Convert.%Self (%Self.2)]() -> @Convert.%Dest (%Dest);
  185. // CHECK:STDOUT: }
  186. // CHECK:STDOUT:
  187. // CHECK:STDOUT: fn @Use(%b.param_patt: %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: %Dest.patt => constants.%Dest
  197. // CHECK:STDOUT: }
  198. // CHECK:STDOUT:
  199. // CHECK:STDOUT: specific @ImplicitAs(@ImplicitAs.%Dest) {
  200. // CHECK:STDOUT: %Dest => constants.%Dest
  201. // CHECK:STDOUT: %Dest.patt => constants.%Dest
  202. // CHECK:STDOUT: }
  203. // CHECK:STDOUT:
  204. // CHECK:STDOUT: specific @ImplicitAs(@Convert.%Dest) {
  205. // CHECK:STDOUT: %Dest => constants.%Dest
  206. // CHECK:STDOUT: %Dest.patt => constants.%Dest
  207. // CHECK:STDOUT: }
  208. // CHECK:STDOUT:
  209. // CHECK:STDOUT: specific @Convert(constants.%Dest, constants.%Self.1) {
  210. // CHECK:STDOUT: %Dest => constants.%Dest
  211. // CHECK:STDOUT: %ImplicitAs.type => constants.%ImplicitAs.type.2
  212. // CHECK:STDOUT: %Self => constants.%Self.1
  213. // CHECK:STDOUT: }
  214. // CHECK:STDOUT:
  215. // CHECK:STDOUT: specific @ImplicitAs(type) {
  216. // CHECK:STDOUT: %Dest => type
  217. // CHECK:STDOUT: %Dest.patt => type
  218. // CHECK:STDOUT:
  219. // CHECK:STDOUT: !definition:
  220. // CHECK:STDOUT: %ImplicitAs.type => constants.%ImplicitAs.type.3
  221. // CHECK:STDOUT: %Self => constants.%Self.2
  222. // CHECK:STDOUT: %Convert.type => constants.%Convert.type.2
  223. // CHECK:STDOUT: %Convert => constants.%Convert.2
  224. // CHECK:STDOUT: %.1 => constants.%.5
  225. // CHECK:STDOUT: %.2 => constants.%.6
  226. // CHECK:STDOUT: }
  227. // CHECK:STDOUT:
  228. // CHECK:STDOUT: --- fail_extend_not_type.carbon
  229. // CHECK:STDOUT:
  230. // CHECK:STDOUT: constants {
  231. // CHECK:STDOUT: %Bad: type = class_type @Bad [template]
  232. // CHECK:STDOUT: %.1: i32 = int_value 100 [template]
  233. // CHECK:STDOUT: %ImplicitAs.type.1: type = generic_interface_type @ImplicitAs [template]
  234. // CHECK:STDOUT: %.2: type = tuple_type () [template]
  235. // CHECK:STDOUT: %ImplicitAs: %ImplicitAs.type.1 = struct_value () [template]
  236. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic]
  237. // CHECK:STDOUT: %ImplicitAs.type.2: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic]
  238. // CHECK:STDOUT: %Self.1: @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2) = bind_symbolic_name Self, 1 [symbolic]
  239. // CHECK:STDOUT: %Dest.patt: type = symbolic_binding_pattern Dest, 0 [symbolic]
  240. // CHECK:STDOUT: %Self.2: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic]
  241. // CHECK:STDOUT: %Convert.type.1: type = fn_type @Convert, @ImplicitAs(%Dest) [symbolic]
  242. // CHECK:STDOUT: %Convert.1: %Convert.type.1 = struct_value () [symbolic]
  243. // CHECK:STDOUT: %.3: type = assoc_entity_type %ImplicitAs.type.2, %Convert.type.1 [symbolic]
  244. // CHECK:STDOUT: %.4: %.3 = assoc_entity element0, imports.%import_ref.5 [symbolic]
  245. // CHECK:STDOUT: %ImplicitAs.type.3: type = interface_type @ImplicitAs, @ImplicitAs(type) [template]
  246. // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert, @ImplicitAs(type) [template]
  247. // CHECK:STDOUT: %Convert.2: %Convert.type.2 = struct_value () [template]
  248. // CHECK:STDOUT: %.5: type = assoc_entity_type %ImplicitAs.type.3, %Convert.type.2 [template]
  249. // CHECK:STDOUT: %.6: %.5 = assoc_entity element0, imports.%import_ref.5 [template]
  250. // CHECK:STDOUT: %.7: %.3 = assoc_entity element0, imports.%import_ref.6 [symbolic]
  251. // CHECK:STDOUT: %Use.type: type = fn_type @Use [template]
  252. // CHECK:STDOUT: %Use: %Use.type = struct_value () [template]
  253. // CHECK:STDOUT: }
  254. // CHECK:STDOUT:
  255. // CHECK:STDOUT: imports {
  256. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  257. // CHECK:STDOUT: .ImplicitAs = %import_ref.1
  258. // CHECK:STDOUT: import Core//prelude
  259. // CHECK:STDOUT: import Core//prelude/...
  260. // CHECK:STDOUT: }
  261. // CHECK:STDOUT: %import_ref.1: %ImplicitAs.type.1 = import_ref Core//prelude/operators/as, inst+49, loaded [template = constants.%ImplicitAs]
  262. // CHECK:STDOUT: %import_ref.2 = import_ref Core//prelude/operators/as, inst+55, unloaded
  263. // CHECK:STDOUT: %import_ref.3: @ImplicitAs.%.1 (%.3) = import_ref Core//prelude/operators/as, inst+77, loaded [symbolic = @ImplicitAs.%.2 (constants.%.7)]
  264. // CHECK:STDOUT: %import_ref.4 = import_ref Core//prelude/operators/as, inst+70, unloaded
  265. // CHECK:STDOUT: %import_ref.5 = import_ref Core//prelude/operators/as, inst+70, unloaded
  266. // CHECK:STDOUT: %import_ref.6 = import_ref Core//prelude/operators/as, inst+70, unloaded
  267. // CHECK:STDOUT: }
  268. // CHECK:STDOUT:
  269. // CHECK:STDOUT: file {
  270. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  271. // CHECK:STDOUT: .Core = imports.%Core
  272. // CHECK:STDOUT: .Bad = %Bad.decl
  273. // CHECK:STDOUT: .Use = %Use.decl
  274. // CHECK:STDOUT: }
  275. // CHECK:STDOUT: %Core.import = import Core
  276. // CHECK:STDOUT: %Bad.decl: type = class_decl @Bad [template = constants.%Bad] {} {}
  277. // CHECK:STDOUT: %Use.decl: %Use.type = fn_decl @Use [template = constants.%Use] {
  278. // CHECK:STDOUT: %b.patt: %Bad = binding_pattern b
  279. // CHECK:STDOUT: %b.param_patt: %Bad = value_param_pattern %b.patt, runtime_param0
  280. // CHECK:STDOUT: } {
  281. // CHECK:STDOUT: %Bad.ref: type = name_ref Bad, file.%Bad.decl [template = constants.%Bad]
  282. // CHECK:STDOUT: %b.param: %Bad = value_param runtime_param0
  283. // CHECK:STDOUT: %b: %Bad = bind_name b, %b.param
  284. // CHECK:STDOUT: }
  285. // CHECK:STDOUT: }
  286. // CHECK:STDOUT:
  287. // CHECK:STDOUT: generic interface @ImplicitAs(constants.%Dest: type) {
  288. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic = %Dest (constants.%Dest)]
  289. // CHECK:STDOUT: %Dest.patt: type = symbolic_binding_pattern Dest, 0 [symbolic = %Dest.patt (constants.%Dest.patt)]
  290. // CHECK:STDOUT:
  291. // CHECK:STDOUT: !definition:
  292. // CHECK:STDOUT: %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic = %ImplicitAs.type (constants.%ImplicitAs.type.2)]
  293. // CHECK:STDOUT: %Self: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.2)]
  294. // CHECK:STDOUT: %Convert.type: type = fn_type @Convert, @ImplicitAs(%Dest) [symbolic = %Convert.type (constants.%Convert.type.1)]
  295. // CHECK:STDOUT: %Convert: @ImplicitAs.%Convert.type (%Convert.type.1) = struct_value () [symbolic = %Convert (constants.%Convert.1)]
  296. // CHECK:STDOUT: %.1: type = assoc_entity_type @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2), @ImplicitAs.%Convert.type (%Convert.type.1) [symbolic = %.1 (constants.%.3)]
  297. // CHECK:STDOUT: %.2: @ImplicitAs.%.1 (%.3) = assoc_entity element0, imports.%import_ref.5 [symbolic = %.2 (constants.%.4)]
  298. // CHECK:STDOUT:
  299. // CHECK:STDOUT: interface {
  300. // CHECK:STDOUT: !members:
  301. // CHECK:STDOUT: .Self = imports.%import_ref.2
  302. // CHECK:STDOUT: .Convert = imports.%import_ref.3
  303. // CHECK:STDOUT: witness = (imports.%import_ref.4)
  304. // CHECK:STDOUT: }
  305. // CHECK:STDOUT: }
  306. // CHECK:STDOUT:
  307. // CHECK:STDOUT: class @Bad {
  308. // CHECK:STDOUT: %.loc12_16: i32 = int_value 100 [template = constants.%.1]
  309. // CHECK:STDOUT: %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(type) [template = constants.%ImplicitAs.type.3]
  310. // CHECK:STDOUT: %.loc12_19.1: %.5 = specific_constant imports.%import_ref.3, @ImplicitAs(type) [template = constants.%.6]
  311. // CHECK:STDOUT: %Convert.ref: %.5 = name_ref Convert, %.loc12_19.1 [template = constants.%.6]
  312. // CHECK:STDOUT: %.loc12_19.2: type = converted %.loc12_16, <error> [template = <error>]
  313. // CHECK:STDOUT: adapt_decl <error>
  314. // CHECK:STDOUT: %.loc13: <witness> = complete_type_witness <error> [template = <error>]
  315. // CHECK:STDOUT:
  316. // CHECK:STDOUT: !members:
  317. // CHECK:STDOUT: .Self = constants.%Bad
  318. // CHECK:STDOUT: has_error
  319. // CHECK:STDOUT: }
  320. // CHECK:STDOUT:
  321. // CHECK:STDOUT: generic fn @Convert(constants.%Dest: type, constants.%Self.1: @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2)) {
  322. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic = %Dest (constants.%Dest)]
  323. // CHECK:STDOUT: %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic = %ImplicitAs.type (constants.%ImplicitAs.type.2)]
  324. // CHECK:STDOUT: %Self: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.2)]
  325. // CHECK:STDOUT:
  326. // CHECK:STDOUT: fn[%self.param_patt: @Convert.%Self (%Self.2)]() -> @Convert.%Dest (%Dest);
  327. // CHECK:STDOUT: }
  328. // CHECK:STDOUT:
  329. // CHECK:STDOUT: fn @Use(%b.param_patt: %Bad) {
  330. // CHECK:STDOUT: !entry:
  331. // CHECK:STDOUT: %b.ref: %Bad = name_ref b, %b
  332. // CHECK:STDOUT: %F.ref: <error> = name_ref F, <error> [template = <error>]
  333. // CHECK:STDOUT: return
  334. // CHECK:STDOUT: }
  335. // CHECK:STDOUT:
  336. // CHECK:STDOUT: specific @ImplicitAs(constants.%Dest) {
  337. // CHECK:STDOUT: %Dest => constants.%Dest
  338. // CHECK:STDOUT: %Dest.patt => constants.%Dest
  339. // CHECK:STDOUT: }
  340. // CHECK:STDOUT:
  341. // CHECK:STDOUT: specific @ImplicitAs(@ImplicitAs.%Dest) {
  342. // CHECK:STDOUT: %Dest => constants.%Dest
  343. // CHECK:STDOUT: %Dest.patt => constants.%Dest
  344. // CHECK:STDOUT: }
  345. // CHECK:STDOUT:
  346. // CHECK:STDOUT: specific @ImplicitAs(@Convert.%Dest) {
  347. // CHECK:STDOUT: %Dest => constants.%Dest
  348. // CHECK:STDOUT: %Dest.patt => constants.%Dest
  349. // CHECK:STDOUT: }
  350. // CHECK:STDOUT:
  351. // CHECK:STDOUT: specific @Convert(constants.%Dest, constants.%Self.1) {
  352. // CHECK:STDOUT: %Dest => constants.%Dest
  353. // CHECK:STDOUT: %ImplicitAs.type => constants.%ImplicitAs.type.2
  354. // CHECK:STDOUT: %Self => constants.%Self.1
  355. // CHECK:STDOUT: }
  356. // CHECK:STDOUT:
  357. // CHECK:STDOUT: specific @ImplicitAs(type) {
  358. // CHECK:STDOUT: %Dest => type
  359. // CHECK:STDOUT: %Dest.patt => type
  360. // CHECK:STDOUT:
  361. // CHECK:STDOUT: !definition:
  362. // CHECK:STDOUT: %ImplicitAs.type => constants.%ImplicitAs.type.3
  363. // CHECK:STDOUT: %Self => constants.%Self.2
  364. // CHECK:STDOUT: %Convert.type => constants.%Convert.type.2
  365. // CHECK:STDOUT: %Convert => constants.%Convert.2
  366. // CHECK:STDOUT: %.1 => constants.%.5
  367. // CHECK:STDOUT: %.2 => constants.%.6
  368. // CHECK:STDOUT: }
  369. // CHECK:STDOUT:
  370. // CHECK:STDOUT: --- fail_repeated.carbon
  371. // CHECK:STDOUT:
  372. // CHECK:STDOUT: constants {
  373. // CHECK:STDOUT: %MultipleAdapts: type = class_type @MultipleAdapts [template]
  374. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  375. // CHECK:STDOUT: %.2: type = struct_type {} [template]
  376. // CHECK:STDOUT: %.3: <witness> = complete_type_witness %.1 [template]
  377. // CHECK:STDOUT: %MultipleAdaptsSameType: type = class_type @MultipleAdaptsSameType [template]
  378. // CHECK:STDOUT: }
  379. // CHECK:STDOUT:
  380. // CHECK:STDOUT: imports {
  381. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  382. // CHECK:STDOUT: import Core//prelude
  383. // CHECK:STDOUT: import Core//prelude/...
  384. // CHECK:STDOUT: }
  385. // CHECK:STDOUT: }
  386. // CHECK:STDOUT:
  387. // CHECK:STDOUT: file {
  388. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  389. // CHECK:STDOUT: .Core = imports.%Core
  390. // CHECK:STDOUT: .MultipleAdapts = %MultipleAdapts.decl
  391. // CHECK:STDOUT: .MultipleAdaptsSameType = %MultipleAdaptsSameType.decl
  392. // CHECK:STDOUT: }
  393. // CHECK:STDOUT: %Core.import = import Core
  394. // CHECK:STDOUT: %MultipleAdapts.decl: type = class_decl @MultipleAdapts [template = constants.%MultipleAdapts] {} {}
  395. // CHECK:STDOUT: %MultipleAdaptsSameType.decl: type = class_decl @MultipleAdaptsSameType [template = constants.%MultipleAdaptsSameType] {} {}
  396. // CHECK:STDOUT: }
  397. // CHECK:STDOUT:
  398. // CHECK:STDOUT: class @MultipleAdapts {
  399. // CHECK:STDOUT: %.loc5_10: %.1 = tuple_literal ()
  400. // CHECK:STDOUT: %.loc5_11: type = converted %.loc5_10, constants.%.1 [template = constants.%.1]
  401. // CHECK:STDOUT: adapt_decl %.1
  402. // CHECK:STDOUT: %.loc13: %.2 = struct_literal ()
  403. // CHECK:STDOUT: %.loc14: <witness> = complete_type_witness %.1 [template = constants.%.3]
  404. // CHECK:STDOUT:
  405. // CHECK:STDOUT: !members:
  406. // CHECK:STDOUT: .Self = constants.%MultipleAdapts
  407. // CHECK:STDOUT: }
  408. // CHECK:STDOUT:
  409. // CHECK:STDOUT: class @MultipleAdaptsSameType {
  410. // CHECK:STDOUT: %.loc17_10: %.1 = tuple_literal ()
  411. // CHECK:STDOUT: %.loc17_11: type = converted %.loc17_10, constants.%.1 [template = constants.%.1]
  412. // CHECK:STDOUT: adapt_decl %.1
  413. // CHECK:STDOUT: %.loc25: %.1 = tuple_literal ()
  414. // CHECK:STDOUT: %.loc26: <witness> = complete_type_witness %.1 [template = constants.%.3]
  415. // CHECK:STDOUT:
  416. // CHECK:STDOUT: !members:
  417. // CHECK:STDOUT: .Self = constants.%MultipleAdaptsSameType
  418. // CHECK:STDOUT: }
  419. // CHECK:STDOUT:
  420. // CHECK:STDOUT: --- fail_bad_scope.carbon
  421. // CHECK:STDOUT:
  422. // CHECK:STDOUT: constants {
  423. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  424. // CHECK:STDOUT: %I.type.1: type = interface_type @I.1 [template]
  425. // CHECK:STDOUT: %Self.1: %I.type.1 = bind_symbolic_name Self, 0 [symbolic]
  426. // CHECK:STDOUT: %C: type = class_type @C [template]
  427. // CHECK:STDOUT: %I.type.2: type = interface_type @I.2 [template]
  428. // CHECK:STDOUT: %Self.2: %I.type.2 = bind_symbolic_name Self, 0 [symbolic]
  429. // CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
  430. // CHECK:STDOUT: }
  431. // CHECK:STDOUT:
  432. // CHECK:STDOUT: imports {
  433. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  434. // CHECK:STDOUT: import Core//prelude
  435. // CHECK:STDOUT: import Core//prelude/...
  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.%I.type.1] {} {}
  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: %I.type.1 = 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: %I.type.2 = 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.%I.type.2] {} {}
  471. // CHECK:STDOUT: %.loc25: <witness> = complete_type_witness %.1 [template = constants.%.2]
  472. // CHECK:STDOUT:
  473. // CHECK:STDOUT: !members:
  474. // CHECK:STDOUT: .Self = constants.%C
  475. // CHECK:STDOUT: .I = %I.decl
  476. // CHECK:STDOUT: }
  477. // CHECK:STDOUT: