redeclaration.carbon 5.5 KB

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