fail_alias_impl_not_found.carbon 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/none.carbon
  6. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  7. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  8. //
  9. // AUTOUPDATE
  10. // TIP: To test this file alone, run:
  11. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/impl/lookup/fail_alias_impl_not_found.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/lookup/fail_alias_impl_not_found.carbon
  14. interface I {
  15. fn F();
  16. }
  17. class C {
  18. alias F = I.F;
  19. }
  20. fn F(c: C) {
  21. // 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 [MissingImplInMemberAccess]
  22. // CHECK:STDERR: C.F();
  23. // CHECK:STDERR: ^~~
  24. // CHECK:STDERR:
  25. C.F();
  26. // 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 [MissingImplInMemberAccess]
  27. // CHECK:STDERR: c.F();
  28. // CHECK:STDERR: ^~~
  29. // CHECK:STDERR:
  30. c.F();
  31. }
  32. // CHECK:STDOUT: --- fail_alias_impl_not_found.carbon
  33. // CHECK:STDOUT:
  34. // CHECK:STDOUT: constants {
  35. // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
  36. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic]
  37. // CHECK:STDOUT: %F.type.cf0: type = fn_type @F.loc16 [concrete]
  38. // CHECK:STDOUT: %F.bc6: %F.type.cf0 = struct_value () [concrete]
  39. // CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type @I [concrete]
  40. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.%F.decl [concrete]
  41. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  42. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  43. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  44. // CHECK:STDOUT: %pattern_type: type = pattern_type %C [concrete]
  45. // CHECK:STDOUT: %F.type.b25: type = fn_type @F.loc23 [concrete]
  46. // CHECK:STDOUT: %F.c41: %F.type.b25 = struct_value () [concrete]
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT:
  49. // CHECK:STDOUT: file {
  50. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  51. // CHECK:STDOUT: .I = %I.decl
  52. // CHECK:STDOUT: .C = %C.decl
  53. // CHECK:STDOUT: .F = %F.decl
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT: %I.decl: type = interface_decl @I [concrete = constants.%I.type] {} {}
  56. // CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {}
  57. // CHECK:STDOUT: %F.decl: %F.type.b25 = fn_decl @F.loc23 [concrete = constants.%F.c41] {
  58. // CHECK:STDOUT: %c.patt: %pattern_type = binding_pattern c [concrete]
  59. // CHECK:STDOUT: %c.param_patt: %pattern_type = value_param_pattern %c.patt, call_param0 [concrete]
  60. // CHECK:STDOUT: } {
  61. // CHECK:STDOUT: %c.param: %C = value_param call_param0
  62. // CHECK:STDOUT: %C.ref.loc23: type = name_ref C, file.%C.decl [concrete = constants.%C]
  63. // CHECK:STDOUT: %c: %C = bind_name c, %c.param
  64. // CHECK:STDOUT: }
  65. // CHECK:STDOUT: }
  66. // CHECK:STDOUT:
  67. // CHECK:STDOUT: interface @I {
  68. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
  69. // CHECK:STDOUT: %F.decl: %F.type.cf0 = fn_decl @F.loc16 [concrete = constants.%F.bc6] {} {}
  70. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, %F.decl [concrete = constants.%assoc0]
  71. // CHECK:STDOUT:
  72. // CHECK:STDOUT: !members:
  73. // CHECK:STDOUT: .Self = %Self
  74. // CHECK:STDOUT: .F = %assoc0
  75. // CHECK:STDOUT: witness = (%F.decl)
  76. // CHECK:STDOUT: }
  77. // CHECK:STDOUT:
  78. // CHECK:STDOUT: class @C {
  79. // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [concrete = constants.%I.type]
  80. // CHECK:STDOUT: %F.ref: %I.assoc_type = name_ref F, @I.%assoc0 [concrete = constants.%assoc0]
  81. // CHECK:STDOUT: %F: %I.assoc_type = bind_alias F, @I.%assoc0 [concrete = constants.%assoc0]
  82. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete = constants.%empty_struct_type]
  83. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type]
  84. // CHECK:STDOUT: complete_type_witness = %complete_type
  85. // CHECK:STDOUT:
  86. // CHECK:STDOUT: !members:
  87. // CHECK:STDOUT: .Self = constants.%C
  88. // CHECK:STDOUT: .I = <poisoned>
  89. // CHECK:STDOUT: .F = %F
  90. // CHECK:STDOUT: }
  91. // CHECK:STDOUT:
  92. // CHECK:STDOUT: generic fn @F.loc16(@I.%Self: %I.type) {
  93. // CHECK:STDOUT: fn();
  94. // CHECK:STDOUT: }
  95. // CHECK:STDOUT:
  96. // CHECK:STDOUT: fn @F.loc23(%c.param: %C) {
  97. // CHECK:STDOUT: !entry:
  98. // CHECK:STDOUT: %C.ref.loc28: type = name_ref C, file.%C.decl [concrete = constants.%C]
  99. // CHECK:STDOUT: %F.ref.loc28: %I.assoc_type = name_ref F, @C.%F [concrete = constants.%assoc0]
  100. // CHECK:STDOUT: %c.ref: %C = name_ref c, %c
  101. // CHECK:STDOUT: %F.ref.loc33: %I.assoc_type = name_ref F, @C.%F [concrete = constants.%assoc0]
  102. // CHECK:STDOUT: return
  103. // CHECK:STDOUT: }
  104. // CHECK:STDOUT:
  105. // CHECK:STDOUT: specific @F.loc16(constants.%Self) {}
  106. // CHECK:STDOUT: