redeclaration.carbon 4.2 KB

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