fail_extend_impl_forall.carbon 4.4 KB

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