fail_alias_impl_not_found.carbon 5.4 KB

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