fail_todo_undefined_impl.carbon 3.5 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 I {
  7. fn F();
  8. }
  9. class C {
  10. extend impl as I;
  11. }
  12. fn F() -> i32 {
  13. // TODO: This should produce a more useful error message.
  14. // CHECK:STDERR: fail_todo_undefined_impl.carbon:[[@LINE+3]]:10: ERROR: Cannot access member of interface I in type C that does not implement that interface.
  15. // CHECK:STDERR: return C.F();
  16. // CHECK:STDERR: ^~~
  17. return C.F();
  18. }
  19. impl C as I {
  20. fn F() {}
  21. }
  22. // CHECK:STDOUT: --- fail_todo_undefined_impl.carbon
  23. // CHECK:STDOUT:
  24. // CHECK:STDOUT: constants {
  25. // CHECK:STDOUT: %.1: type = interface_type @I [template]
  26. // CHECK:STDOUT: %.2: type = assoc_entity_type @I, <function> [template]
  27. // CHECK:STDOUT: %.3: <associated <function> in I> = assoc_entity element0, @I.%F [template]
  28. // CHECK:STDOUT: %C: type = class_type @C [template]
  29. // CHECK:STDOUT: %.4: type = struct_type {} [template]
  30. // CHECK:STDOUT: %.5: <witness> = interface_witness (@impl.%F) [template]
  31. // CHECK:STDOUT: }
  32. // CHECK:STDOUT:
  33. // CHECK:STDOUT: file {
  34. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  35. // CHECK:STDOUT: .I = %I.decl
  36. // CHECK:STDOUT: .C = %C.decl
  37. // CHECK:STDOUT: .F = %F
  38. // CHECK:STDOUT: }
  39. // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%.1] {}
  40. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {}
  41. // CHECK:STDOUT: %F: <function> = fn_decl @F.2 [template] {
  42. // CHECK:STDOUT: %return.var: ref i32 = var <return slot>
  43. // CHECK:STDOUT: }
  44. // CHECK:STDOUT: impl_decl @impl {
  45. // CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C]
  46. // CHECK:STDOUT: %I.ref: type = name_ref I, %I.decl [template = constants.%.1]
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT:
  50. // CHECK:STDOUT: interface @I {
  51. // CHECK:STDOUT: %Self: I = bind_symbolic_name Self [symbolic]
  52. // CHECK:STDOUT: %F: <function> = fn_decl @F.1 [template] {}
  53. // CHECK:STDOUT: %.loc8: <associated <function> in I> = assoc_entity element0, %F [template = constants.%.3]
  54. // CHECK:STDOUT:
  55. // CHECK:STDOUT: !members:
  56. // CHECK:STDOUT: .Self = %Self
  57. // CHECK:STDOUT: .F = %.loc8
  58. // CHECK:STDOUT: witness = (%F)
  59. // CHECK:STDOUT: }
  60. // CHECK:STDOUT:
  61. // CHECK:STDOUT: impl @impl: C as I {
  62. // CHECK:STDOUT: %F: <function> = fn_decl @F.3 [template] {}
  63. // CHECK:STDOUT: %.1: <witness> = interface_witness (%F) [template = constants.%.5]
  64. // CHECK:STDOUT:
  65. // CHECK:STDOUT: !members:
  66. // CHECK:STDOUT: .F = %F
  67. // CHECK:STDOUT: witness = %.1
  68. // CHECK:STDOUT: }
  69. // CHECK:STDOUT:
  70. // CHECK:STDOUT: class @C {
  71. // CHECK:STDOUT: impl_decl @impl {
  72. // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [template = constants.%.1]
  73. // CHECK:STDOUT: }
  74. // CHECK:STDOUT:
  75. // CHECK:STDOUT: !members:
  76. // CHECK:STDOUT: .Self = constants.%C
  77. // CHECK:STDOUT: extend name_scope1
  78. // CHECK:STDOUT: }
  79. // CHECK:STDOUT:
  80. // CHECK:STDOUT: fn @F.1();
  81. // CHECK:STDOUT:
  82. // CHECK:STDOUT: fn @F.2() -> i32 {
  83. // CHECK:STDOUT: !entry:
  84. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  85. // CHECK:STDOUT: %F.ref: <associated <function> in I> = name_ref F, @I.%.loc8 [template = constants.%.3]
  86. // CHECK:STDOUT: return <error>
  87. // CHECK:STDOUT: }
  88. // CHECK:STDOUT:
  89. // CHECK:STDOUT: fn @F.3() {
  90. // CHECK:STDOUT: !entry:
  91. // CHECK:STDOUT: return
  92. // CHECK:STDOUT: }
  93. // CHECK:STDOUT: