fail_extend_impl_forall.carbon 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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(unused x: T) {}
  24. }
  25. }
  26. // CHECK:STDOUT: --- fail_extend_impl_forall.carbon
  27. // CHECK:STDOUT:
  28. // CHECK:STDOUT: constants {
  29. // CHECK:STDOUT: %type: type = facet_type <type> [concrete]
  30. // CHECK:STDOUT: %.Self: %type = symbolic_binding .Self [symbolic_self]
  31. // CHECK:STDOUT: %pattern_type.98f: type = pattern_type type [concrete]
  32. // CHECK:STDOUT: %T: type = symbolic_binding T, 0 [symbolic]
  33. // CHECK:STDOUT: %GenericInterface.type.21d: type = generic_interface_type @GenericInterface [concrete]
  34. // CHECK:STDOUT: %GenericInterface.generic: %GenericInterface.type.21d = struct_value () [concrete]
  35. // CHECK:STDOUT: %GenericInterface.type.8bc: type = facet_type <@GenericInterface, @GenericInterface(%T)> [symbolic]
  36. // CHECK:STDOUT: %Self: %GenericInterface.type.8bc = symbolic_binding Self, 1 [symbolic]
  37. // CHECK:STDOUT: %pattern_type.51d: type = pattern_type %T [symbolic]
  38. // CHECK:STDOUT: %GenericInterface.WithSelf.F.type: type = fn_type @GenericInterface.WithSelf.F, @GenericInterface.WithSelf(%T, %Self) [symbolic]
  39. // CHECK:STDOUT: %GenericInterface.WithSelf.F: %GenericInterface.WithSelf.F.type = struct_value () [symbolic]
  40. // CHECK:STDOUT: %GenericInterface.assoc_type: type = assoc_entity_type @GenericInterface, @GenericInterface(%T) [symbolic]
  41. // CHECK:STDOUT: %assoc0: %GenericInterface.assoc_type = assoc_entity element0, @GenericInterface.WithSelf.%GenericInterface.WithSelf.F.decl [symbolic]
  42. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  43. // CHECK:STDOUT: %GenericInterface.impl_witness: <witness> = impl_witness @C.as.GenericInterface.impl.%GenericInterface.impl_witness_table, @C.as.GenericInterface.impl(%T) [symbolic]
  44. // CHECK:STDOUT: %C.as.GenericInterface.impl.F.type: type = fn_type @C.as.GenericInterface.impl.F, @C.as.GenericInterface.impl(%T) [symbolic]
  45. // CHECK:STDOUT: %C.as.GenericInterface.impl.F: %C.as.GenericInterface.impl.F.type = struct_value () [symbolic]
  46. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  47. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  48. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type %T [symbolic]
  49. // CHECK:STDOUT: }
  50. // CHECK:STDOUT:
  51. // CHECK:STDOUT: file {
  52. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  53. // CHECK:STDOUT: .GenericInterface = %GenericInterface.decl
  54. // CHECK:STDOUT: .C = %C.decl
  55. // CHECK:STDOUT: }
  56. // CHECK:STDOUT: %GenericInterface.decl: %GenericInterface.type.21d = interface_decl @GenericInterface [concrete = constants.%GenericInterface.generic] {
  57. // CHECK:STDOUT: %T.patt: %pattern_type.98f = symbolic_binding_pattern T, 0 [concrete]
  58. // CHECK:STDOUT: } {
  59. // CHECK:STDOUT: %.loc15_32.1: type = splice_block %.loc15_32.2 [concrete = type] {
  60. // CHECK:STDOUT: %.Self: %type = symbolic_binding .Self [symbolic_self = constants.%.Self]
  61. // CHECK:STDOUT: %.loc15_32.2: type = type_literal type [concrete = type]
  62. // CHECK:STDOUT: }
  63. // CHECK:STDOUT: %T.loc15_29.2: type = symbolic_binding T, 0 [symbolic = %T.loc15_29.1 (constants.%T)]
  64. // CHECK:STDOUT: }
  65. // CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {}
  66. // CHECK:STDOUT: }
  67. // CHECK:STDOUT:
  68. // CHECK:STDOUT: generic interface @GenericInterface(%T.loc15_29.2: type) {
  69. // CHECK:STDOUT: %T.loc15_29.1: type = symbolic_binding T, 0 [symbolic = %T.loc15_29.1 (constants.%T)]
  70. // CHECK:STDOUT:
  71. // CHECK:STDOUT: !definition:
  72. // CHECK:STDOUT: %GenericInterface.type: type = facet_type <@GenericInterface, @GenericInterface(%T.loc15_29.1)> [symbolic = %GenericInterface.type (constants.%GenericInterface.type.8bc)]
  73. // CHECK:STDOUT: %Self.loc15_38.2: @GenericInterface.%GenericInterface.type (%GenericInterface.type.8bc) = symbolic_binding Self, 1 [symbolic = %Self.loc15_38.2 (constants.%Self)]
  74. // CHECK:STDOUT:
  75. // CHECK:STDOUT: interface {
  76. // CHECK:STDOUT: %Self.loc15_38.1: @GenericInterface.%GenericInterface.type (%GenericInterface.type.8bc) = symbolic_binding Self, 1 [symbolic = %Self.loc15_38.2 (constants.%Self)]
  77. // CHECK:STDOUT: %GenericInterface.WithSelf.decl = interface_with_self_decl @GenericInterface [concrete]
  78. // CHECK:STDOUT:
  79. // CHECK:STDOUT: !with Self:
  80. // CHECK:STDOUT: %GenericInterface.WithSelf.F.decl: @GenericInterface.WithSelf.%GenericInterface.WithSelf.F.type (%GenericInterface.WithSelf.F.type) = fn_decl @GenericInterface.WithSelf.F [symbolic = @GenericInterface.WithSelf.%GenericInterface.WithSelf.F (constants.%GenericInterface.WithSelf.F)] {
  81. // CHECK:STDOUT: %x.param_patt: @GenericInterface.WithSelf.F.%pattern_type (%pattern_type.51d) = value_param_pattern [concrete]
  82. // CHECK:STDOUT: %x.patt: @GenericInterface.WithSelf.F.%pattern_type (%pattern_type.51d) = at_binding_pattern x, %x.param_patt [concrete]
  83. // CHECK:STDOUT: } {
  84. // CHECK:STDOUT: %x.param: @GenericInterface.WithSelf.F.%T (%T) = value_param call_param0
  85. // CHECK:STDOUT: %T.ref: type = name_ref T, @GenericInterface.%T.loc15_29.2 [symbolic = %T (constants.%T)]
  86. // CHECK:STDOUT: %x: @GenericInterface.WithSelf.F.%T (%T) = value_binding x, %x.param
  87. // CHECK:STDOUT: }
  88. // CHECK:STDOUT: %assoc0.loc16_13.1: @GenericInterface.WithSelf.%GenericInterface.assoc_type (%GenericInterface.assoc_type) = assoc_entity element0, %GenericInterface.WithSelf.F.decl [symbolic = %assoc0.loc16_13.2 (constants.%assoc0)]
  89. // CHECK:STDOUT:
  90. // CHECK:STDOUT: !members:
  91. // CHECK:STDOUT: .Self = %Self.loc15_38.1
  92. // CHECK:STDOUT: .T = <poisoned>
  93. // CHECK:STDOUT: .T = <poisoned>
  94. // CHECK:STDOUT: .F = @GenericInterface.WithSelf.%assoc0.loc16_13.1
  95. // CHECK:STDOUT: witness = (@GenericInterface.WithSelf.%GenericInterface.WithSelf.F.decl)
  96. // CHECK:STDOUT:
  97. // CHECK:STDOUT: !requires:
  98. // CHECK:STDOUT: }
  99. // CHECK:STDOUT: }
  100. // CHECK:STDOUT:
  101. // CHECK:STDOUT: generic impl @C.as.GenericInterface.impl(%T.loc24_24.2: type) {
  102. // CHECK:STDOUT: %T.loc24_24.1: type = symbolic_binding T, 0 [symbolic = %T.loc24_24.1 (constants.%T)]
  103. // CHECK:STDOUT: %GenericInterface.type.loc24_54.1: type = facet_type <@GenericInterface, @GenericInterface(%T.loc24_24.1)> [symbolic = %GenericInterface.type.loc24_54.1 (constants.%GenericInterface.type.8bc)]
  104. // CHECK:STDOUT: %GenericInterface.impl_witness.loc24_56.2: <witness> = impl_witness %GenericInterface.impl_witness_table, @C.as.GenericInterface.impl(%T.loc24_24.1) [symbolic = %GenericInterface.impl_witness.loc24_56.2 (constants.%GenericInterface.impl_witness)]
  105. // CHECK:STDOUT:
  106. // CHECK:STDOUT: !definition:
  107. // CHECK:STDOUT: %C.as.GenericInterface.impl.F.type: type = fn_type @C.as.GenericInterface.impl.F, @C.as.GenericInterface.impl(%T.loc24_24.1) [symbolic = %C.as.GenericInterface.impl.F.type (constants.%C.as.GenericInterface.impl.F.type)]
  108. // CHECK:STDOUT: %C.as.GenericInterface.impl.F: @C.as.GenericInterface.impl.%C.as.GenericInterface.impl.F.type (%C.as.GenericInterface.impl.F.type) = struct_value () [symbolic = %C.as.GenericInterface.impl.F (constants.%C.as.GenericInterface.impl.F)]
  109. // CHECK:STDOUT:
  110. // CHECK:STDOUT: impl: %Self.ref as %GenericInterface.type.loc24_54.2 {
  111. // CHECK:STDOUT: %C.as.GenericInterface.impl.F.decl: @C.as.GenericInterface.impl.%C.as.GenericInterface.impl.F.type (%C.as.GenericInterface.impl.F.type) = fn_decl @C.as.GenericInterface.impl.F [symbolic = @C.as.GenericInterface.impl.%C.as.GenericInterface.impl.F (constants.%C.as.GenericInterface.impl.F)] {
  112. // CHECK:STDOUT: %x.param_patt: @C.as.GenericInterface.impl.F.%pattern_type (%pattern_type.51d) = value_param_pattern [concrete]
  113. // CHECK:STDOUT: %x.patt: @C.as.GenericInterface.impl.F.%pattern_type (%pattern_type.51d) = at_binding_pattern x, %x.param_patt [concrete]
  114. // CHECK:STDOUT: } {
  115. // CHECK:STDOUT: %x.param: @C.as.GenericInterface.impl.F.%T (%T) = value_param call_param0
  116. // CHECK:STDOUT: %T.ref: type = name_ref T, @C.as.GenericInterface.impl.%T.loc24_24.2 [symbolic = %T (constants.%T)]
  117. // CHECK:STDOUT: %x: @C.as.GenericInterface.impl.F.%T (%T) = value_binding x, %x.param
  118. // CHECK:STDOUT: }
  119. // CHECK:STDOUT: %GenericInterface.impl_witness_table = impl_witness_table (), @C.as.GenericInterface.impl [concrete]
  120. // CHECK:STDOUT: %GenericInterface.impl_witness.loc24_56.1: <witness> = impl_witness %GenericInterface.impl_witness_table, @C.as.GenericInterface.impl(constants.%T) [symbolic = %GenericInterface.impl_witness.loc24_56.2 (constants.%GenericInterface.impl_witness)]
  121. // CHECK:STDOUT:
  122. // CHECK:STDOUT: !members:
  123. // CHECK:STDOUT: .T = <poisoned>
  124. // CHECK:STDOUT: .F = %C.as.GenericInterface.impl.F.decl
  125. // CHECK:STDOUT: witness = <error>
  126. // CHECK:STDOUT: }
  127. // CHECK:STDOUT: }
  128. // CHECK:STDOUT:
  129. // CHECK:STDOUT: class @C {
  130. // CHECK:STDOUT: impl_decl @C.as.GenericInterface.impl [concrete] {
  131. // CHECK:STDOUT: %T.patt: %pattern_type.98f = symbolic_binding_pattern T, 0 [concrete]
  132. // CHECK:STDOUT: } {
  133. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%C [concrete = constants.%C]
  134. // CHECK:STDOUT: %GenericInterface.ref: %GenericInterface.type.21d = name_ref GenericInterface, file.%GenericInterface.decl [concrete = constants.%GenericInterface.generic]
  135. // CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc24_24.2 [symbolic = %T.loc24_24.1 (constants.%T)]
  136. // CHECK:STDOUT: %GenericInterface.type.loc24_54.2: type = facet_type <@GenericInterface, @GenericInterface(constants.%T)> [symbolic = %GenericInterface.type.loc24_54.1 (constants.%GenericInterface.type.8bc)]
  137. // CHECK:STDOUT: %.loc24_27.1: type = splice_block %.loc24_27.2 [concrete = type] {
  138. // CHECK:STDOUT: %.Self: %type = symbolic_binding .Self [symbolic_self = constants.%.Self]
  139. // CHECK:STDOUT: %.loc24_27.2: type = type_literal type [concrete = type]
  140. // CHECK:STDOUT: }
  141. // CHECK:STDOUT: %T.loc24_24.2: type = symbolic_binding T, 0 [symbolic = %T.loc24_24.1 (constants.%T)]
  142. // CHECK:STDOUT: }
  143. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type]
  144. // CHECK:STDOUT: complete_type_witness = %complete_type
  145. // CHECK:STDOUT:
  146. // CHECK:STDOUT: !members:
  147. // CHECK:STDOUT: .Self = constants.%C
  148. // CHECK:STDOUT: .GenericInterface = <poisoned>
  149. // CHECK:STDOUT: has_error
  150. // CHECK:STDOUT: }
  151. // CHECK:STDOUT:
  152. // CHECK:STDOUT: generic fn @GenericInterface.WithSelf.F(@GenericInterface.%T.loc15_29.2: type, @GenericInterface.%Self.loc15_38.1: @GenericInterface.%GenericInterface.type (%GenericInterface.type.8bc)) {
  153. // CHECK:STDOUT: %T: type = symbolic_binding T, 0 [symbolic = %T (constants.%T)]
  154. // CHECK:STDOUT: %pattern_type: type = pattern_type %T [symbolic = %pattern_type (constants.%pattern_type.51d)]
  155. // CHECK:STDOUT:
  156. // CHECK:STDOUT: fn(%x.param: @GenericInterface.WithSelf.F.%T (%T));
  157. // CHECK:STDOUT: }
  158. // CHECK:STDOUT:
  159. // CHECK:STDOUT: generic fn @C.as.GenericInterface.impl.F(@C.as.GenericInterface.impl.%T.loc24_24.2: type) {
  160. // CHECK:STDOUT: %T: type = symbolic_binding T, 0 [symbolic = %T (constants.%T)]
  161. // CHECK:STDOUT: %pattern_type: type = pattern_type %T [symbolic = %pattern_type (constants.%pattern_type.51d)]
  162. // CHECK:STDOUT:
  163. // CHECK:STDOUT: !definition:
  164. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type %T [symbolic = %require_complete (constants.%require_complete)]
  165. // CHECK:STDOUT:
  166. // CHECK:STDOUT: fn(%x.param: @C.as.GenericInterface.impl.F.%T (%T)) {
  167. // CHECK:STDOUT: !entry:
  168. // CHECK:STDOUT: return
  169. // CHECK:STDOUT: }
  170. // CHECK:STDOUT: }
  171. // CHECK:STDOUT:
  172. // CHECK:STDOUT: specific @GenericInterface(constants.%T) {
  173. // CHECK:STDOUT: %T.loc15_29.1 => constants.%T
  174. // CHECK:STDOUT: }
  175. // CHECK:STDOUT:
  176. // CHECK:STDOUT: specific @GenericInterface.WithSelf(constants.%T, constants.%Self) {}
  177. // CHECK:STDOUT:
  178. // CHECK:STDOUT: specific @GenericInterface.WithSelf.F(constants.%T, constants.%Self) {
  179. // CHECK:STDOUT: %T => constants.%T
  180. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.51d
  181. // CHECK:STDOUT: }
  182. // CHECK:STDOUT:
  183. // CHECK:STDOUT: specific @C.as.GenericInterface.impl(constants.%T) {
  184. // CHECK:STDOUT: %T.loc24_24.1 => constants.%T
  185. // CHECK:STDOUT: %GenericInterface.type.loc24_54.1 => constants.%GenericInterface.type.8bc
  186. // CHECK:STDOUT: %GenericInterface.impl_witness.loc24_56.2 => constants.%GenericInterface.impl_witness
  187. // CHECK:STDOUT:
  188. // CHECK:STDOUT: !definition:
  189. // CHECK:STDOUT: %C.as.GenericInterface.impl.F.type => constants.%C.as.GenericInterface.impl.F.type
  190. // CHECK:STDOUT: %C.as.GenericInterface.impl.F => constants.%C.as.GenericInterface.impl.F
  191. // CHECK:STDOUT: }
  192. // CHECK:STDOUT:
  193. // CHECK:STDOUT: specific @C.as.GenericInterface.impl.F(constants.%T) {
  194. // CHECK:STDOUT: %T => constants.%T
  195. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.51d
  196. // CHECK:STDOUT: }
  197. // CHECK:STDOUT: