fail_alias_impl_not_found.carbon 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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_alias_impl_not_found.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_alias_impl_not_found.carbon
  10. interface I {
  11. fn F();
  12. }
  13. class C {
  14. alias F = I.F;
  15. }
  16. fn F(c: C) {
  17. // CHECK:STDERR: fail_alias_impl_not_found.carbon:[[@LINE+4]]:3: ERROR: Cannot access member of interface I in type C that does not implement that interface.
  18. // CHECK:STDERR: C.F();
  19. // CHECK:STDERR: ^~~
  20. // CHECK:STDERR:
  21. C.F();
  22. // CHECK:STDERR: fail_alias_impl_not_found.carbon:[[@LINE+3]]:3: ERROR: Cannot access member of interface I in type C that does not implement that interface.
  23. // CHECK:STDERR: c.F();
  24. // CHECK:STDERR: ^~~
  25. c.F();
  26. }
  27. // CHECK:STDOUT: --- fail_alias_impl_not_found.carbon
  28. // CHECK:STDOUT:
  29. // CHECK:STDOUT: constants {
  30. // CHECK:STDOUT: %.1: type = interface_type @I [template]
  31. // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic]
  32. // CHECK:STDOUT: %F.type.1: type = fn_type @F.1 [template]
  33. // CHECK:STDOUT: %.2: type = tuple_type () [template]
  34. // CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [template]
  35. // CHECK:STDOUT: %.3: type = assoc_entity_type @I, %F.type.1 [template]
  36. // CHECK:STDOUT: %.4: %.3 = assoc_entity element0, @I.%F.decl [template]
  37. // CHECK:STDOUT: %C: type = class_type @C [template]
  38. // CHECK:STDOUT: %.5: type = struct_type {} [template]
  39. // CHECK:STDOUT: %F.type.2: type = fn_type @F.2 [template]
  40. // CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [template]
  41. // CHECK:STDOUT: %.6: type = ptr_type %.5 [template]
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT:
  44. // CHECK:STDOUT: file {
  45. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  46. // CHECK:STDOUT: .Core = %Core
  47. // CHECK:STDOUT: .I = %I.decl
  48. // CHECK:STDOUT: .C = %C.decl
  49. // CHECK:STDOUT: .F = %F.decl
  50. // CHECK:STDOUT: }
  51. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  52. // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%.1] {}
  53. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {}
  54. // CHECK:STDOUT: %F.decl: %F.type.2 = fn_decl @F.2 [template = constants.%F.2] {
  55. // CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C]
  56. // CHECK:STDOUT: %c.loc19_6.1: %C = param c
  57. // CHECK:STDOUT: @F.2.%c: %C = bind_name c, %c.loc19_6.1
  58. // CHECK:STDOUT: }
  59. // CHECK:STDOUT: }
  60. // CHECK:STDOUT:
  61. // CHECK:STDOUT: interface @I {
  62. // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic = constants.%Self]
  63. // CHECK:STDOUT: %F.decl: %F.type.1 = fn_decl @F.1 [template = constants.%F.1] {}
  64. // CHECK:STDOUT: %.loc12: %.3 = assoc_entity element0, %F.decl [template = constants.%.4]
  65. // CHECK:STDOUT:
  66. // CHECK:STDOUT: !members:
  67. // CHECK:STDOUT: .Self = %Self
  68. // CHECK:STDOUT: .F = %.loc12
  69. // CHECK:STDOUT: witness = (%F.decl)
  70. // CHECK:STDOUT: }
  71. // CHECK:STDOUT:
  72. // CHECK:STDOUT: class @C {
  73. // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [template = constants.%.1]
  74. // CHECK:STDOUT: %F.ref: %.3 = name_ref F, @I.%.loc12 [template = constants.%.4]
  75. // CHECK:STDOUT: %F: %.3 = bind_alias F, @I.%.loc12 [template = constants.%.4]
  76. // CHECK:STDOUT:
  77. // CHECK:STDOUT: !members:
  78. // CHECK:STDOUT: .Self = constants.%C
  79. // CHECK:STDOUT: .F = %F
  80. // CHECK:STDOUT: }
  81. // CHECK:STDOUT:
  82. // CHECK:STDOUT: fn @F.1()
  83. // CHECK:STDOUT: generic [@I.%Self: %.1];
  84. // CHECK:STDOUT:
  85. // CHECK:STDOUT: fn @F.2(%c: %C) {
  86. // CHECK:STDOUT: !entry:
  87. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  88. // CHECK:STDOUT: %F.ref.loc24: %.3 = name_ref F, @C.%F [template = constants.%.4]
  89. // CHECK:STDOUT: %c.ref: %C = name_ref c, %c
  90. // CHECK:STDOUT: %F.ref.loc28: %.3 = name_ref F, @C.%F [template = constants.%.4]
  91. // CHECK:STDOUT: return
  92. // CHECK:STDOUT: }
  93. // CHECK:STDOUT: