fail_alias_impl_not_found.carbon 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 [MissingImplInMemberAccess]
  18. // CHECK:STDERR: C.F();
  19. // CHECK:STDERR: ^~~
  20. // CHECK:STDERR:
  21. C.F();
  22. // 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]
  23. // CHECK:STDERR: c.F();
  24. // CHECK:STDERR: ^~~
  25. // CHECK:STDERR:
  26. c.F();
  27. }
  28. // CHECK:STDOUT: --- fail_alias_impl_not_found.carbon
  29. // CHECK:STDOUT:
  30. // CHECK:STDOUT: constants {
  31. // CHECK:STDOUT: %I.type: type = facet_type <@I> [template]
  32. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic]
  33. // CHECK:STDOUT: %F.type.cf0: type = fn_type @F.1 [template]
  34. // CHECK:STDOUT: %F.bc6: %F.type.cf0 = struct_value () [template]
  35. // CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type %I.type [template]
  36. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.%F.decl [template]
  37. // CHECK:STDOUT: %C: type = class_type @C [template]
  38. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  39. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
  40. // CHECK:STDOUT: %F.type.b25: type = fn_type @F.2 [template]
  41. // CHECK:STDOUT: %F.c41: %F.type.b25 = struct_value () [template]
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT:
  44. // CHECK:STDOUT: imports {
  45. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  46. // CHECK:STDOUT: import Core//prelude
  47. // CHECK:STDOUT: import Core//prelude/...
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT: }
  50. // CHECK:STDOUT:
  51. // CHECK:STDOUT: file {
  52. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  53. // CHECK:STDOUT: .Core = imports.%Core
  54. // CHECK:STDOUT: .I = %I.decl
  55. // CHECK:STDOUT: .C = %C.decl
  56. // CHECK:STDOUT: .F = %F.decl
  57. // CHECK:STDOUT: }
  58. // CHECK:STDOUT: %Core.import = import Core
  59. // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%I.type] {} {}
  60. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  61. // CHECK:STDOUT: %F.decl: %F.type.b25 = fn_decl @F.2 [template = constants.%F.c41] {
  62. // CHECK:STDOUT: %c.patt: %C = binding_pattern c
  63. // CHECK:STDOUT: %c.param_patt: %C = value_param_pattern %c.patt, runtime_param0
  64. // CHECK:STDOUT: } {
  65. // CHECK:STDOUT: %c.param: %C = value_param runtime_param0
  66. // CHECK:STDOUT: %C.ref.loc19: type = name_ref C, file.%C.decl [template = constants.%C]
  67. // CHECK:STDOUT: %c: %C = bind_name c, %c.param
  68. // CHECK:STDOUT: }
  69. // CHECK:STDOUT: }
  70. // CHECK:STDOUT:
  71. // CHECK:STDOUT: interface @I {
  72. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
  73. // CHECK:STDOUT: %F.decl: %F.type.cf0 = fn_decl @F.1 [template = constants.%F.bc6] {} {}
  74. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, %F.decl [template = constants.%assoc0]
  75. // CHECK:STDOUT:
  76. // CHECK:STDOUT: !members:
  77. // CHECK:STDOUT: .Self = %Self
  78. // CHECK:STDOUT: .F = %assoc0
  79. // CHECK:STDOUT: witness = (%F.decl)
  80. // CHECK:STDOUT: }
  81. // CHECK:STDOUT:
  82. // CHECK:STDOUT: class @C {
  83. // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [template = constants.%I.type]
  84. // CHECK:STDOUT: %F.ref: %I.assoc_type = name_ref F, @I.%assoc0 [template = constants.%assoc0]
  85. // CHECK:STDOUT: %F: %I.assoc_type = bind_alias F, @I.%assoc0 [template = constants.%assoc0]
  86. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
  87. // CHECK:STDOUT: complete_type_witness = %complete_type
  88. // CHECK:STDOUT:
  89. // CHECK:STDOUT: !members:
  90. // CHECK:STDOUT: .Self = constants.%C
  91. // CHECK:STDOUT: .F = %F
  92. // CHECK:STDOUT: }
  93. // CHECK:STDOUT:
  94. // CHECK:STDOUT: generic fn @F.1(@I.%Self: %I.type) {
  95. // CHECK:STDOUT: fn();
  96. // CHECK:STDOUT: }
  97. // CHECK:STDOUT:
  98. // CHECK:STDOUT: fn @F.2(%c.param_patt: %C) {
  99. // CHECK:STDOUT: !entry:
  100. // CHECK:STDOUT: %C.ref.loc24: type = name_ref C, file.%C.decl [template = constants.%C]
  101. // CHECK:STDOUT: %F.ref.loc24: %I.assoc_type = name_ref F, @C.%F [template = constants.%assoc0]
  102. // CHECK:STDOUT: %c.ref: %C = name_ref c, %c
  103. // CHECK:STDOUT: %F.ref.loc29: %I.assoc_type = name_ref F, @C.%F [template = constants.%assoc0]
  104. // CHECK:STDOUT: return
  105. // CHECK:STDOUT: }
  106. // CHECK:STDOUT:
  107. // CHECK:STDOUT: specific @F.1(constants.%Self) {}
  108. // CHECK:STDOUT: