redeclaration.carbon 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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: bool);
  16. }
  17. fn Class.F[self: Self](b: bool) {}
  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: %Bool.type: type = fn_type @Bool [concrete]
  24. // CHECK:STDOUT: %Bool: %Bool.type = struct_value () [concrete]
  25. // CHECK:STDOUT: %pattern_type.831: type = pattern_type bool [concrete]
  26. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  27. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  28. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  29. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  30. // CHECK:STDOUT: }
  31. // CHECK:STDOUT:
  32. // CHECK:STDOUT: imports {
  33. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  34. // CHECK:STDOUT: .Bool = %Core.Bool
  35. // CHECK:STDOUT: import Core//prelude
  36. // CHECK:STDOUT: import Core//prelude/...
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT: %Core.Bool: %Bool.type = import_ref Core//prelude/types/bool, Bool, loaded [concrete = constants.%Bool]
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT:
  41. // CHECK:STDOUT: file {
  42. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  43. // CHECK:STDOUT: .Core = imports.%Core
  44. // CHECK:STDOUT: .Class = %Class.decl.loc14
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT: %Core.import = import Core
  47. // CHECK:STDOUT: %Class.decl.loc14: type = class_decl @Class [concrete = constants.%Class] {} {}
  48. // CHECK:STDOUT: %Class.decl.loc16: type = class_decl @Class [concrete = constants.%Class] {} {}
  49. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  50. // CHECK:STDOUT: %self.patt: %pattern_type.761 = binding_pattern self [concrete]
  51. // CHECK:STDOUT: %self.param_patt: %pattern_type.761 = value_param_pattern %self.patt, call_param0 [concrete]
  52. // CHECK:STDOUT: %b.patt: %pattern_type.831 = binding_pattern b [concrete]
  53. // CHECK:STDOUT: %b.param_patt: %pattern_type.831 = value_param_pattern %b.patt, call_param1 [concrete]
  54. // CHECK:STDOUT: } {
  55. // CHECK:STDOUT: %self.param.loc20: %Class = value_param call_param0
  56. // CHECK:STDOUT: %Self.ref.loc20: type = name_ref Self, constants.%Class [concrete = constants.%Class]
  57. // CHECK:STDOUT: %self.loc20: %Class = bind_name self, %self.param.loc20
  58. // CHECK:STDOUT: %b.param.loc20: bool = value_param call_param1
  59. // CHECK:STDOUT: %.loc20_27.1: type = splice_block %.loc20_27.3 [concrete = bool] {
  60. // CHECK:STDOUT: %bool.make_type.loc20: init type = call constants.%Bool() [concrete = bool]
  61. // CHECK:STDOUT: %.loc20_27.2: type = value_of_initializer %bool.make_type.loc20 [concrete = bool]
  62. // CHECK:STDOUT: %.loc20_27.3: type = converted %bool.make_type.loc20, %.loc20_27.2 [concrete = bool]
  63. // CHECK:STDOUT: }
  64. // CHECK:STDOUT: %b.loc20: bool = bind_name b, %b.param.loc20
  65. // CHECK:STDOUT: }
  66. // CHECK:STDOUT: }
  67. // CHECK:STDOUT:
  68. // CHECK:STDOUT: class @Class {
  69. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  70. // CHECK:STDOUT: %self.patt: %pattern_type.761 = binding_pattern self [concrete]
  71. // CHECK:STDOUT: %self.param_patt: %pattern_type.761 = value_param_pattern %self.patt, call_param0 [concrete]
  72. // CHECK:STDOUT: %b.patt: %pattern_type.831 = binding_pattern b [concrete]
  73. // CHECK:STDOUT: %b.param_patt: %pattern_type.831 = value_param_pattern %b.patt, call_param1 [concrete]
  74. // CHECK:STDOUT: } {
  75. // CHECK:STDOUT: %self.param.loc17: %Class = value_param call_param0
  76. // CHECK:STDOUT: %Self.ref.loc17: type = name_ref Self, constants.%Class [concrete = constants.%Class]
  77. // CHECK:STDOUT: %self.loc17: %Class = bind_name self, %self.param.loc17
  78. // CHECK:STDOUT: %b.param.loc17: bool = value_param call_param1
  79. // CHECK:STDOUT: %.loc17_23.1: type = splice_block %.loc17_23.3 [concrete = bool] {
  80. // CHECK:STDOUT: %bool.make_type.loc17: init type = call constants.%Bool() [concrete = bool]
  81. // CHECK:STDOUT: %.loc17_23.2: type = value_of_initializer %bool.make_type.loc17 [concrete = bool]
  82. // CHECK:STDOUT: %.loc17_23.3: type = converted %bool.make_type.loc17, %.loc17_23.2 [concrete = bool]
  83. // CHECK:STDOUT: }
  84. // CHECK:STDOUT: %b.loc17: bool = bind_name b, %b.param.loc17
  85. // CHECK:STDOUT: }
  86. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete = constants.%empty_struct_type]
  87. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type]
  88. // CHECK:STDOUT: complete_type_witness = %complete_type
  89. // CHECK:STDOUT:
  90. // CHECK:STDOUT: !members:
  91. // CHECK:STDOUT: .Self = constants.%Class
  92. // CHECK:STDOUT: .F = %F.decl
  93. // CHECK:STDOUT: }
  94. // CHECK:STDOUT:
  95. // CHECK:STDOUT: fn @F(%self.param.loc20: %Class, %b.param.loc20: bool) {
  96. // CHECK:STDOUT: !entry:
  97. // CHECK:STDOUT: return
  98. // CHECK:STDOUT: }
  99. // CHECK:STDOUT: