redeclaration.carbon 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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/class/redeclaration.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/redeclaration.carbon
  10. class Class;
  11. class Class {
  12. fn F[self: Self](b: bool);
  13. }
  14. fn Class.F[self: Self](b: bool) {}
  15. // CHECK:STDOUT: --- redeclaration.carbon
  16. // CHECK:STDOUT:
  17. // CHECK:STDOUT: constants {
  18. // CHECK:STDOUT: %Class: type = class_type @Class [concrete]
  19. // CHECK:STDOUT: %pattern_type.761: type = pattern_type %Class [concrete]
  20. // CHECK:STDOUT: %Bool.type: type = fn_type @Bool [concrete]
  21. // CHECK:STDOUT: %Bool: %Bool.type = struct_value () [concrete]
  22. // CHECK:STDOUT: %pattern_type.831: type = pattern_type bool [concrete]
  23. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  24. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  25. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  26. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  27. // CHECK:STDOUT: }
  28. // CHECK:STDOUT:
  29. // CHECK:STDOUT: imports {
  30. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  31. // CHECK:STDOUT: .Bool = %Core.Bool
  32. // CHECK:STDOUT: import Core//prelude
  33. // CHECK:STDOUT: import Core//prelude/...
  34. // CHECK:STDOUT: }
  35. // CHECK:STDOUT: %Core.Bool: %Bool.type = import_ref Core//prelude/types/bool, Bool, loaded [concrete = constants.%Bool]
  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.loc11
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT: %Core.import = import Core
  44. // CHECK:STDOUT: %Class.decl.loc11: type = class_decl @Class [concrete = constants.%Class] {} {}
  45. // CHECK:STDOUT: %Class.decl.loc13: 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.831 = binding_pattern b [concrete]
  50. // CHECK:STDOUT: %b.param_patt: %pattern_type.831 = value_param_pattern %b.patt, call_param1 [concrete]
  51. // CHECK:STDOUT: } {
  52. // CHECK:STDOUT: %self.param.loc17: %Class = value_param call_param0
  53. // CHECK:STDOUT: %Self.ref.loc17: type = name_ref Self, constants.%Class [concrete = constants.%Class]
  54. // CHECK:STDOUT: %self.loc17: %Class = bind_name self, %self.param.loc17
  55. // CHECK:STDOUT: %b.param.loc17: bool = value_param call_param1
  56. // CHECK:STDOUT: %.loc17_27.1: type = splice_block %.loc17_27.3 [concrete = bool] {
  57. // CHECK:STDOUT: %bool.make_type.loc17: init type = call constants.%Bool() [concrete = bool]
  58. // CHECK:STDOUT: %.loc17_27.2: type = value_of_initializer %bool.make_type.loc17 [concrete = bool]
  59. // CHECK:STDOUT: %.loc17_27.3: type = converted %bool.make_type.loc17, %.loc17_27.2 [concrete = bool]
  60. // CHECK:STDOUT: }
  61. // CHECK:STDOUT: %b.loc17: bool = bind_name b, %b.param.loc17
  62. // CHECK:STDOUT: }
  63. // CHECK:STDOUT: }
  64. // CHECK:STDOUT:
  65. // CHECK:STDOUT: class @Class {
  66. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  67. // CHECK:STDOUT: %self.patt: %pattern_type.761 = binding_pattern self [concrete]
  68. // CHECK:STDOUT: %self.param_patt: %pattern_type.761 = value_param_pattern %self.patt, call_param0 [concrete]
  69. // CHECK:STDOUT: %b.patt: %pattern_type.831 = binding_pattern b [concrete]
  70. // CHECK:STDOUT: %b.param_patt: %pattern_type.831 = value_param_pattern %b.patt, call_param1 [concrete]
  71. // CHECK:STDOUT: } {
  72. // CHECK:STDOUT: %self.param.loc14: %Class = value_param call_param0
  73. // CHECK:STDOUT: %Self.ref.loc14: type = name_ref Self, constants.%Class [concrete = constants.%Class]
  74. // CHECK:STDOUT: %self.loc14: %Class = bind_name self, %self.param.loc14
  75. // CHECK:STDOUT: %b.param.loc14: bool = value_param call_param1
  76. // CHECK:STDOUT: %.loc14_23.1: type = splice_block %.loc14_23.3 [concrete = bool] {
  77. // CHECK:STDOUT: %bool.make_type.loc14: init type = call constants.%Bool() [concrete = bool]
  78. // CHECK:STDOUT: %.loc14_23.2: type = value_of_initializer %bool.make_type.loc14 [concrete = bool]
  79. // CHECK:STDOUT: %.loc14_23.3: type = converted %bool.make_type.loc14, %.loc14_23.2 [concrete = bool]
  80. // CHECK:STDOUT: }
  81. // CHECK:STDOUT: %b.loc14: bool = bind_name b, %b.param.loc14
  82. // CHECK:STDOUT: }
  83. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete = constants.%empty_struct_type]
  84. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type]
  85. // CHECK:STDOUT: complete_type_witness = %complete_type
  86. // CHECK:STDOUT:
  87. // CHECK:STDOUT: !members:
  88. // CHECK:STDOUT: .Self = constants.%Class
  89. // CHECK:STDOUT: .F = %F.decl
  90. // CHECK:STDOUT: }
  91. // CHECK:STDOUT:
  92. // CHECK:STDOUT: fn @F(%self.param.loc17: %Class, %b.param.loc17: bool) {
  93. // CHECK:STDOUT: !entry:
  94. // CHECK:STDOUT: return
  95. // CHECK:STDOUT: }
  96. // CHECK:STDOUT: