fail_extend_impl_forall.carbon 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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/none.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/impl/fail_extend_impl_forall.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/fail_extend_impl_forall.carbon
  14. interface GenericInterface(T:! type) {
  15. fn F(x: T);
  16. }
  17. class C {
  18. // CHECK:STDERR: fail_extend_impl_forall.carbon:[[@LINE+4]]:3: error: cannot `extend` a parameterized `impl` [ExtendImplForall]
  19. // CHECK:STDERR: extend impl forall [T:! type] as GenericInterface(T) {
  20. // CHECK:STDERR: ^~~~~~
  21. // CHECK:STDERR:
  22. extend impl forall [T:! type] as GenericInterface(T) {
  23. fn F(x: T) {}
  24. }
  25. }
  26. // CHECK:STDOUT: --- fail_extend_impl_forall.carbon
  27. // CHECK:STDOUT:
  28. // CHECK:STDOUT: constants {
  29. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  30. // CHECK:STDOUT: %pattern_type.98f: type = pattern_type type [concrete]
  31. // CHECK:STDOUT: %GenericInterface.type.c92: type = generic_interface_type @GenericInterface [concrete]
  32. // CHECK:STDOUT: %GenericInterface.generic: %GenericInterface.type.c92 = struct_value () [concrete]
  33. // CHECK:STDOUT: %GenericInterface.type.3fe: type = facet_type <@GenericInterface, @GenericInterface(%T)> [symbolic]
  34. // CHECK:STDOUT: %Self: %GenericInterface.type.3fe = bind_symbolic_name Self, 1 [symbolic]
  35. // CHECK:STDOUT: %pattern_type.7dc: type = pattern_type %T [symbolic]
  36. // CHECK:STDOUT: %F.type.a4b: type = fn_type @F.loc16, @GenericInterface(%T) [symbolic]
  37. // CHECK:STDOUT: %F.3d9: %F.type.a4b = struct_value () [symbolic]
  38. // CHECK:STDOUT: %GenericInterface.assoc_type: type = assoc_entity_type @GenericInterface, @GenericInterface(%T) [symbolic]
  39. // CHECK:STDOUT: %assoc0: %GenericInterface.assoc_type = assoc_entity element0, @GenericInterface.%F.decl [symbolic]
  40. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  41. // CHECK:STDOUT: %require_complete.70f: <witness> = require_complete_type %GenericInterface.type.3fe [symbolic]
  42. // CHECK:STDOUT: %GenericInterface.impl_witness: <witness> = impl_witness @C.%GenericInterface.impl_witness_table, @GenericInterface.impl(%T) [symbolic]
  43. // CHECK:STDOUT: %F.type.2cb: type = fn_type @F.loc25, @GenericInterface.impl(%T) [symbolic]
  44. // CHECK:STDOUT: %F.4b1: %F.type.2cb = struct_value () [symbolic]
  45. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  46. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  47. // CHECK:STDOUT: %require_complete.4ae: <witness> = require_complete_type %T [symbolic]
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT:
  50. // CHECK:STDOUT: file {
  51. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  52. // CHECK:STDOUT: .GenericInterface = %GenericInterface.decl
  53. // CHECK:STDOUT: .C = %C.decl
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT: %GenericInterface.decl: %GenericInterface.type.c92 = interface_decl @GenericInterface [concrete = constants.%GenericInterface.generic] {
  56. // CHECK:STDOUT: %T.patt: %pattern_type.98f = symbolic_binding_pattern T, 0 [concrete]
  57. // CHECK:STDOUT: } {
  58. // CHECK:STDOUT: %T.loc15_28.1: type = bind_symbolic_name T, 0 [symbolic = %T.loc15_28.2 (constants.%T)]
  59. // CHECK:STDOUT: }
  60. // CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {}
  61. // CHECK:STDOUT: }
  62. // CHECK:STDOUT:
  63. // CHECK:STDOUT: generic interface @GenericInterface(%T.loc15_28.1: type) {
  64. // CHECK:STDOUT: %T.loc15_28.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc15_28.2 (constants.%T)]
  65. // CHECK:STDOUT:
  66. // CHECK:STDOUT: !definition:
  67. // CHECK:STDOUT: %GenericInterface.type: type = facet_type <@GenericInterface, @GenericInterface(%T.loc15_28.2)> [symbolic = %GenericInterface.type (constants.%GenericInterface.type.3fe)]
  68. // CHECK:STDOUT: %Self.2: @GenericInterface.%GenericInterface.type (%GenericInterface.type.3fe) = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self)]
  69. // CHECK:STDOUT: %F.type: type = fn_type @F.loc16, @GenericInterface(%T.loc15_28.2) [symbolic = %F.type (constants.%F.type.a4b)]
  70. // CHECK:STDOUT: %F: @GenericInterface.%F.type (%F.type.a4b) = struct_value () [symbolic = %F (constants.%F.3d9)]
  71. // CHECK:STDOUT: %GenericInterface.assoc_type: type = assoc_entity_type @GenericInterface, @GenericInterface(%T.loc15_28.2) [symbolic = %GenericInterface.assoc_type (constants.%GenericInterface.assoc_type)]
  72. // CHECK:STDOUT: %assoc0.loc16_13.2: @GenericInterface.%GenericInterface.assoc_type (%GenericInterface.assoc_type) = assoc_entity element0, %F.decl [symbolic = %assoc0.loc16_13.2 (constants.%assoc0)]
  73. // CHECK:STDOUT:
  74. // CHECK:STDOUT: interface {
  75. // CHECK:STDOUT: %Self.1: @GenericInterface.%GenericInterface.type (%GenericInterface.type.3fe) = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self)]
  76. // CHECK:STDOUT: %F.decl: @GenericInterface.%F.type (%F.type.a4b) = fn_decl @F.loc16 [symbolic = @GenericInterface.%F (constants.%F.3d9)] {
  77. // CHECK:STDOUT: %x.patt: @F.loc16.%pattern_type (%pattern_type.7dc) = binding_pattern x [concrete]
  78. // CHECK:STDOUT: %x.param_patt: @F.loc16.%pattern_type (%pattern_type.7dc) = value_param_pattern %x.patt, call_param0 [concrete]
  79. // CHECK:STDOUT: } {
  80. // CHECK:STDOUT: %x.param: @F.loc16.%T (%T) = value_param call_param0
  81. // CHECK:STDOUT: %T.ref: type = name_ref T, @GenericInterface.%T.loc15_28.1 [symbolic = %T (constants.%T)]
  82. // CHECK:STDOUT: %x: @F.loc16.%T (%T) = bind_name x, %x.param
  83. // CHECK:STDOUT: }
  84. // CHECK:STDOUT: %assoc0.loc16_13.1: @GenericInterface.%GenericInterface.assoc_type (%GenericInterface.assoc_type) = assoc_entity element0, %F.decl [symbolic = %assoc0.loc16_13.2 (constants.%assoc0)]
  85. // CHECK:STDOUT:
  86. // CHECK:STDOUT: !members:
  87. // CHECK:STDOUT: .Self = %Self.1
  88. // CHECK:STDOUT: .T = <poisoned>
  89. // CHECK:STDOUT: .F = %assoc0.loc16_13.1
  90. // CHECK:STDOUT: witness = (%F.decl)
  91. // CHECK:STDOUT: }
  92. // CHECK:STDOUT: }
  93. // CHECK:STDOUT:
  94. // CHECK:STDOUT: generic impl @GenericInterface.impl(%T.loc24_23.1: type) {
  95. // CHECK:STDOUT: %T.loc24_23.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc24_23.2 (constants.%T)]
  96. // CHECK:STDOUT: %GenericInterface.type.loc24_54.2: type = facet_type <@GenericInterface, @GenericInterface(%T.loc24_23.2)> [symbolic = %GenericInterface.type.loc24_54.2 (constants.%GenericInterface.type.3fe)]
  97. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type %GenericInterface.type.loc24_54.2 [symbolic = %require_complete (constants.%require_complete.70f)]
  98. // CHECK:STDOUT: %GenericInterface.impl_witness: <witness> = impl_witness @C.%GenericInterface.impl_witness_table, @GenericInterface.impl(%T.loc24_23.2) [symbolic = %GenericInterface.impl_witness (constants.%GenericInterface.impl_witness)]
  99. // CHECK:STDOUT:
  100. // CHECK:STDOUT: !definition:
  101. // CHECK:STDOUT: %F.type: type = fn_type @F.loc25, @GenericInterface.impl(%T.loc24_23.2) [symbolic = %F.type (constants.%F.type.2cb)]
  102. // CHECK:STDOUT: %F: @GenericInterface.impl.%F.type (%F.type.2cb) = struct_value () [symbolic = %F (constants.%F.4b1)]
  103. // CHECK:STDOUT:
  104. // CHECK:STDOUT: impl: %Self.ref as %GenericInterface.type.loc24_54.1 {
  105. // CHECK:STDOUT: %F.decl: @GenericInterface.impl.%F.type (%F.type.2cb) = fn_decl @F.loc25 [symbolic = @GenericInterface.impl.%F (constants.%F.4b1)] {
  106. // CHECK:STDOUT: %x.patt: @F.loc25.%pattern_type (%pattern_type.7dc) = binding_pattern x [concrete]
  107. // CHECK:STDOUT: %x.param_patt: @F.loc25.%pattern_type (%pattern_type.7dc) = value_param_pattern %x.patt, call_param0 [concrete]
  108. // CHECK:STDOUT: } {
  109. // CHECK:STDOUT: %x.param: @F.loc25.%T (%T) = value_param call_param0
  110. // CHECK:STDOUT: %T.ref: type = name_ref T, @GenericInterface.impl.%T.loc24_23.1 [symbolic = %T (constants.%T)]
  111. // CHECK:STDOUT: %x: @F.loc25.%T (%T) = bind_name x, %x.param
  112. // CHECK:STDOUT: }
  113. // CHECK:STDOUT:
  114. // CHECK:STDOUT: !members:
  115. // CHECK:STDOUT: .T = <poisoned>
  116. // CHECK:STDOUT: .F = %F.decl
  117. // CHECK:STDOUT: witness = <error>
  118. // CHECK:STDOUT: }
  119. // CHECK:STDOUT: }
  120. // CHECK:STDOUT:
  121. // CHECK:STDOUT: class @C {
  122. // CHECK:STDOUT: impl_decl @GenericInterface.impl [concrete] {
  123. // CHECK:STDOUT: %T.patt: %pattern_type.98f = symbolic_binding_pattern T, 0 [concrete]
  124. // CHECK:STDOUT: } {
  125. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%C [concrete = constants.%C]
  126. // CHECK:STDOUT: %GenericInterface.ref: %GenericInterface.type.c92 = name_ref GenericInterface, file.%GenericInterface.decl [concrete = constants.%GenericInterface.generic]
  127. // CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc24_23.1 [symbolic = %T.loc24_23.2 (constants.%T)]
  128. // CHECK:STDOUT: %GenericInterface.type.loc24_54.1: type = facet_type <@GenericInterface, @GenericInterface(constants.%T)> [symbolic = %GenericInterface.type.loc24_54.2 (constants.%GenericInterface.type.3fe)]
  129. // CHECK:STDOUT: %T.loc24_23.1: type = bind_symbolic_name T, 0 [symbolic = %T.loc24_23.2 (constants.%T)]
  130. // CHECK:STDOUT: }
  131. // CHECK:STDOUT: %GenericInterface.impl_witness_table = impl_witness_table (<error>), @GenericInterface.impl [concrete]
  132. // CHECK:STDOUT: %GenericInterface.impl_witness: <witness> = impl_witness %GenericInterface.impl_witness_table, @GenericInterface.impl(constants.%T) [symbolic = @GenericInterface.impl.%GenericInterface.impl_witness (constants.%GenericInterface.impl_witness)]
  133. // CHECK:STDOUT: %.loc24: type = specific_constant @GenericInterface.impl.%GenericInterface.type.loc24_54.1, @GenericInterface.impl(constants.%T) [symbolic = constants.%GenericInterface.type.3fe]
  134. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete = constants.%empty_struct_type]
  135. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type]
  136. // CHECK:STDOUT: complete_type_witness = %complete_type
  137. // CHECK:STDOUT:
  138. // CHECK:STDOUT: !members:
  139. // CHECK:STDOUT: .Self = constants.%C
  140. // CHECK:STDOUT: .GenericInterface = <poisoned>
  141. // CHECK:STDOUT: has_error
  142. // CHECK:STDOUT: }
  143. // CHECK:STDOUT:
  144. // CHECK:STDOUT: generic fn @F.loc16(@GenericInterface.%T.loc15_28.1: type, @GenericInterface.%Self.1: @GenericInterface.%GenericInterface.type (%GenericInterface.type.3fe)) {
  145. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T)]
  146. // CHECK:STDOUT: %pattern_type: type = pattern_type %T [symbolic = %pattern_type (constants.%pattern_type.7dc)]
  147. // CHECK:STDOUT:
  148. // CHECK:STDOUT: fn(%x.param: @F.loc16.%T (%T));
  149. // CHECK:STDOUT: }
  150. // CHECK:STDOUT:
  151. // CHECK:STDOUT: generic fn @F.loc25(@GenericInterface.impl.%T.loc24_23.1: type) {
  152. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T)]
  153. // CHECK:STDOUT: %pattern_type: type = pattern_type %T [symbolic = %pattern_type (constants.%pattern_type.7dc)]
  154. // CHECK:STDOUT:
  155. // CHECK:STDOUT: !definition:
  156. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type %T [symbolic = %require_complete (constants.%require_complete.4ae)]
  157. // CHECK:STDOUT:
  158. // CHECK:STDOUT: fn(%x.param: @F.loc25.%T (%T)) {
  159. // CHECK:STDOUT: !entry:
  160. // CHECK:STDOUT: return
  161. // CHECK:STDOUT: }
  162. // CHECK:STDOUT: }
  163. // CHECK:STDOUT:
  164. // CHECK:STDOUT: specific @GenericInterface(constants.%T) {
  165. // CHECK:STDOUT: %T.loc15_28.2 => constants.%T
  166. // CHECK:STDOUT:
  167. // CHECK:STDOUT: !definition:
  168. // CHECK:STDOUT: %GenericInterface.type => constants.%GenericInterface.type.3fe
  169. // CHECK:STDOUT: %Self.2 => constants.%Self
  170. // CHECK:STDOUT: %F.type => constants.%F.type.a4b
  171. // CHECK:STDOUT: %F => constants.%F.3d9
  172. // CHECK:STDOUT: %GenericInterface.assoc_type => constants.%GenericInterface.assoc_type
  173. // CHECK:STDOUT: %assoc0.loc16_13.2 => constants.%assoc0
  174. // CHECK:STDOUT: }
  175. // CHECK:STDOUT:
  176. // CHECK:STDOUT: specific @F.loc16(constants.%T, constants.%Self) {
  177. // CHECK:STDOUT: %T => constants.%T
  178. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.7dc
  179. // CHECK:STDOUT: }
  180. // CHECK:STDOUT:
  181. // CHECK:STDOUT: specific @GenericInterface.impl(constants.%T) {
  182. // CHECK:STDOUT: %T.loc24_23.2 => constants.%T
  183. // CHECK:STDOUT: %GenericInterface.type.loc24_54.2 => constants.%GenericInterface.type.3fe
  184. // CHECK:STDOUT: %require_complete => constants.%require_complete.70f
  185. // CHECK:STDOUT: %GenericInterface.impl_witness => constants.%GenericInterface.impl_witness
  186. // CHECK:STDOUT:
  187. // CHECK:STDOUT: !definition:
  188. // CHECK:STDOUT: %F.type => constants.%F.type.2cb
  189. // CHECK:STDOUT: %F => constants.%F.4b1
  190. // CHECK:STDOUT: }
  191. // CHECK:STDOUT:
  192. // CHECK:STDOUT: specific @F.loc25(constants.%T) {
  193. // CHECK:STDOUT: %T => constants.%T
  194. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.7dc
  195. // CHECK:STDOUT: }
  196. // CHECK:STDOUT: