fail_todo_extend_impl.carbon 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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: <witness> = interface_witness @HasF, (@impl.%F) [template]
  34. // CHECK:STDOUT: %.5: type = struct_type {} [template]
  35. // CHECK:STDOUT: %.6: type = tuple_type () [template]
  36. // CHECK:STDOUT: %.7: type = ptr_type {} [template]
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT:
  39. // CHECK:STDOUT: file {
  40. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  41. // CHECK:STDOUT: .HasF = %HasF.decl
  42. // CHECK:STDOUT: .C = %C.decl
  43. // CHECK:STDOUT: .G = %G
  44. // CHECK:STDOUT: }
  45. // CHECK:STDOUT: %HasF.decl: type = interface_decl @HasF [template = constants.%.1] {}
  46. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {}
  47. // CHECK:STDOUT: %G: <function> = fn_decl @G [template] {
  48. // CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C]
  49. // CHECK:STDOUT: %c.loc17_6.1: C = param c
  50. // CHECK:STDOUT: @G.%c: C = bind_name c, %c.loc17_6.1
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT:
  54. // CHECK:STDOUT: interface @HasF {
  55. // CHECK:STDOUT: %Self: HasF = bind_symbolic_name Self [symbolic]
  56. // CHECK:STDOUT: %F: <function> = fn_decl @F.1 [template] {}
  57. // CHECK:STDOUT: %.loc8: <associated <function> in HasF> = assoc_entity element0, %F [template = constants.%.3]
  58. // CHECK:STDOUT:
  59. // CHECK:STDOUT: !members:
  60. // CHECK:STDOUT: .Self = %Self
  61. // CHECK:STDOUT: .F = %.loc8
  62. // CHECK:STDOUT: witness = (%F)
  63. // CHECK:STDOUT: }
  64. // CHECK:STDOUT:
  65. // CHECK:STDOUT: impl @impl: C as HasF {
  66. // CHECK:STDOUT: %F: <function> = fn_decl @F.2 [template] {}
  67. // CHECK:STDOUT: %.1: <witness> = interface_witness @HasF, (%F) [template = constants.%.4]
  68. // CHECK:STDOUT:
  69. // CHECK:STDOUT: !members:
  70. // CHECK:STDOUT: .F = %F
  71. // CHECK:STDOUT: witness = %.1
  72. // CHECK:STDOUT: }
  73. // CHECK:STDOUT:
  74. // CHECK:STDOUT: class @C {
  75. // CHECK:STDOUT: impl_decl @impl {
  76. // CHECK:STDOUT: %HasF.ref: type = name_ref HasF, file.%HasF.decl [template = constants.%.1]
  77. // CHECK:STDOUT: }
  78. // CHECK:STDOUT:
  79. // CHECK:STDOUT: !members:
  80. // CHECK:STDOUT: .Self = constants.%C
  81. // CHECK:STDOUT: extend name_scope1
  82. // CHECK:STDOUT: }
  83. // CHECK:STDOUT:
  84. // CHECK:STDOUT: fn @F.1();
  85. // CHECK:STDOUT:
  86. // CHECK:STDOUT: fn @F.2() {
  87. // CHECK:STDOUT: !entry:
  88. // CHECK:STDOUT: return
  89. // CHECK:STDOUT: }
  90. // CHECK:STDOUT:
  91. // CHECK:STDOUT: fn @G(%c: C) {
  92. // CHECK:STDOUT: !entry:
  93. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  94. // CHECK:STDOUT: %F.ref.loc23: <associated <function> in HasF> = name_ref F, @HasF.%.loc8 [template = constants.%.3]
  95. // CHECK:STDOUT: %c.ref: C = name_ref c, %c
  96. // CHECK:STDOUT: %F.ref.loc27: <associated <function> in HasF> = name_ref F, @HasF.%.loc8 [template = constants.%.3]
  97. // CHECK:STDOUT: return
  98. // CHECK:STDOUT: }
  99. // CHECK:STDOUT: