fail_alias_impl_not_found.carbon 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. alias F = I.F;
  11. }
  12. fn F(c: C) {
  13. // 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.
  14. // CHECK:STDERR: C.F();
  15. // CHECK:STDERR: ^~~
  16. // CHECK:STDERR:
  17. C.F();
  18. // 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.
  19. // CHECK:STDERR: c.F();
  20. // CHECK:STDERR: ^~~
  21. c.F();
  22. }
  23. // CHECK:STDOUT: --- fail_alias_impl_not_found.carbon
  24. // CHECK:STDOUT:
  25. // CHECK:STDOUT: constants {
  26. // CHECK:STDOUT: %.1: type = interface_type @I [template]
  27. // CHECK:STDOUT: %.2: type = assoc_entity_type @I, <function> [template]
  28. // CHECK:STDOUT: %.3: <associated <function> in I> = assoc_entity element0, @I.%F [template]
  29. // CHECK:STDOUT: %C: type = class_type @C [template]
  30. // CHECK:STDOUT: %.4: type = struct_type {} [template]
  31. // CHECK:STDOUT: %.5: type = tuple_type () [template]
  32. // CHECK:STDOUT: %.6: type = ptr_type {} [template]
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT:
  35. // CHECK:STDOUT: file {
  36. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  37. // CHECK:STDOUT: .I = %I.decl
  38. // CHECK:STDOUT: .C = %C.decl
  39. // CHECK:STDOUT: .F = %F
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%.1] {}
  42. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {}
  43. // CHECK:STDOUT: %F: <function> = fn_decl @F.2 [template] {
  44. // CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C]
  45. // CHECK:STDOUT: %c.loc15_6.1: C = param c
  46. // CHECK:STDOUT: @F.2.%c: C = bind_name c, %c.loc15_6.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: class @C {
  62. // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [template = constants.%.1]
  63. // CHECK:STDOUT: %F.ref: <associated <function> in I> = name_ref F, @I.%.loc8 [template = constants.%.3]
  64. // CHECK:STDOUT: %F: <associated <function> in I> = bind_alias F, @I.%.loc8 [template = constants.%.3]
  65. // CHECK:STDOUT:
  66. // CHECK:STDOUT: !members:
  67. // CHECK:STDOUT: .Self = constants.%C
  68. // CHECK:STDOUT: .F = %F
  69. // CHECK:STDOUT: }
  70. // CHECK:STDOUT:
  71. // CHECK:STDOUT: fn @F.1();
  72. // CHECK:STDOUT:
  73. // CHECK:STDOUT: fn @F.2(%c: C) {
  74. // CHECK:STDOUT: !entry:
  75. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  76. // CHECK:STDOUT: %F.ref.loc20: <associated <function> in I> = name_ref F, @C.%F [template = constants.%.3]
  77. // CHECK:STDOUT: %c.ref: C = name_ref c, %c
  78. // CHECK:STDOUT: %F.ref.loc24: <associated <function> in I> = name_ref F, @C.%F [template = constants.%.3]
  79. // CHECK:STDOUT: return
  80. // CHECK:STDOUT: }
  81. // CHECK:STDOUT: