redeclaration.carbon 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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/redeclaration.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/redeclaration.carbon
  10. interface I {}
  11. impl i32 as I;
  12. class X {
  13. impl i32 as I;
  14. }
  15. impl i32 as I {}
  16. // CHECK:STDOUT: --- redeclaration.carbon
  17. // CHECK:STDOUT:
  18. // CHECK:STDOUT: constants {
  19. // CHECK:STDOUT: %.1: type = interface_type @I [template]
  20. // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic]
  21. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  22. // CHECK:STDOUT: %.2: type = tuple_type () [template]
  23. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  24. // CHECK:STDOUT: %X: type = class_type @X [template]
  25. // CHECK:STDOUT: %.3: type = struct_type {} [template]
  26. // CHECK:STDOUT: %.4: <witness> = interface_witness () [template]
  27. // CHECK:STDOUT: }
  28. // CHECK:STDOUT:
  29. // CHECK:STDOUT: file {
  30. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  31. // CHECK:STDOUT: .Core = %Core
  32. // CHECK:STDOUT: .I = %I.decl
  33. // CHECK:STDOUT: .X = %X.decl
  34. // CHECK:STDOUT: }
  35. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  36. // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%.1] {}
  37. // CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  38. // CHECK:STDOUT: impl_decl @impl {
  39. // CHECK:STDOUT: %int.make_type_32.loc13: init type = call constants.%Int32() [template = i32]
  40. // CHECK:STDOUT: %.loc13_6.1: type = value_of_initializer %int.make_type_32.loc13 [template = i32]
  41. // CHECK:STDOUT: %.loc13_6.2: type = converted %int.make_type_32.loc13, %.loc13_6.1 [template = i32]
  42. // CHECK:STDOUT: %I.ref.loc13: type = name_ref I, %I.decl [template = constants.%.1]
  43. // CHECK:STDOUT: }
  44. // CHECK:STDOUT: %X.decl: type = class_decl @X [template = constants.%X] {}
  45. // CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  46. // CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  47. // CHECK:STDOUT: impl_decl @impl {
  48. // CHECK:STDOUT: %int.make_type_32.loc19: init type = call constants.%Int32() [template = i32]
  49. // CHECK:STDOUT: %.loc19_6.1: type = value_of_initializer %int.make_type_32.loc19 [template = i32]
  50. // CHECK:STDOUT: %.loc19_6.2: type = converted %int.make_type_32.loc19, %.loc19_6.1 [template = i32]
  51. // CHECK:STDOUT: %I.ref.loc19: type = name_ref I, %I.decl [template = constants.%.1]
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT: }
  54. // CHECK:STDOUT:
  55. // CHECK:STDOUT: interface @I {
  56. // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic = constants.%Self]
  57. // CHECK:STDOUT:
  58. // CHECK:STDOUT: !members:
  59. // CHECK:STDOUT: .Self = %Self
  60. // CHECK:STDOUT: witness = ()
  61. // CHECK:STDOUT: }
  62. // CHECK:STDOUT:
  63. // CHECK:STDOUT: impl @impl: i32 as %.1 {
  64. // CHECK:STDOUT: %.1: <witness> = interface_witness () [template = constants.%.4]
  65. // CHECK:STDOUT:
  66. // CHECK:STDOUT: !members:
  67. // CHECK:STDOUT: witness = %.1
  68. // CHECK:STDOUT: }
  69. // CHECK:STDOUT:
  70. // CHECK:STDOUT: class @X {
  71. // CHECK:STDOUT: impl_decl @impl {
  72. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  73. // CHECK:STDOUT: %.loc16_8.1: type = value_of_initializer %int.make_type_32 [template = i32]
  74. // CHECK:STDOUT: %.loc16_8.2: type = converted %int.make_type_32, %.loc16_8.1 [template = i32]
  75. // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [template = constants.%.1]
  76. // CHECK:STDOUT: }
  77. // CHECK:STDOUT:
  78. // CHECK:STDOUT: !members:
  79. // CHECK:STDOUT: .Self = constants.%X
  80. // CHECK:STDOUT: }
  81. // CHECK:STDOUT:
  82. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  83. // CHECK:STDOUT: