fail_todo_undefined_impl.carbon 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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: %I.type: type = interface_type @I [template]
  30. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic]
  31. // CHECK:STDOUT: %F.type.1: type = fn_type @F.1 [template]
  32. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  33. // CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [template]
  34. // CHECK:STDOUT: %.2: type = assoc_entity_type %I.type, %F.type.1 [template]
  35. // CHECK:STDOUT: %.3: %.2 = assoc_entity element0, @I.%F.decl [template]
  36. // CHECK:STDOUT: %C: type = class_type @C [template]
  37. // CHECK:STDOUT: %.4: type = struct_type {} [template]
  38. // CHECK:STDOUT: %.5: <witness> = complete_type_witness %.4 [template]
  39. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  40. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  41. // CHECK:STDOUT: %F.type.2: type = fn_type @F.2 [template]
  42. // CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [template]
  43. // CHECK:STDOUT: %.6: type = ptr_type %.4 [template]
  44. // CHECK:STDOUT: %F.type.3: type = fn_type @F.3 [template]
  45. // CHECK:STDOUT: %F.3: %F.type.3 = struct_value () [template]
  46. // CHECK:STDOUT: %.7: <witness> = interface_witness (%F.3) [template]
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT:
  49. // CHECK:STDOUT: imports {
  50. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  51. // CHECK:STDOUT: .Int32 = %import_ref
  52. // CHECK:STDOUT: import Core//prelude
  53. // CHECK:STDOUT: import Core//prelude/operators
  54. // CHECK:STDOUT: import Core//prelude/types
  55. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  56. // CHECK:STDOUT: import Core//prelude/operators/as
  57. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  58. // CHECK:STDOUT: import Core//prelude/operators/comparison
  59. // CHECK:STDOUT: import Core//prelude/types/bool
  60. // CHECK:STDOUT: }
  61. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+9, loaded [template = constants.%Int32]
  62. // CHECK:STDOUT: }
  63. // CHECK:STDOUT:
  64. // CHECK:STDOUT: file {
  65. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  66. // CHECK:STDOUT: .Core = imports.%Core
  67. // CHECK:STDOUT: .I = %I.decl
  68. // CHECK:STDOUT: .C = %C.decl
  69. // CHECK:STDOUT: .F = %F.decl
  70. // CHECK:STDOUT: }
  71. // CHECK:STDOUT: %Core.import = import Core
  72. // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%I.type] {} {}
  73. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  74. // CHECK:STDOUT: %F.decl: %F.type.2 = fn_decl @F.2 [template = constants.%F.2] {} {
  75. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  76. // CHECK:STDOUT: %.loc19_11.1: type = value_of_initializer %int.make_type_32 [template = i32]
  77. // CHECK:STDOUT: %.loc19_11.2: type = converted %int.make_type_32, %.loc19_11.1 [template = i32]
  78. // CHECK:STDOUT: %return: ref i32 = var <return slot>
  79. // CHECK:STDOUT: }
  80. // CHECK:STDOUT: impl_decl @impl.2 [template] {} {
  81. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  82. // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [template = constants.%I.type]
  83. // CHECK:STDOUT: }
  84. // CHECK:STDOUT: }
  85. // CHECK:STDOUT:
  86. // CHECK:STDOUT: interface @I {
  87. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
  88. // CHECK:STDOUT: %F.decl: %F.type.1 = fn_decl @F.1 [template = constants.%F.1] {} {}
  89. // CHECK:STDOUT: %.loc12: %.2 = assoc_entity element0, %F.decl [template = constants.%.3]
  90. // CHECK:STDOUT:
  91. // CHECK:STDOUT: !members:
  92. // CHECK:STDOUT: .Self = %Self
  93. // CHECK:STDOUT: .F = %.loc12
  94. // CHECK:STDOUT: witness = (%F.decl)
  95. // CHECK:STDOUT: }
  96. // CHECK:STDOUT:
  97. // CHECK:STDOUT: impl @impl.1: %Self.ref as %I.ref;
  98. // CHECK:STDOUT:
  99. // CHECK:STDOUT: impl @impl.2: %C.ref as %I.ref {
  100. // CHECK:STDOUT: %F.decl: %F.type.3 = fn_decl @F.3 [template = constants.%F.3] {} {}
  101. // CHECK:STDOUT: %.loc27: <witness> = interface_witness (%F.decl) [template = constants.%.7]
  102. // CHECK:STDOUT:
  103. // CHECK:STDOUT: !members:
  104. // CHECK:STDOUT: .F = %F.decl
  105. // CHECK:STDOUT: witness = %.loc27
  106. // CHECK:STDOUT: }
  107. // CHECK:STDOUT:
  108. // CHECK:STDOUT: class @C {
  109. // CHECK:STDOUT: impl_decl @impl.1 [template] {} {
  110. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%C [template = constants.%C]
  111. // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [template = constants.%I.type]
  112. // CHECK:STDOUT: }
  113. // CHECK:STDOUT: %.loc17: <witness> = complete_type_witness %.4 [template = constants.%.5]
  114. // CHECK:STDOUT:
  115. // CHECK:STDOUT: !members:
  116. // CHECK:STDOUT: .Self = constants.%C
  117. // CHECK:STDOUT: extend name_scope2
  118. // CHECK:STDOUT: }
  119. // CHECK:STDOUT:
  120. // CHECK:STDOUT: generic fn @F.1(@I.%Self: %I.type) {
  121. // CHECK:STDOUT:
  122. // CHECK:STDOUT: fn();
  123. // CHECK:STDOUT: }
  124. // CHECK:STDOUT:
  125. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  126. // CHECK:STDOUT:
  127. // CHECK:STDOUT: fn @F.2() -> i32 {
  128. // CHECK:STDOUT: !entry:
  129. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  130. // CHECK:STDOUT: %F.ref: %.2 = name_ref F, @I.%.loc12 [template = constants.%.3]
  131. // CHECK:STDOUT: return <error>
  132. // CHECK:STDOUT: }
  133. // CHECK:STDOUT:
  134. // CHECK:STDOUT: fn @F.3() {
  135. // CHECK:STDOUT: !entry:
  136. // CHECK:STDOUT: return
  137. // CHECK:STDOUT: }
  138. // CHECK:STDOUT:
  139. // CHECK:STDOUT: specific @F.1(constants.%Self) {}
  140. // CHECK:STDOUT:
  141. // CHECK:STDOUT: specific @F.1(constants.%C) {}
  142. // CHECK:STDOUT: