fail_todo_undefined_impl.carbon 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/impl/lookup/fail_todo_undefined_impl.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/lookup/fail_todo_undefined_impl.carbon
  10. interface I {
  11. fn F();
  12. }
  13. class C {
  14. extend impl as I;
  15. }
  16. fn F() -> i32 {
  17. // TODO: This should produce a more useful error message.
  18. // 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.
  19. // CHECK:STDERR: return C.F();
  20. // CHECK:STDERR: ^~~
  21. return C.F();
  22. }
  23. impl C as I {
  24. fn F() {}
  25. }
  26. // CHECK:STDOUT: --- fail_todo_undefined_impl.carbon
  27. // CHECK:STDOUT:
  28. // CHECK:STDOUT: constants {
  29. // CHECK:STDOUT: %.1: type = interface_type @I [template]
  30. // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic]
  31. // CHECK:STDOUT: %F.type.1: type = fn_type @F.1 [template]
  32. // CHECK:STDOUT: %.2: type = tuple_type () [template]
  33. // CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [template]
  34. // CHECK:STDOUT: %.3: type = assoc_entity_type @I, %F.type.1 [template]
  35. // CHECK:STDOUT: %.4: %.3 = assoc_entity element0, @I.%F.decl [template]
  36. // CHECK:STDOUT: %C: type = class_type @C [template]
  37. // CHECK:STDOUT: %.5: type = struct_type {} [template]
  38. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  39. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  40. // CHECK:STDOUT: %F.type.2: type = fn_type @F.2 [template]
  41. // CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [template]
  42. // CHECK:STDOUT: %F.type.3: type = fn_type @F.3 [template]
  43. // CHECK:STDOUT: %F.3: %F.type.3 = struct_value () [template]
  44. // CHECK:STDOUT: %.6: <witness> = interface_witness (%F.3) [template]
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT:
  47. // CHECK:STDOUT: file {
  48. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  49. // CHECK:STDOUT: .Core = %Core
  50. // CHECK:STDOUT: .I = %I.decl
  51. // CHECK:STDOUT: .C = %C.decl
  52. // CHECK:STDOUT: .F = %F.decl
  53. // CHECK:STDOUT: }
  54. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  55. // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%.1] {}
  56. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {}
  57. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  58. // CHECK:STDOUT: %F.decl: %F.type.2 = fn_decl @F.2 [template = constants.%F.2] {
  59. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  60. // CHECK:STDOUT: %.loc19_11.1: type = value_of_initializer %int.make_type_32 [template = i32]
  61. // CHECK:STDOUT: %.loc19_11.2: type = converted %int.make_type_32, %.loc19_11.1 [template = i32]
  62. // CHECK:STDOUT: @F.2.%return: ref i32 = var <return slot>
  63. // CHECK:STDOUT: }
  64. // CHECK:STDOUT: impl_decl @impl {
  65. // CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C]
  66. // CHECK:STDOUT: %I.ref: type = name_ref I, %I.decl [template = constants.%.1]
  67. // CHECK:STDOUT: }
  68. // CHECK:STDOUT: }
  69. // CHECK:STDOUT:
  70. // CHECK:STDOUT: interface @I {
  71. // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic = constants.%Self]
  72. // CHECK:STDOUT: %F.decl: %F.type.1 = fn_decl @F.1 [template = constants.%F.1] {}
  73. // CHECK:STDOUT: %.loc12: %.3 = assoc_entity element0, %F.decl [template = constants.%.4]
  74. // CHECK:STDOUT:
  75. // CHECK:STDOUT: !members:
  76. // CHECK:STDOUT: .Self = %Self
  77. // CHECK:STDOUT: .F = %.loc12
  78. // CHECK:STDOUT: witness = (%F.decl)
  79. // CHECK:STDOUT: }
  80. // CHECK:STDOUT:
  81. // CHECK:STDOUT: impl @impl: %C as %.1 {
  82. // CHECK:STDOUT: %F.decl: %F.type.3 = fn_decl @F.3 [template = constants.%F.3] {}
  83. // CHECK:STDOUT: %.1: <witness> = interface_witness (%F.decl) [template = constants.%.6]
  84. // CHECK:STDOUT:
  85. // CHECK:STDOUT: !members:
  86. // CHECK:STDOUT: .F = %F.decl
  87. // CHECK:STDOUT: witness = %.1
  88. // CHECK:STDOUT: }
  89. // CHECK:STDOUT:
  90. // CHECK:STDOUT: class @C {
  91. // CHECK:STDOUT: impl_decl @impl {
  92. // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [template = constants.%.1]
  93. // CHECK:STDOUT: }
  94. // CHECK:STDOUT:
  95. // CHECK:STDOUT: !members:
  96. // CHECK:STDOUT: .Self = constants.%C
  97. // CHECK:STDOUT: extend name_scope2
  98. // CHECK:STDOUT: }
  99. // CHECK:STDOUT:
  100. // CHECK:STDOUT: fn @F.1()
  101. // CHECK:STDOUT: generic [@I.%Self: %.1];
  102. // CHECK:STDOUT:
  103. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  104. // CHECK:STDOUT:
  105. // CHECK:STDOUT: fn @F.2() -> i32 {
  106. // CHECK:STDOUT: !entry:
  107. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  108. // CHECK:STDOUT: %F.ref: %.3 = name_ref F, @I.%.loc12 [template = constants.%.4]
  109. // CHECK:STDOUT: return <error>
  110. // CHECK:STDOUT: }
  111. // CHECK:STDOUT:
  112. // CHECK:STDOUT: fn @F.3() {
  113. // CHECK:STDOUT: !entry:
  114. // CHECK:STDOUT: return
  115. // CHECK:STDOUT: }
  116. // CHECK:STDOUT: