redeclaration.carbon 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/int.carbon
  6. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  7. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  8. //
  9. // AUTOUPDATE
  10. // TIP: To test this file alone, run:
  11. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/impl/redeclaration.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/redeclaration.carbon
  14. interface I {}
  15. impl i32 as I;
  16. class X {
  17. impl i32 as I;
  18. }
  19. impl i32 as I {}
  20. // CHECK:STDOUT: --- redeclaration.carbon
  21. // CHECK:STDOUT:
  22. // CHECK:STDOUT: constants {
  23. // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
  24. // CHECK:STDOUT: %Self: %I.type = symbolic_binding Self, 0 [symbolic]
  25. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  26. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  27. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  28. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  29. // CHECK:STDOUT: %I.impl_witness: <witness> = impl_witness @i32.as.I.impl.%I.impl_witness_table [concrete]
  30. // CHECK:STDOUT: %X: type = class_type @X [concrete]
  31. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  32. // CHECK:STDOUT: %complete_type.357: <witness> = complete_type_witness %empty_struct_type [concrete]
  33. // CHECK:STDOUT: %I.facet: %I.type = facet_value %i32, (%I.impl_witness) [concrete]
  34. // CHECK:STDOUT: }
  35. // CHECK:STDOUT:
  36. // CHECK:STDOUT: imports {
  37. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  38. // CHECK:STDOUT: .Int = %Core.Int
  39. // CHECK:STDOUT: import Core//prelude
  40. // CHECK:STDOUT: import Core//prelude/...
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/parts/int, Int, loaded [concrete = constants.%Int.generic]
  43. // CHECK:STDOUT: }
  44. // CHECK:STDOUT:
  45. // CHECK:STDOUT: file {
  46. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  47. // CHECK:STDOUT: .Core = imports.%Core
  48. // CHECK:STDOUT: .I = %I.decl
  49. // CHECK:STDOUT: .X = %X.decl
  50. // CHECK:STDOUT: }
  51. // CHECK:STDOUT: %Core.import = import Core
  52. // CHECK:STDOUT: %I.decl: type = interface_decl @I [concrete = constants.%I.type] {} {}
  53. // CHECK:STDOUT: impl_decl @i32.as.I.impl [concrete] {} {
  54. // CHECK:STDOUT: %i32.loc17: type = type_literal constants.%i32 [concrete = constants.%i32]
  55. // CHECK:STDOUT: %I.ref.loc17: type = name_ref I, file.%I.decl [concrete = constants.%I.type]
  56. // CHECK:STDOUT: }
  57. // CHECK:STDOUT: %X.decl: type = class_decl @X [concrete = constants.%X] {} {}
  58. // CHECK:STDOUT: impl_decl @i32.as.I.impl [concrete] {} {
  59. // CHECK:STDOUT: %i32.loc23: type = type_literal constants.%i32 [concrete = constants.%i32]
  60. // CHECK:STDOUT: %I.ref.loc23: type = name_ref I, file.%I.decl [concrete = constants.%I.type]
  61. // CHECK:STDOUT: }
  62. // CHECK:STDOUT: }
  63. // CHECK:STDOUT:
  64. // CHECK:STDOUT: interface @I {
  65. // CHECK:STDOUT: %Self: %I.type = symbolic_binding Self, 0 [symbolic = constants.%Self]
  66. // CHECK:STDOUT: %I.WithSelf.decl = interface_with_self_decl @I [concrete]
  67. // CHECK:STDOUT:
  68. // CHECK:STDOUT: !members:
  69. // CHECK:STDOUT: .Self = %Self
  70. // CHECK:STDOUT: witness = ()
  71. // CHECK:STDOUT:
  72. // CHECK:STDOUT: !requires:
  73. // CHECK:STDOUT: }
  74. // CHECK:STDOUT:
  75. // CHECK:STDOUT: impl @i32.as.I.impl: %i32.loc17 as %I.ref.loc17 {
  76. // CHECK:STDOUT: %I.impl_witness_table = impl_witness_table (), @i32.as.I.impl [concrete]
  77. // CHECK:STDOUT: %I.impl_witness: <witness> = impl_witness %I.impl_witness_table [concrete = constants.%I.impl_witness]
  78. // CHECK:STDOUT:
  79. // CHECK:STDOUT: !members:
  80. // CHECK:STDOUT: witness = %I.impl_witness
  81. // CHECK:STDOUT: }
  82. // CHECK:STDOUT:
  83. // CHECK:STDOUT: class @X {
  84. // CHECK:STDOUT: impl_decl @i32.as.I.impl [concrete] {} {
  85. // CHECK:STDOUT: %i32.loc20: type = type_literal constants.%i32 [concrete = constants.%i32]
  86. // CHECK:STDOUT: %I.ref.loc20: type = name_ref I, file.%I.decl [concrete = constants.%I.type]
  87. // CHECK:STDOUT: }
  88. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type.357]
  89. // CHECK:STDOUT: complete_type_witness = %complete_type
  90. // CHECK:STDOUT:
  91. // CHECK:STDOUT: !members:
  92. // CHECK:STDOUT: .Self = constants.%X
  93. // CHECK:STDOUT: .I = <poisoned>
  94. // CHECK:STDOUT: }
  95. // CHECK:STDOUT:
  96. // CHECK:STDOUT: specific @I.WithSelf(constants.%Self) {
  97. // CHECK:STDOUT: !definition:
  98. // CHECK:STDOUT: }
  99. // CHECK:STDOUT:
  100. // CHECK:STDOUT: specific @I.WithSelf(constants.%I.facet) {
  101. // CHECK:STDOUT: !definition:
  102. // CHECK:STDOUT: }
  103. // CHECK:STDOUT: