fail_extend_impl_forall.carbon 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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, (%T) [symbolic]
  29. // CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 1 [symbolic]
  30. // CHECK:STDOUT: %F.type.1: type = fn_type @F.1 [template]
  31. // CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [template]
  32. // CHECK:STDOUT: %.3: type = assoc_entity_type @GenericInterface, %F.type.1 [template]
  33. // CHECK:STDOUT: %.4: %.3 = assoc_entity element0, @GenericInterface.%F.decl [template]
  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: }
  40. // CHECK:STDOUT:
  41. // CHECK:STDOUT: file {
  42. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  43. // CHECK:STDOUT: .Core = %Core
  44. // CHECK:STDOUT: .GenericInterface = %GenericInterface.decl
  45. // CHECK:STDOUT: .C = %C.decl
  46. // CHECK:STDOUT: }
  47. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  48. // CHECK:STDOUT: %GenericInterface.decl: %GenericInterface.type = interface_decl @GenericInterface [template = constants.%GenericInterface] {
  49. // CHECK:STDOUT: %T.loc11_28.1: type = param T
  50. // CHECK:STDOUT: %T.loc11_28.2: type = bind_symbolic_name T 0, %T.loc11_28.1 [symbolic = constants.%T]
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {}
  53. // CHECK:STDOUT: }
  54. // CHECK:STDOUT:
  55. // CHECK:STDOUT: interface @GenericInterface
  56. // CHECK:STDOUT: generic [file.%T.loc11_28.2: type] {
  57. // CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 1 [symbolic = constants.%Self]
  58. // CHECK:STDOUT: %F.decl: %F.type.1 = fn_decl @F.1 [template = constants.%F.1] {
  59. // CHECK:STDOUT: %T.ref: type = name_ref T, file.%T.loc11_28.2 [symbolic = constants.%T]
  60. // CHECK:STDOUT: %x.loc12_8.1: %T = param x
  61. // CHECK:STDOUT: %x.loc12_8.2: %T = bind_name x, %x.loc12_8.1
  62. // CHECK:STDOUT: }
  63. // CHECK:STDOUT: %.loc12: %.3 = assoc_entity element0, %F.decl [template = constants.%.4]
  64. // CHECK:STDOUT:
  65. // CHECK:STDOUT: !members:
  66. // CHECK:STDOUT: .Self = %Self
  67. // CHECK:STDOUT: .F = %.loc12
  68. // CHECK:STDOUT: witness = (%F.decl)
  69. // CHECK:STDOUT: }
  70. // CHECK:STDOUT:
  71. // CHECK:STDOUT: impl @impl: %C as %.2 {
  72. // CHECK:STDOUT: %F.decl: %F.type.2 = fn_decl @F.2 [template = constants.%F.2] {
  73. // CHECK:STDOUT: %T.ref: type = name_ref T, @C.%T.loc19_23.2 [symbolic = constants.%T]
  74. // CHECK:STDOUT: %x.loc20_10.1: %T = param x
  75. // CHECK:STDOUT: %x.loc20_10.2: %T = bind_name x, %x.loc20_10.1
  76. // CHECK:STDOUT: }
  77. // CHECK:STDOUT: %.1: <witness> = interface_witness (%F.decl) [template = constants.%.5]
  78. // CHECK:STDOUT:
  79. // CHECK:STDOUT: !members:
  80. // CHECK:STDOUT: .F = %F.decl
  81. // CHECK:STDOUT: witness = %.1
  82. // CHECK:STDOUT: }
  83. // CHECK:STDOUT:
  84. // CHECK:STDOUT: class @C {
  85. // CHECK:STDOUT: %.loc19_54.1: type = value_of_initializer %.loc19_52 [symbolic = constants.%.2]
  86. // CHECK:STDOUT: %.loc19_54.2: type = converted %.loc19_52, %.loc19_54.1 [symbolic = constants.%.2]
  87. // CHECK:STDOUT: impl_decl @impl {
  88. // CHECK:STDOUT: %T.loc19_23.1: type = param T
  89. // CHECK:STDOUT: %T.loc19_23.2: type = bind_symbolic_name T 0, %T.loc19_23.1 [symbolic = constants.%T]
  90. // CHECK:STDOUT: %GenericInterface.ref: %GenericInterface.type = name_ref GenericInterface, file.%GenericInterface.decl [template = constants.%GenericInterface]
  91. // CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc19_23.2 [symbolic = constants.%T]
  92. // CHECK:STDOUT: %.loc19_52: init type = call %GenericInterface.ref(%T.ref) [symbolic = constants.%.2]
  93. // CHECK:STDOUT: }
  94. // CHECK:STDOUT:
  95. // CHECK:STDOUT: !members:
  96. // CHECK:STDOUT: .Self = constants.%C
  97. // CHECK:STDOUT: has_error
  98. // CHECK:STDOUT: }
  99. // CHECK:STDOUT:
  100. // CHECK:STDOUT: fn @F.1(@GenericInterface.%x.loc12_8.2: %T)
  101. // CHECK:STDOUT: generic [file.%T.loc11_28.2: type, @GenericInterface.%Self: %.2];
  102. // CHECK:STDOUT:
  103. // CHECK:STDOUT: fn @F.2(@impl.%x.loc20_10.2: %T)
  104. // CHECK:STDOUT: generic [@C.%T.loc19_23.2: type] {
  105. // CHECK:STDOUT: !entry:
  106. // CHECK:STDOUT: return
  107. // CHECK:STDOUT: }
  108. // CHECK:STDOUT: