fail_alias.carbon 3.6 KB

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