fail_alias_impl_not_found.carbon 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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 = symbolic_binding Self, 0 [symbolic]
  37. // CHECK:STDOUT: %I.WithSelf.F.type: type = fn_type @I.WithSelf.F, @I.WithSelf(%Self) [symbolic]
  38. // CHECK:STDOUT: %I.WithSelf.F: %I.WithSelf.F.type = struct_value () [symbolic]
  39. // CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type @I [concrete]
  40. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.WithSelf.%I.WithSelf.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: type = fn_type @F [concrete]
  46. // CHECK:STDOUT: %F: %F.type = 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 = fn_decl @F [concrete = constants.%F] {
  58. // CHECK:STDOUT: %c.param_patt: %pattern_type = value_param_pattern [concrete]
  59. // CHECK:STDOUT: %c.patt: %pattern_type = at_binding_pattern c, %c.param_patt [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 = value_binding c, %c.param
  64. // CHECK:STDOUT: }
  65. // CHECK:STDOUT: }
  66. // CHECK:STDOUT:
  67. // CHECK:STDOUT: interface @I {
  68. // CHECK:STDOUT: %Self: %I.type = symbolic_binding Self, 0 [symbolic = constants.%Self]
  69. // CHECK:STDOUT: %I.WithSelf.decl = interface_with_self_decl @I [concrete]
  70. // CHECK:STDOUT:
  71. // CHECK:STDOUT: !with Self:
  72. // CHECK:STDOUT: %I.WithSelf.F.decl: @I.WithSelf.%I.WithSelf.F.type (%I.WithSelf.F.type) = fn_decl @I.WithSelf.F [symbolic = @I.WithSelf.%I.WithSelf.F (constants.%I.WithSelf.F)] {} {}
  73. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, %I.WithSelf.F.decl [concrete = constants.%assoc0]
  74. // CHECK:STDOUT:
  75. // CHECK:STDOUT: !members:
  76. // CHECK:STDOUT: .Self = %Self
  77. // CHECK:STDOUT: .F = @I.WithSelf.%assoc0
  78. // CHECK:STDOUT: witness = (@I.WithSelf.%I.WithSelf.F.decl)
  79. // CHECK:STDOUT:
  80. // CHECK:STDOUT: !requires:
  81. // CHECK:STDOUT: }
  82. // CHECK:STDOUT:
  83. // CHECK:STDOUT: class @C {
  84. // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [concrete = constants.%I.type]
  85. // CHECK:STDOUT: %F.ref: %I.assoc_type = name_ref F, @I.WithSelf.%assoc0 [concrete = constants.%assoc0]
  86. // CHECK:STDOUT: %F: %I.assoc_type = alias_binding F, @I.WithSelf.%assoc0 [concrete = constants.%assoc0]
  87. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type]
  88. // CHECK:STDOUT: complete_type_witness = %complete_type
  89. // CHECK:STDOUT:
  90. // CHECK:STDOUT: !members:
  91. // CHECK:STDOUT: .Self = constants.%C
  92. // CHECK:STDOUT: .I = <poisoned>
  93. // CHECK:STDOUT: .F = %F
  94. // CHECK:STDOUT: }
  95. // CHECK:STDOUT:
  96. // CHECK:STDOUT: generic fn @I.WithSelf.F(@I.%Self: %I.type) {
  97. // CHECK:STDOUT: fn();
  98. // CHECK:STDOUT: }
  99. // CHECK:STDOUT:
  100. // CHECK:STDOUT: fn @F(%c.param: %C) {
  101. // CHECK:STDOUT: !entry:
  102. // CHECK:STDOUT: %C.ref.loc28: type = name_ref C, file.%C.decl [concrete = constants.%C]
  103. // CHECK:STDOUT: %F.ref.loc28: %I.assoc_type = name_ref F, @C.%F [concrete = constants.%assoc0]
  104. // CHECK:STDOUT: %c.ref: %C = name_ref c, %c
  105. // CHECK:STDOUT: %F.ref.loc33: %I.assoc_type = name_ref F, @C.%F [concrete = constants.%assoc0]
  106. // CHECK:STDOUT: return
  107. // CHECK:STDOUT: }
  108. // CHECK:STDOUT:
  109. // CHECK:STDOUT: specific @I.WithSelf(constants.%Self) {
  110. // CHECK:STDOUT: !definition:
  111. // CHECK:STDOUT: %Self => constants.%Self
  112. // CHECK:STDOUT: %I.WithSelf.F.type => constants.%I.WithSelf.F.type
  113. // CHECK:STDOUT: %I.WithSelf.F => constants.%I.WithSelf.F
  114. // CHECK:STDOUT: }
  115. // CHECK:STDOUT:
  116. // CHECK:STDOUT: specific @I.WithSelf.F(constants.%Self) {}
  117. // CHECK:STDOUT: