redeclaration.carbon 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 [template]
  19. // CHECK:STDOUT: %Bool.type: type = fn_type @Bool [template]
  20. // CHECK:STDOUT: %Bool: %Bool.type = struct_value () [template]
  21. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  22. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  23. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  24. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
  25. // CHECK:STDOUT: }
  26. // CHECK:STDOUT:
  27. // CHECK:STDOUT: imports {
  28. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  29. // CHECK:STDOUT: .Bool = %Core.Bool
  30. // CHECK:STDOUT: import Core//prelude
  31. // CHECK:STDOUT: import Core//prelude/...
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT:
  35. // CHECK:STDOUT: file {
  36. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  37. // CHECK:STDOUT: .Core = imports.%Core
  38. // CHECK:STDOUT: .Class = %Class.decl.loc11
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT: %Core.import = import Core
  41. // CHECK:STDOUT: %Class.decl.loc11: type = class_decl @Class [template = constants.%Class] {} {}
  42. // CHECK:STDOUT: %Class.decl.loc13: type = class_decl @Class [template = constants.%Class] {} {}
  43. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  44. // CHECK:STDOUT: %self.patt: %Class = binding_pattern self
  45. // CHECK:STDOUT: %self.param_patt: %Class = value_param_pattern %self.patt, runtime_param0
  46. // CHECK:STDOUT: %b.patt: bool = binding_pattern b
  47. // CHECK:STDOUT: %b.param_patt: bool = value_param_pattern %b.patt, runtime_param1
  48. // CHECK:STDOUT: } {
  49. // CHECK:STDOUT: %self.param.loc17: %Class = value_param runtime_param0
  50. // CHECK:STDOUT: %Self.ref.loc17: type = name_ref Self, constants.%Class [template = constants.%Class]
  51. // CHECK:STDOUT: %self.loc17: %Class = bind_name self, %self.param.loc17
  52. // CHECK:STDOUT: %b.param.loc17: bool = value_param runtime_param1
  53. // CHECK:STDOUT: %.loc17_27.1: type = splice_block %.loc17_27.3 [template = bool] {
  54. // CHECK:STDOUT: %bool.make_type.loc17: init type = call constants.%Bool() [template = bool]
  55. // CHECK:STDOUT: %.loc17_27.2: type = value_of_initializer %bool.make_type.loc17 [template = bool]
  56. // CHECK:STDOUT: %.loc17_27.3: type = converted %bool.make_type.loc17, %.loc17_27.2 [template = bool]
  57. // CHECK:STDOUT: }
  58. // CHECK:STDOUT: %b.loc17: bool = bind_name b, %b.param.loc17
  59. // CHECK:STDOUT: }
  60. // CHECK:STDOUT: }
  61. // CHECK:STDOUT:
  62. // CHECK:STDOUT: class @Class {
  63. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  64. // CHECK:STDOUT: %self.patt: %Class = binding_pattern self
  65. // CHECK:STDOUT: %self.param_patt: %Class = value_param_pattern %self.patt, runtime_param0
  66. // CHECK:STDOUT: %b.patt: bool = binding_pattern b
  67. // CHECK:STDOUT: %b.param_patt: bool = value_param_pattern %b.patt, runtime_param1
  68. // CHECK:STDOUT: } {
  69. // CHECK:STDOUT: %self.param.loc14: %Class = value_param runtime_param0
  70. // CHECK:STDOUT: %Self.ref.loc14: type = name_ref Self, constants.%Class [template = constants.%Class]
  71. // CHECK:STDOUT: %self.loc14: %Class = bind_name self, %self.param.loc14
  72. // CHECK:STDOUT: %b.param.loc14: bool = value_param runtime_param1
  73. // CHECK:STDOUT: %.loc14_23.1: type = splice_block %.loc14_23.3 [template = bool] {
  74. // CHECK:STDOUT: %bool.make_type.loc14: init type = call constants.%Bool() [template = bool]
  75. // CHECK:STDOUT: %.loc14_23.2: type = value_of_initializer %bool.make_type.loc14 [template = bool]
  76. // CHECK:STDOUT: %.loc14_23.3: type = converted %bool.make_type.loc14, %.loc14_23.2 [template = bool]
  77. // CHECK:STDOUT: }
  78. // CHECK:STDOUT: %b.loc14: bool = bind_name b, %b.param.loc14
  79. // CHECK:STDOUT: }
  80. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
  81. // CHECK:STDOUT: complete_type_witness = %complete_type
  82. // CHECK:STDOUT:
  83. // CHECK:STDOUT: !members:
  84. // CHECK:STDOUT: .Self = constants.%Class
  85. // CHECK:STDOUT: .F = %F.decl
  86. // CHECK:STDOUT: }
  87. // CHECK:STDOUT:
  88. // CHECK:STDOUT: fn @F[%self.param_patt: %Class](%b.param_patt: bool) {
  89. // CHECK:STDOUT: !entry:
  90. // CHECK:STDOUT: return
  91. // CHECK:STDOUT: }
  92. // CHECK:STDOUT: