fail_extend_impl_forall.carbon 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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/impl/fail_extend_impl_forall.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/fail_extend_impl_forall.carbon
  10. interface GenericInterface(T:! type) {
  11. fn F(x: T);
  12. }
  13. class C {
  14. // CHECK:STDERR: fail_extend_impl_forall.carbon:[[@LINE+3]]:3: error: cannot `extend` a parameterized `impl`
  15. // CHECK:STDERR: extend impl forall [T:! type] as GenericInterface(T) {
  16. // CHECK:STDERR: ^~~~~~
  17. extend impl forall [T:! type] as GenericInterface(T) {
  18. fn F(x: T) {}
  19. }
  20. }
  21. // CHECK:STDOUT: --- fail_extend_impl_forall.carbon
  22. // CHECK:STDOUT:
  23. // CHECK:STDOUT: constants {
  24. // CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic]
  25. // CHECK:STDOUT: %GenericInterface.type: type = generic_interface_type @GenericInterface [template]
  26. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  27. // CHECK:STDOUT: %GenericInterface: %GenericInterface.type = struct_value () [template]
  28. // CHECK:STDOUT: %.2: type = interface_type @GenericInterface, @GenericInterface(%T) [symbolic]
  29. // CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 1 [symbolic]
  30. // CHECK:STDOUT: %F.type.1: type = fn_type @F.1, @GenericInterface(%T) [symbolic]
  31. // CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [symbolic]
  32. // CHECK:STDOUT: %.3: type = assoc_entity_type %.2, %F.type.1 [symbolic]
  33. // CHECK:STDOUT: %.4: %.3 = assoc_entity element0, @GenericInterface.%F.decl [symbolic]
  34. // CHECK:STDOUT: %C: type = class_type @C [template]
  35. // CHECK:STDOUT: %F.type.2: type = fn_type @F.2 [template]
  36. // CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [template]
  37. // CHECK:STDOUT: %.5: <witness> = interface_witness (%F.2) [template]
  38. // CHECK:STDOUT: %.6: type = struct_type {} [template]
  39. // CHECK:STDOUT: %.7: <witness> = complete_type_witness %.6 [template]
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT:
  42. // CHECK:STDOUT: imports {
  43. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  44. // CHECK:STDOUT: import Core//prelude
  45. // CHECK:STDOUT: import Core//prelude/operators
  46. // CHECK:STDOUT: import Core//prelude/types
  47. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  48. // CHECK:STDOUT: import Core//prelude/operators/as
  49. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  50. // CHECK:STDOUT: import Core//prelude/operators/comparison
  51. // CHECK:STDOUT: import Core//prelude/types/bool
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT: }
  54. // CHECK:STDOUT:
  55. // CHECK:STDOUT: file {
  56. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  57. // CHECK:STDOUT: .Core = imports.%Core
  58. // CHECK:STDOUT: .GenericInterface = %GenericInterface.decl
  59. // CHECK:STDOUT: .C = %C.decl
  60. // CHECK:STDOUT: }
  61. // CHECK:STDOUT: %Core.import = import Core
  62. // CHECK:STDOUT: %GenericInterface.decl: %GenericInterface.type = interface_decl @GenericInterface [template = constants.%GenericInterface] {
  63. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T 0
  64. // CHECK:STDOUT: } {
  65. // CHECK:STDOUT: %T.param: type = param T, runtime_param<invalid>
  66. // CHECK:STDOUT: %T.loc11: type = bind_symbolic_name T 0, %T.param [symbolic = %T.1 (constants.%T)]
  67. // CHECK:STDOUT: }
  68. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  69. // CHECK:STDOUT: }
  70. // CHECK:STDOUT:
  71. // CHECK:STDOUT: generic interface @GenericInterface(%T.loc11: type) {
  72. // CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T)]
  73. // CHECK:STDOUT:
  74. // CHECK:STDOUT: !definition:
  75. // CHECK:STDOUT: %.1: type = interface_type @GenericInterface, @GenericInterface(%T.1) [symbolic = %.1 (constants.%.2)]
  76. // CHECK:STDOUT: %Self.2: %.2 = bind_symbolic_name Self 1 [symbolic = %Self.2 (constants.%Self)]
  77. // CHECK:STDOUT: %F.type: type = fn_type @F.1, @GenericInterface(%T.1) [symbolic = %F.type (constants.%F.type.1)]
  78. // CHECK:STDOUT: %F: @GenericInterface.%F.type (%F.type.1) = struct_value () [symbolic = %F (constants.%F.1)]
  79. // CHECK:STDOUT: %.2: type = assoc_entity_type @GenericInterface.%.1 (%.2), @GenericInterface.%F.type (%F.type.1) [symbolic = %.2 (constants.%.3)]
  80. // CHECK:STDOUT: %.3: @GenericInterface.%.2 (%.3) = assoc_entity element0, %F.decl [symbolic = %.3 (constants.%.4)]
  81. // CHECK:STDOUT:
  82. // CHECK:STDOUT: interface {
  83. // CHECK:STDOUT: %Self.1: @GenericInterface.%.1 (%.2) = bind_symbolic_name Self 1 [symbolic = %Self.2 (constants.%Self)]
  84. // CHECK:STDOUT: %F.decl: @GenericInterface.%F.type (%F.type.1) = fn_decl @F.1 [symbolic = @GenericInterface.%F (constants.%F.1)] {
  85. // CHECK:STDOUT: %x.patt: @F.1.%T (%T) = binding_pattern x
  86. // CHECK:STDOUT: } {
  87. // CHECK:STDOUT: %T.ref: type = name_ref T, @GenericInterface.%T.loc11 [symbolic = %T (constants.%T)]
  88. // CHECK:STDOUT: %x.param: @F.1.%T (%T) = param x, runtime_param0
  89. // CHECK:STDOUT: %x: @F.1.%T (%T) = bind_name x, %x.param
  90. // CHECK:STDOUT: }
  91. // CHECK:STDOUT: %.loc12: @GenericInterface.%.2 (%.3) = assoc_entity element0, %F.decl [symbolic = %.3 (constants.%.4)]
  92. // CHECK:STDOUT:
  93. // CHECK:STDOUT: !members:
  94. // CHECK:STDOUT: .Self = %Self.1
  95. // CHECK:STDOUT: .F = %.loc12
  96. // CHECK:STDOUT: witness = (%F.decl)
  97. // CHECK:STDOUT: }
  98. // CHECK:STDOUT: }
  99. // CHECK:STDOUT:
  100. // CHECK:STDOUT: impl @impl: %C as %.2 {
  101. // CHECK:STDOUT: %F.decl: %F.type.2 = fn_decl @F.2 [template = constants.%F.2] {
  102. // CHECK:STDOUT: %x.patt: @F.2.%T (%T) = binding_pattern x
  103. // CHECK:STDOUT: } {
  104. // CHECK:STDOUT: %T.ref: type = name_ref T, @impl.%T [symbolic = %T (constants.%T)]
  105. // CHECK:STDOUT: %x.param: @F.2.%T (%T) = param x, runtime_param0
  106. // CHECK:STDOUT: %x: @F.2.%T (%T) = bind_name x, %x.param
  107. // CHECK:STDOUT: }
  108. // CHECK:STDOUT: %.loc19_56: <witness> = interface_witness (%F.decl) [template = constants.%.5]
  109. // CHECK:STDOUT:
  110. // CHECK:STDOUT: !members:
  111. // CHECK:STDOUT: .F = %F.decl
  112. // CHECK:STDOUT: witness = %.loc19_56
  113. // CHECK:STDOUT: }
  114. // CHECK:STDOUT:
  115. // CHECK:STDOUT: class @C {
  116. // CHECK:STDOUT: impl_decl @impl {
  117. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T 0
  118. // CHECK:STDOUT: } {
  119. // CHECK:STDOUT: %T.param: type = param T, runtime_param<invalid>
  120. // CHECK:STDOUT: %T: type = bind_symbolic_name T 0, %T.param [symbolic = constants.%T]
  121. // CHECK:STDOUT: %GenericInterface.ref: %GenericInterface.type = name_ref GenericInterface, file.%GenericInterface.decl [template = constants.%GenericInterface]
  122. // CHECK:STDOUT: %T.ref: type = name_ref T, %T [symbolic = constants.%T]
  123. // CHECK:STDOUT: %.loc19_52: type = interface_type @GenericInterface, @GenericInterface(constants.%T) [symbolic = constants.%.2]
  124. // CHECK:STDOUT: }
  125. // CHECK:STDOUT: %.loc22: <witness> = complete_type_witness %.6 [template = constants.%.7]
  126. // CHECK:STDOUT:
  127. // CHECK:STDOUT: !members:
  128. // CHECK:STDOUT: .Self = constants.%C
  129. // CHECK:STDOUT: has_error
  130. // CHECK:STDOUT: }
  131. // CHECK:STDOUT:
  132. // CHECK:STDOUT: generic fn @F.1(@GenericInterface.%T.loc11: type, @GenericInterface.%Self.1: @GenericInterface.%.1 (%.2)) {
  133. // CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)]
  134. // CHECK:STDOUT:
  135. // CHECK:STDOUT: fn(%x: @F.1.%T (%T));
  136. // CHECK:STDOUT: }
  137. // CHECK:STDOUT:
  138. // CHECK:STDOUT: generic fn @F.2(@impl.%T: type) {
  139. // CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)]
  140. // CHECK:STDOUT:
  141. // CHECK:STDOUT: !definition:
  142. // CHECK:STDOUT:
  143. // CHECK:STDOUT: fn(%x: @F.2.%T (%T)) {
  144. // CHECK:STDOUT: !entry:
  145. // CHECK:STDOUT: return
  146. // CHECK:STDOUT: }
  147. // CHECK:STDOUT: }
  148. // CHECK:STDOUT:
  149. // CHECK:STDOUT: specific @GenericInterface(constants.%T) {
  150. // CHECK:STDOUT: %T.1 => constants.%T
  151. // CHECK:STDOUT:
  152. // CHECK:STDOUT: !definition:
  153. // CHECK:STDOUT: %.1 => constants.%.2
  154. // CHECK:STDOUT: %Self.2 => constants.%Self
  155. // CHECK:STDOUT: %F.type => constants.%F.type.1
  156. // CHECK:STDOUT: %F => constants.%F.1
  157. // CHECK:STDOUT: %.2 => constants.%.3
  158. // CHECK:STDOUT: %.3 => constants.%.4
  159. // CHECK:STDOUT: }
  160. // CHECK:STDOUT:
  161. // CHECK:STDOUT: specific @F.1(constants.%T, constants.%Self) {
  162. // CHECK:STDOUT: %T => constants.%T
  163. // CHECK:STDOUT: }
  164. // CHECK:STDOUT:
  165. // CHECK:STDOUT: specific @GenericInterface(@GenericInterface.%T.1) {
  166. // CHECK:STDOUT: %T.1 => constants.%T
  167. // CHECK:STDOUT: }
  168. // CHECK:STDOUT:
  169. // CHECK:STDOUT: specific @F.2(constants.%T) {
  170. // CHECK:STDOUT: %T => constants.%T
  171. // CHECK:STDOUT: }
  172. // CHECK:STDOUT:
  173. // CHECK:STDOUT: specific @F.1(constants.%T, constants.%C) {
  174. // CHECK:STDOUT: %T => constants.%T
  175. // CHECK:STDOUT: }
  176. // CHECK:STDOUT: