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