fail_alias.carbon 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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/fail_alias.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/fail_alias.carbon
  14. interface I {}
  15. class C {}
  16. alias AI = I;
  17. alias AC = C;
  18. impl AC as AI {}
  19. // CHECK:STDERR: fail_alias.carbon:[[@LINE+7]]:1: error: redefinition of `impl AC as AI` [ImplRedefinition]
  20. // CHECK:STDERR: impl AC as AI {}
  21. // CHECK:STDERR: ^~~~~~~~~~~~~~~
  22. // CHECK:STDERR: fail_alias.carbon:[[@LINE-5]]:1: note: previous definition was here [ImplPreviousDefinition]
  23. // CHECK:STDERR: impl AC as AI {}
  24. // CHECK:STDERR: ^~~~~~~~~~~~~~~
  25. // CHECK:STDERR:
  26. impl AC as AI {}
  27. // CHECK:STDOUT: --- fail_alias.carbon
  28. // CHECK:STDOUT:
  29. // CHECK:STDOUT: constants {
  30. // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
  31. // CHECK:STDOUT: %Self: %I.type = symbolic_binding Self, 0 [symbolic]
  32. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  33. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  34. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  35. // CHECK:STDOUT: %I.impl_witness: <witness> = impl_witness @C.as.I.impl.e47215.1.%I.impl_witness_table [concrete]
  36. // CHECK:STDOUT: %I.facet: %I.type = facet_value %C, (%I.impl_witness) [concrete]
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT:
  39. // CHECK:STDOUT: file {
  40. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  41. // CHECK:STDOUT: .I = %I.decl
  42. // CHECK:STDOUT: .C = %C.decl
  43. // CHECK:STDOUT: .AI = %AI
  44. // CHECK:STDOUT: .AC = %AC
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT: %I.decl: type = interface_decl @I [concrete = constants.%I.type] {} {}
  47. // CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {}
  48. // CHECK:STDOUT: %I.ref: type = name_ref I, %I.decl [concrete = constants.%I.type]
  49. // CHECK:STDOUT: %AI: type = alias_binding AI, %I.decl [concrete = constants.%I.type]
  50. // CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [concrete = constants.%C]
  51. // CHECK:STDOUT: %AC: type = alias_binding AC, %C.decl [concrete = constants.%C]
  52. // CHECK:STDOUT: impl_decl @C.as.I.impl.e47215.1 [concrete] {} {
  53. // CHECK:STDOUT: %AC.ref: type = name_ref AC, file.%AC [concrete = constants.%C]
  54. // CHECK:STDOUT: %AI.ref: type = name_ref AI, file.%AI [concrete = constants.%I.type]
  55. // CHECK:STDOUT: }
  56. // CHECK:STDOUT: impl_decl @C.as.I.impl.e47215.2 [concrete] {} {
  57. // CHECK:STDOUT: %AC.ref: type = name_ref AC, file.%AC [concrete = constants.%C]
  58. // CHECK:STDOUT: %AI.ref: type = name_ref AI, file.%AI [concrete = constants.%I.type]
  59. // CHECK:STDOUT: }
  60. // CHECK:STDOUT: }
  61. // CHECK:STDOUT:
  62. // CHECK:STDOUT: interface @I {
  63. // CHECK:STDOUT: %Self: %I.type = symbolic_binding Self, 0 [symbolic = constants.%Self]
  64. // CHECK:STDOUT: %I.WithSelf.decl = interface_with_self_decl @I [concrete]
  65. // CHECK:STDOUT:
  66. // CHECK:STDOUT: !members:
  67. // CHECK:STDOUT: .Self = %Self
  68. // CHECK:STDOUT: witness = ()
  69. // CHECK:STDOUT:
  70. // CHECK:STDOUT: !requires:
  71. // CHECK:STDOUT: }
  72. // CHECK:STDOUT:
  73. // CHECK:STDOUT: impl @C.as.I.impl.e47215.1: %AC.ref as %AI.ref {
  74. // CHECK:STDOUT: %I.impl_witness_table = impl_witness_table (), @C.as.I.impl.e47215.1 [concrete]
  75. // CHECK:STDOUT: %I.impl_witness: <witness> = impl_witness %I.impl_witness_table [concrete = constants.%I.impl_witness]
  76. // CHECK:STDOUT:
  77. // CHECK:STDOUT: !members:
  78. // CHECK:STDOUT: witness = %I.impl_witness
  79. // CHECK:STDOUT: }
  80. // CHECK:STDOUT:
  81. // CHECK:STDOUT: impl @C.as.I.impl.e47215.2: %AC.ref as %AI.ref {
  82. // CHECK:STDOUT: !members:
  83. // CHECK:STDOUT: witness = <error>
  84. // CHECK:STDOUT: }
  85. // CHECK:STDOUT:
  86. // CHECK:STDOUT: class @C {
  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: }
  93. // CHECK:STDOUT:
  94. // CHECK:STDOUT: specific @I.WithSelf(constants.%Self) {
  95. // CHECK:STDOUT: !definition:
  96. // CHECK:STDOUT: }
  97. // CHECK:STDOUT:
  98. // CHECK:STDOUT: specific @I.WithSelf(constants.%I.facet) {
  99. // CHECK:STDOUT: !definition:
  100. // CHECK:STDOUT: }
  101. // CHECK:STDOUT: