fail_extend_impl_forall.carbon 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. // CHECK:STDERR: fail_extend_impl_forall.carbon:[[@LINE+4]]:1: ERROR: Semantics TODO: `generic interface`.
  7. // CHECK:STDERR: interface GenericInterface(T:! type) {
  8. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  9. // CHECK:STDERR:
  10. interface GenericInterface(T:! type) {
  11. fn F(x: T);
  12. }
  13. class C {
  14. // CHECK:STDERR: fail_extend_impl_forall.carbon:[[@LINE+11]]:3: ERROR: Cannot `extend` a parameterized `impl`.
  15. // CHECK:STDERR: extend impl forall [T:! type] as GenericInterface(T) {
  16. // CHECK:STDERR: ^~~~~~
  17. // CHECK:STDERR:
  18. // CHECK:STDERR: fail_extend_impl_forall.carbon:[[@LINE+7]]:3: ERROR: Semantics TODO: `impl as non-interface`.
  19. // CHECK:STDERR: extend impl forall [T:! type] as GenericInterface(T) {
  20. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  21. // CHECK:STDERR:
  22. // CHECK:STDERR: fail_extend_impl_forall.carbon:[[@LINE+3]]:36: ERROR: Value of type `type` is not callable.
  23. // CHECK:STDERR: extend impl forall [T:! type] as GenericInterface(T) {
  24. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~
  25. extend impl forall [T:! type] as GenericInterface(T) {
  26. fn F(x: T) {}
  27. }
  28. }
  29. // CHECK:STDOUT: --- fail_extend_impl_forall.carbon
  30. // CHECK:STDOUT:
  31. // CHECK:STDOUT: constants {
  32. // CHECK:STDOUT: %.1: type = interface_type @GenericInterface [template]
  33. // CHECK:STDOUT: %.2: type = assoc_entity_type @GenericInterface, <function> [template]
  34. // CHECK:STDOUT: %.3: <associated <function> in GenericInterface> = assoc_entity element0, @GenericInterface.%F [template]
  35. // CHECK:STDOUT: %C: type = class_type @C [template]
  36. // CHECK:STDOUT: %.4: type = struct_type {} [template]
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT:
  39. // CHECK:STDOUT: file {
  40. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  41. // CHECK:STDOUT: .GenericInterface = %GenericInterface.decl
  42. // CHECK:STDOUT: .C = %C.decl
  43. // CHECK:STDOUT: }
  44. // CHECK:STDOUT: %GenericInterface.decl: type = interface_decl @GenericInterface [template = constants.%.1] {
  45. // CHECK:STDOUT: %T.loc11_28.1: type = param T
  46. // CHECK:STDOUT: %T.loc11_28.2: type = bind_symbolic_name T, %T.loc11_28.1 [symbolic]
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {}
  49. // CHECK:STDOUT: }
  50. // CHECK:STDOUT:
  51. // CHECK:STDOUT: interface @GenericInterface {
  52. // CHECK:STDOUT: %Self: GenericInterface = bind_symbolic_name Self [symbolic]
  53. // CHECK:STDOUT: %F: <function> = fn_decl @F.1 [template] {
  54. // CHECK:STDOUT: %T.ref: type = name_ref T, file.%T.loc11_28.2 [symbolic = file.%T.loc11_28.2]
  55. // CHECK:STDOUT: %x.loc12_8.1: T = param x
  56. // CHECK:STDOUT: %x.loc12_8.2: T = bind_name x, %x.loc12_8.1
  57. // CHECK:STDOUT: }
  58. // CHECK:STDOUT: %.loc12: <associated <function> in GenericInterface> = assoc_entity element0, %F [template = constants.%.3]
  59. // CHECK:STDOUT:
  60. // CHECK:STDOUT: !members:
  61. // CHECK:STDOUT: .Self = %Self
  62. // CHECK:STDOUT: .F = %.loc12
  63. // CHECK:STDOUT: witness = (%F)
  64. // CHECK:STDOUT: }
  65. // CHECK:STDOUT:
  66. // CHECK:STDOUT: impl @impl: C as <error> {
  67. // CHECK:STDOUT: %F: <function> = fn_decl @F.2 [template] {
  68. // CHECK:STDOUT: %T.ref: type = name_ref T, @C.%T.loc27_23.2 [symbolic = @C.%T.loc27_23.2]
  69. // CHECK:STDOUT: %x.loc28_10.1: T = param x
  70. // CHECK:STDOUT: %x.loc28_10.2: T = bind_name x, %x.loc28_10.1
  71. // CHECK:STDOUT: }
  72. // CHECK:STDOUT:
  73. // CHECK:STDOUT: !members:
  74. // CHECK:STDOUT: .F = %F
  75. // CHECK:STDOUT: witness = <error>
  76. // CHECK:STDOUT: }
  77. // CHECK:STDOUT:
  78. // CHECK:STDOUT: class @C {
  79. // CHECK:STDOUT: impl_decl @impl {
  80. // CHECK:STDOUT: %T.loc27_23.1: type = param T
  81. // CHECK:STDOUT: %T.loc27_23.2: type = bind_symbolic_name T, %T.loc27_23.1 [symbolic]
  82. // CHECK:STDOUT: %GenericInterface.ref: type = name_ref GenericInterface, file.%GenericInterface.decl [template = constants.%.1]
  83. // CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc27_23.2 [symbolic = %T.loc27_23.2]
  84. // CHECK:STDOUT: }
  85. // CHECK:STDOUT:
  86. // CHECK:STDOUT: !members:
  87. // CHECK:STDOUT: .Self = constants.%C
  88. // CHECK:STDOUT: has_error
  89. // CHECK:STDOUT: }
  90. // CHECK:STDOUT:
  91. // CHECK:STDOUT: fn @F.1(@GenericInterface.%x.loc12_8.2: T);
  92. // CHECK:STDOUT:
  93. // CHECK:STDOUT: fn @F.2(@impl.%x.loc28_10.2: T) {
  94. // CHECK:STDOUT: !entry:
  95. // CHECK:STDOUT: return
  96. // CHECK:STDOUT: }
  97. // CHECK:STDOUT: