fail_todo_extend_impl.carbon 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. interface HasF {
  7. fn F();
  8. }
  9. class C {
  10. extend impl as HasF {
  11. fn F() {}
  12. }
  13. }
  14. fn G(c: C) {
  15. // TODO: These should do impl lookup. Because that's not implemented yet, they
  16. // refer to the interface members rather than to the impl members.
  17. // CHECK:STDERR: fail_todo_extend_impl.carbon:[[@LINE+3]]:3: ERROR: Value of type `<associated <function> in HasF>` is not callable.
  18. // CHECK:STDERR: C.F();
  19. // CHECK:STDERR: ^~~~
  20. C.F();
  21. // CHECK:STDERR: fail_todo_extend_impl.carbon:[[@LINE+3]]:3: ERROR: Value of type `<associated <function> in HasF>` is not callable.
  22. // CHECK:STDERR: c.F();
  23. // CHECK:STDERR: ^~~~
  24. c.F();
  25. }
  26. // CHECK:STDOUT: --- fail_todo_extend_impl.carbon
  27. // CHECK:STDOUT:
  28. // CHECK:STDOUT: constants {
  29. // CHECK:STDOUT: %.1: type = interface_type @HasF [template]
  30. // CHECK:STDOUT: %.2: type = assoc_entity_type @HasF, <function> [template]
  31. // CHECK:STDOUT: %.3: <associated <function> in HasF> = assoc_entity element0, @HasF.%F [template]
  32. // CHECK:STDOUT: %C: type = class_type @C [template]
  33. // CHECK:STDOUT: %.4: type = struct_type {} [template]
  34. // CHECK:STDOUT: %.5: type = tuple_type () [template]
  35. // CHECK:STDOUT: %.6: type = ptr_type {} [template]
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT:
  38. // CHECK:STDOUT: file {
  39. // CHECK:STDOUT: package: <namespace> = namespace {
  40. // CHECK:STDOUT: .HasF = %HasF.decl
  41. // CHECK:STDOUT: .C = %C.decl
  42. // CHECK:STDOUT: .G = %G
  43. // CHECK:STDOUT: } [template]
  44. // CHECK:STDOUT: %HasF.decl = interface_decl @HasF {} [template = constants.%.1]
  45. // CHECK:STDOUT: %C.decl = class_decl @C {} [template = constants.%C]
  46. // CHECK:STDOUT: %G: <function> = fn_decl @G {
  47. // CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C]
  48. // CHECK:STDOUT: %c.loc17_6.1: C = param c
  49. // CHECK:STDOUT: @G.%c: C = bind_name c, %c.loc17_6.1
  50. // CHECK:STDOUT: } [template]
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT:
  53. // CHECK:STDOUT: interface @HasF {
  54. // CHECK:STDOUT: %F: <function> = fn_decl @F.1 {} [template]
  55. // CHECK:STDOUT: %.loc8: <associated <function> in HasF> = assoc_entity element0, %F [template = constants.%.3]
  56. // CHECK:STDOUT:
  57. // CHECK:STDOUT: !members:
  58. // CHECK:STDOUT: .F = %.loc8
  59. // CHECK:STDOUT: witness = (%F)
  60. // CHECK:STDOUT: }
  61. // CHECK:STDOUT:
  62. // CHECK:STDOUT: impl @impl: C as HasF {
  63. // CHECK:STDOUT: %F: <function> = fn_decl @F.2 {} [template]
  64. // CHECK:STDOUT:
  65. // CHECK:STDOUT: !members:
  66. // CHECK:STDOUT: .F = %F
  67. // CHECK:STDOUT: }
  68. // CHECK:STDOUT:
  69. // CHECK:STDOUT: class @C {
  70. // CHECK:STDOUT: impl_decl @impl {
  71. // CHECK:STDOUT: %HasF.ref: type = name_ref HasF, file.%HasF.decl [template = constants.%.1]
  72. // CHECK:STDOUT: }
  73. // CHECK:STDOUT:
  74. // CHECK:STDOUT: !members:
  75. // CHECK:STDOUT: .Self = constants.%C
  76. // CHECK:STDOUT: extend name_scope1
  77. // CHECK:STDOUT: }
  78. // CHECK:STDOUT:
  79. // CHECK:STDOUT: fn @F.1();
  80. // CHECK:STDOUT:
  81. // CHECK:STDOUT: fn @F.2() {
  82. // CHECK:STDOUT: !entry:
  83. // CHECK:STDOUT: return
  84. // CHECK:STDOUT: }
  85. // CHECK:STDOUT:
  86. // CHECK:STDOUT: fn @G(%c: C) {
  87. // CHECK:STDOUT: !entry:
  88. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  89. // CHECK:STDOUT: %F.ref.loc23: <associated <function> in HasF> = name_ref F, @HasF.%.loc8 [template = constants.%.3]
  90. // CHECK:STDOUT: %c.ref: C = name_ref c, %c
  91. // CHECK:STDOUT: %F.ref.loc27: <associated <function> in HasF> = name_ref F, @HasF.%.loc8 [template = constants.%.3]
  92. // CHECK:STDOUT: return
  93. // CHECK:STDOUT: }
  94. // CHECK:STDOUT: