fail_alias.carbon 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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+7]]: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. // CHECK:STDERR:
  22. impl AC as AI {}
  23. // CHECK:STDOUT: --- fail_alias.carbon
  24. // CHECK:STDOUT:
  25. // CHECK:STDOUT: constants {
  26. // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
  27. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic]
  28. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  29. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  30. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  31. // CHECK:STDOUT: %impl_witness: <witness> = impl_witness () [concrete]
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT:
  34. // CHECK:STDOUT: file {
  35. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  36. // CHECK:STDOUT: .I = %I.decl
  37. // CHECK:STDOUT: .C = %C.decl
  38. // CHECK:STDOUT: .AI = %AI
  39. // CHECK:STDOUT: .AC = %AC
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT: %I.decl: type = interface_decl @I [concrete = constants.%I.type] {} {}
  42. // CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {}
  43. // CHECK:STDOUT: %I.ref: type = name_ref I, %I.decl [concrete = constants.%I.type]
  44. // CHECK:STDOUT: %AI: type = bind_alias AI, %I.decl [concrete = constants.%I.type]
  45. // CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [concrete = constants.%C]
  46. // CHECK:STDOUT: %AC: type = bind_alias AC, %C.decl [concrete = constants.%C]
  47. // CHECK:STDOUT: impl_decl @impl.7704ae.1 [concrete] {} {
  48. // CHECK:STDOUT: %AC.ref: type = name_ref AC, file.%AC [concrete = constants.%C]
  49. // CHECK:STDOUT: %AI.ref: type = name_ref AI, file.%AI [concrete = constants.%I.type]
  50. // CHECK:STDOUT: }
  51. // CHECK:STDOUT: %impl_witness.loc17: <witness> = impl_witness () [concrete = constants.%impl_witness]
  52. // CHECK:STDOUT: impl_decl @impl.7704ae.2 [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_witness.loc26: <witness> = impl_witness () [concrete = constants.%impl_witness]
  57. // CHECK:STDOUT: }
  58. // CHECK:STDOUT:
  59. // CHECK:STDOUT: interface @I {
  60. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
  61. // CHECK:STDOUT:
  62. // CHECK:STDOUT: !members:
  63. // CHECK:STDOUT: .Self = %Self
  64. // CHECK:STDOUT: witness = ()
  65. // CHECK:STDOUT: }
  66. // CHECK:STDOUT:
  67. // CHECK:STDOUT: impl @impl.7704ae.1: %AC.ref as %AI.ref {
  68. // CHECK:STDOUT: !members:
  69. // CHECK:STDOUT: witness = file.%impl_witness.loc17
  70. // CHECK:STDOUT: }
  71. // CHECK:STDOUT:
  72. // CHECK:STDOUT: impl @impl.7704ae.2: %AC.ref as %AI.ref {
  73. // CHECK:STDOUT: !members:
  74. // CHECK:STDOUT: witness = file.%impl_witness.loc26
  75. // CHECK:STDOUT: }
  76. // CHECK:STDOUT:
  77. // CHECK:STDOUT: class @C {
  78. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type]
  79. // CHECK:STDOUT: complete_type_witness = %complete_type
  80. // CHECK:STDOUT:
  81. // CHECK:STDOUT: !members:
  82. // CHECK:STDOUT: .Self = constants.%C
  83. // CHECK:STDOUT: }
  84. // CHECK:STDOUT: