redeclaration.carbon 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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: %.1: type = tuple_type () [template]
  21. // CHECK:STDOUT: %Bool: %Bool.type = struct_value () [template]
  22. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  23. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  24. // CHECK:STDOUT: %.2: type = struct_type {} [template]
  25. // CHECK:STDOUT: %.3: <witness> = complete_type_witness %.2 [template]
  26. // CHECK:STDOUT: %.4: type = ptr_type %.2 [template]
  27. // CHECK:STDOUT: }
  28. // CHECK:STDOUT:
  29. // CHECK:STDOUT: imports {
  30. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  31. // CHECK:STDOUT: .Bool = %import_ref
  32. // CHECK:STDOUT: import Core//prelude
  33. // CHECK:STDOUT: import Core//prelude/operators
  34. // CHECK:STDOUT: import Core//prelude/types
  35. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  36. // CHECK:STDOUT: import Core//prelude/operators/as
  37. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  38. // CHECK:STDOUT: import Core//prelude/operators/comparison
  39. // CHECK:STDOUT: import Core//prelude/types/bool
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT: %import_ref: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool]
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT:
  44. // CHECK:STDOUT: file {
  45. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  46. // CHECK:STDOUT: .Core = imports.%Core
  47. // CHECK:STDOUT: .Class = %Class.decl.loc11
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT: %Core.import = import Core
  50. // CHECK:STDOUT: %Class.decl.loc11: type = class_decl @Class [template = constants.%Class] {} {}
  51. // CHECK:STDOUT: %Class.decl.loc13: type = class_decl @Class [template = constants.%Class] {} {}
  52. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  53. // CHECK:STDOUT: %self.patt: %Class = binding_pattern self
  54. // CHECK:STDOUT: %self.param_patt: %Class = param_pattern %self.patt, runtime_param0
  55. // CHECK:STDOUT: %b.patt: bool = binding_pattern b
  56. // CHECK:STDOUT: %b.param_patt: bool = param_pattern %b.patt, runtime_param1
  57. // CHECK:STDOUT: } {
  58. // CHECK:STDOUT: %Self.ref.loc17: type = name_ref Self, constants.%Class [template = constants.%Class]
  59. // CHECK:STDOUT: %bool.make_type.loc17: init type = call constants.%Bool() [template = bool]
  60. // CHECK:STDOUT: %.loc17_27.1: type = value_of_initializer %bool.make_type.loc17 [template = bool]
  61. // CHECK:STDOUT: %.loc17_27.2: type = converted %bool.make_type.loc17, %.loc17_27.1 [template = bool]
  62. // CHECK:STDOUT: %param.loc17_12: %Class = param runtime_param0
  63. // CHECK:STDOUT: %self.loc17: %Class = bind_name self, %param.loc17_12
  64. // CHECK:STDOUT: %param.loc17_24: bool = param runtime_param1
  65. // CHECK:STDOUT: %b.loc17: bool = bind_name b, %param.loc17_24
  66. // CHECK:STDOUT: }
  67. // CHECK:STDOUT: }
  68. // CHECK:STDOUT:
  69. // CHECK:STDOUT: class @Class {
  70. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  71. // CHECK:STDOUT: %self.patt: %Class = binding_pattern self
  72. // CHECK:STDOUT: %self.param_patt: %Class = param_pattern %self.patt, runtime_param0
  73. // CHECK:STDOUT: %b.patt: bool = binding_pattern b
  74. // CHECK:STDOUT: %b.param_patt: bool = param_pattern %b.patt, runtime_param1
  75. // CHECK:STDOUT: } {
  76. // CHECK:STDOUT: %Self.ref.loc14: type = name_ref Self, constants.%Class [template = constants.%Class]
  77. // CHECK:STDOUT: %bool.make_type.loc14: init type = call constants.%Bool() [template = bool]
  78. // CHECK:STDOUT: %.loc14_23.1: type = value_of_initializer %bool.make_type.loc14 [template = bool]
  79. // CHECK:STDOUT: %.loc14_23.2: type = converted %bool.make_type.loc14, %.loc14_23.1 [template = bool]
  80. // CHECK:STDOUT: %param.loc14_8: %Class = param runtime_param0
  81. // CHECK:STDOUT: %self.loc14: %Class = bind_name self, %param.loc14_8
  82. // CHECK:STDOUT: %param.loc14_20: bool = param runtime_param1
  83. // CHECK:STDOUT: %b.loc14: bool = bind_name b, %param.loc14_20
  84. // CHECK:STDOUT: }
  85. // CHECK:STDOUT: %.loc15: <witness> = complete_type_witness %.2 [template = constants.%.3]
  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 @Bool() -> type = "bool.make_type";
  93. // CHECK:STDOUT:
  94. // CHECK:STDOUT: fn @F[%self.param_patt: %Class](%b.param_patt: bool) {
  95. // CHECK:STDOUT: !entry:
  96. // CHECK:STDOUT: return
  97. // CHECK:STDOUT: }
  98. // CHECK:STDOUT: