redeclaration.carbon 4.0 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/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: %I.type: type = facet_type <@I> [template]
  20. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic]
  21. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  22. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  23. // CHECK:STDOUT: %impl_witness: <witness> = impl_witness () [template]
  24. // CHECK:STDOUT: %X: type = class_type @X [template]
  25. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  26. // CHECK:STDOUT: %complete_type.357: <witness> = complete_type_witness %empty_struct_type [template]
  27. // CHECK:STDOUT: }
  28. // CHECK:STDOUT:
  29. // CHECK:STDOUT: imports {
  30. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  31. // CHECK:STDOUT: .Int = %Core.Int
  32. // CHECK:STDOUT: import Core//prelude
  33. // CHECK:STDOUT: import Core//prelude/...
  34. // CHECK:STDOUT: }
  35. // CHECK:STDOUT: }
  36. // CHECK:STDOUT:
  37. // CHECK:STDOUT: file {
  38. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  39. // CHECK:STDOUT: .Core = imports.%Core
  40. // CHECK:STDOUT: .I = %I.decl
  41. // CHECK:STDOUT: .X = %X.decl
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT: %Core.import = import Core
  44. // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%I.type] {} {}
  45. // CHECK:STDOUT: impl_decl @impl [template] {} {
  46. // CHECK:STDOUT: %int_32.loc13: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  47. // CHECK:STDOUT: %i32.loc13: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  48. // CHECK:STDOUT: %I.ref.loc13: type = name_ref I, file.%I.decl [template = constants.%I.type]
  49. // CHECK:STDOUT: }
  50. // CHECK:STDOUT: %impl_witness: <witness> = impl_witness () [template = constants.%impl_witness]
  51. // CHECK:STDOUT: %X.decl: type = class_decl @X [template = constants.%X] {} {}
  52. // CHECK:STDOUT: impl_decl @impl [template] {} {
  53. // CHECK:STDOUT: %int_32.loc19: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  54. // CHECK:STDOUT: %i32.loc19: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  55. // CHECK:STDOUT: %I.ref.loc19: type = name_ref I, file.%I.decl [template = constants.%I.type]
  56. // CHECK:STDOUT: }
  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: %i32.loc13 as %I.ref.loc13 {
  68. // CHECK:STDOUT: !members:
  69. // CHECK:STDOUT: witness = file.%impl_witness
  70. // CHECK:STDOUT: }
  71. // CHECK:STDOUT:
  72. // CHECK:STDOUT: class @X {
  73. // CHECK:STDOUT: impl_decl @impl [template] {} {
  74. // CHECK:STDOUT: %int_32.loc16: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  75. // CHECK:STDOUT: %i32.loc16: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  76. // CHECK:STDOUT: %I.ref.loc16: type = name_ref I, file.%I.decl [template = constants.%I.type]
  77. // CHECK:STDOUT: }
  78. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type.357]
  79. // CHECK:STDOUT: complete_type_witness = %complete_type
  80. // CHECK:STDOUT:
  81. // CHECK:STDOUT: !members:
  82. // CHECK:STDOUT: .Self = constants.%X
  83. // CHECK:STDOUT: }
  84. // CHECK:STDOUT: