fail_alias.carbon 4.1 KB

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