fail_alias.carbon 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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`
  16. // CHECK:STDERR: impl AC as AI {}
  17. // CHECK:STDERR: ^~~~~~~~~~~~~~~
  18. // CHECK:STDERR: fail_alias.carbon:[[@LINE-5]]:1: note: previous definition was here
  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 = interface_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: %.1: type = struct_type {} [template]
  29. // CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
  30. // CHECK:STDOUT: %.3: type = tuple_type () [template]
  31. // CHECK:STDOUT: %.4: <witness> = interface_witness () [template]
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT:
  34. // CHECK:STDOUT: file {
  35. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  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 [template = constants.%I.type] {} {}
  42. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  43. // CHECK:STDOUT: %I.ref: type = name_ref I, %I.decl [template = constants.%I.type]
  44. // CHECK:STDOUT: %AI: type = bind_alias AI, %I.decl [template = constants.%I.type]
  45. // CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C]
  46. // CHECK:STDOUT: %AC: type = bind_alias AC, %C.decl [template = constants.%C]
  47. // CHECK:STDOUT: impl_decl @impl [template] {} {
  48. // CHECK:STDOUT: %AC.ref.loc17: type = name_ref AC, file.%AC [template = constants.%C]
  49. // CHECK:STDOUT: %AI.ref.loc17: type = name_ref AI, file.%AI [template = constants.%I.type]
  50. // CHECK:STDOUT: }
  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 = <unexpected>.inst+18.loc17_15
  68. // CHECK:STDOUT: }
  69. // CHECK:STDOUT:
  70. // CHECK:STDOUT: class @C {
  71. // CHECK:STDOUT: %.loc12: <witness> = complete_type_witness %.1 [template = constants.%.2]
  72. // CHECK:STDOUT:
  73. // CHECK:STDOUT: !members:
  74. // CHECK:STDOUT: .Self = constants.%C
  75. // CHECK:STDOUT: }
  76. // CHECK:STDOUT: