redeclaration.carbon 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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: imports {
  30. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  31. // CHECK:STDOUT: .Int32 = %import_ref
  32. // CHECK:STDOUT: import Core//prelude
  33. // CHECK:STDOUT: import Core//prelude/operators
  34. // CHECK:STDOUT: import Core//prelude/types
  35. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  36. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  37. // CHECK:STDOUT: import Core//prelude/operators/comparison
  38. // CHECK:STDOUT: import Core//prelude/types/bool
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT:
  43. // CHECK:STDOUT: file {
  44. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  45. // CHECK:STDOUT: .Core = imports.%Core
  46. // CHECK:STDOUT: .I = %I.decl
  47. // CHECK:STDOUT: .X = %X.decl
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT: %Core.import = import Core
  50. // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%.1] {}
  51. // CHECK:STDOUT: impl_decl @impl {
  52. // CHECK:STDOUT: %int.make_type_32.loc13: init type = call constants.%Int32() [template = i32]
  53. // CHECK:STDOUT: %.loc13_6.1: type = value_of_initializer %int.make_type_32.loc13 [template = i32]
  54. // CHECK:STDOUT: %.loc13_6.2: type = converted %int.make_type_32.loc13, %.loc13_6.1 [template = i32]
  55. // CHECK:STDOUT: %I.ref.loc13: type = name_ref I, %I.decl [template = constants.%.1]
  56. // CHECK:STDOUT: }
  57. // CHECK:STDOUT: %X.decl: type = class_decl @X [template = constants.%X] {}
  58. // CHECK:STDOUT: impl_decl @impl {
  59. // CHECK:STDOUT: %int.make_type_32.loc19: init type = call constants.%Int32() [template = i32]
  60. // CHECK:STDOUT: %.loc19_6.1: type = value_of_initializer %int.make_type_32.loc19 [template = i32]
  61. // CHECK:STDOUT: %.loc19_6.2: type = converted %int.make_type_32.loc19, %.loc19_6.1 [template = i32]
  62. // CHECK:STDOUT: %I.ref.loc19: type = name_ref I, %I.decl [template = constants.%.1]
  63. // CHECK:STDOUT: }
  64. // CHECK:STDOUT: }
  65. // CHECK:STDOUT:
  66. // CHECK:STDOUT: interface @I {
  67. // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic = constants.%Self]
  68. // CHECK:STDOUT:
  69. // CHECK:STDOUT: !members:
  70. // CHECK:STDOUT: .Self = %Self
  71. // CHECK:STDOUT: witness = ()
  72. // CHECK:STDOUT: }
  73. // CHECK:STDOUT:
  74. // CHECK:STDOUT: impl @impl: i32 as %.1 {
  75. // CHECK:STDOUT: %.1: <witness> = interface_witness () [template = constants.%.4]
  76. // CHECK:STDOUT:
  77. // CHECK:STDOUT: !members:
  78. // CHECK:STDOUT: witness = %.1
  79. // CHECK:STDOUT: }
  80. // CHECK:STDOUT:
  81. // CHECK:STDOUT: class @X {
  82. // CHECK:STDOUT: impl_decl @impl {
  83. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  84. // CHECK:STDOUT: %.loc16_8.1: type = value_of_initializer %int.make_type_32 [template = i32]
  85. // CHECK:STDOUT: %.loc16_8.2: type = converted %int.make_type_32, %.loc16_8.1 [template = i32]
  86. // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [template = constants.%.1]
  87. // CHECK:STDOUT: }
  88. // CHECK:STDOUT:
  89. // CHECK:STDOUT: !members:
  90. // CHECK:STDOUT: .Self = constants.%X
  91. // CHECK:STDOUT: }
  92. // CHECK:STDOUT:
  93. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  94. // CHECK:STDOUT: