redeclaration.carbon 5.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  6. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  7. //
  8. // AUTOUPDATE
  9. // TIP: To test this file alone, run:
  10. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/class/redeclaration.carbon
  11. // TIP: To dump output, run:
  12. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/redeclaration.carbon
  13. class Class;
  14. class Class {
  15. fn F[self: Self](b: ());
  16. }
  17. fn Class.F[self: Self](b: ()) {}
  18. // CHECK:STDOUT: --- redeclaration.carbon
  19. // CHECK:STDOUT:
  20. // CHECK:STDOUT: constants {
  21. // CHECK:STDOUT: %Class: type = class_type @Class [concrete]
  22. // CHECK:STDOUT: %pattern_type.761: type = pattern_type %Class [concrete]
  23. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  24. // CHECK:STDOUT: %pattern_type.cb1: type = pattern_type %empty_tuple.type [concrete]
  25. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  26. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  27. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  28. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  29. // CHECK:STDOUT: }
  30. // CHECK:STDOUT:
  31. // CHECK:STDOUT: imports {
  32. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  33. // CHECK:STDOUT: import Core//prelude
  34. // CHECK:STDOUT: import Core//prelude/...
  35. // CHECK:STDOUT: }
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT:
  38. // CHECK:STDOUT: file {
  39. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  40. // CHECK:STDOUT: .Core = imports.%Core
  41. // CHECK:STDOUT: .Class = %Class.decl.loc14
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT: %Core.import = import Core
  44. // CHECK:STDOUT: %Class.decl.loc14: type = class_decl @Class [concrete = constants.%Class] {} {}
  45. // CHECK:STDOUT: %Class.decl.loc16: type = class_decl @Class [concrete = constants.%Class] {} {}
  46. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  47. // CHECK:STDOUT: %self.patt: %pattern_type.761 = binding_pattern self [concrete]
  48. // CHECK:STDOUT: %self.param_patt: %pattern_type.761 = value_param_pattern %self.patt, call_param0 [concrete]
  49. // CHECK:STDOUT: %b.patt: %pattern_type.cb1 = binding_pattern b [concrete]
  50. // CHECK:STDOUT: %b.param_patt: %pattern_type.cb1 = value_param_pattern %b.patt, call_param1 [concrete]
  51. // CHECK:STDOUT: } {
  52. // CHECK:STDOUT: %self.param.loc20: %Class = value_param call_param0
  53. // CHECK:STDOUT: %Self.ref.loc20: type = name_ref Self, constants.%Class [concrete = constants.%Class]
  54. // CHECK:STDOUT: %self.loc20: %Class = bind_name self, %self.param.loc20
  55. // CHECK:STDOUT: %b.param.loc20: %empty_tuple.type = value_param call_param1
  56. // CHECK:STDOUT: %.loc20_28.1: type = splice_block %.loc20_28.3 [concrete = constants.%empty_tuple.type] {
  57. // CHECK:STDOUT: %.loc20_28.2: %empty_tuple.type = tuple_literal ()
  58. // CHECK:STDOUT: %.loc20_28.3: type = converted %.loc20_28.2, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  59. // CHECK:STDOUT: }
  60. // CHECK:STDOUT: %b.loc20: %empty_tuple.type = bind_name b, %b.param.loc20
  61. // CHECK:STDOUT: }
  62. // CHECK:STDOUT: }
  63. // CHECK:STDOUT:
  64. // CHECK:STDOUT: class @Class {
  65. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  66. // CHECK:STDOUT: %self.patt: %pattern_type.761 = binding_pattern self [concrete]
  67. // CHECK:STDOUT: %self.param_patt: %pattern_type.761 = value_param_pattern %self.patt, call_param0 [concrete]
  68. // CHECK:STDOUT: %b.patt: %pattern_type.cb1 = binding_pattern b [concrete]
  69. // CHECK:STDOUT: %b.param_patt: %pattern_type.cb1 = value_param_pattern %b.patt, call_param1 [concrete]
  70. // CHECK:STDOUT: } {
  71. // CHECK:STDOUT: %self.param.loc17: %Class = value_param call_param0
  72. // CHECK:STDOUT: %Self.ref.loc17: type = name_ref Self, constants.%Class [concrete = constants.%Class]
  73. // CHECK:STDOUT: %self.loc17: %Class = bind_name self, %self.param.loc17
  74. // CHECK:STDOUT: %b.param.loc17: %empty_tuple.type = value_param call_param1
  75. // CHECK:STDOUT: %.loc17_24.1: type = splice_block %.loc17_24.3 [concrete = constants.%empty_tuple.type] {
  76. // CHECK:STDOUT: %.loc17_24.2: %empty_tuple.type = tuple_literal ()
  77. // CHECK:STDOUT: %.loc17_24.3: type = converted %.loc17_24.2, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  78. // CHECK:STDOUT: }
  79. // CHECK:STDOUT: %b.loc17: %empty_tuple.type = bind_name b, %b.param.loc17
  80. // CHECK:STDOUT: }
  81. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete = constants.%empty_struct_type]
  82. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type]
  83. // CHECK:STDOUT: complete_type_witness = %complete_type
  84. // CHECK:STDOUT:
  85. // CHECK:STDOUT: !members:
  86. // CHECK:STDOUT: .Self = constants.%Class
  87. // CHECK:STDOUT: .F = %F.decl
  88. // CHECK:STDOUT: }
  89. // CHECK:STDOUT:
  90. // CHECK:STDOUT: fn @F(%self.param.loc20: %Class, %b.param.loc20: %empty_tuple.type) {
  91. // CHECK:STDOUT: !entry:
  92. // CHECK:STDOUT: return
  93. // CHECK:STDOUT: }
  94. // CHECK:STDOUT: