fail_generic_redeclaration.carbon 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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/none.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/interface/fail_generic_redeclaration.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interface/fail_generic_redeclaration.carbon
  14. interface NotGeneric;
  15. // CHECK:STDERR: fail_generic_redeclaration.carbon:[[@LINE+7]]:1: error: redeclaration differs because of parameter list [RedeclParamListDiffers]
  16. // CHECK:STDERR: interface NotGeneric(T:! type) {}
  17. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  18. // CHECK:STDERR: fail_generic_redeclaration.carbon:[[@LINE-4]]:1: note: previously declared without parameter list [RedeclParamListPrevious]
  19. // CHECK:STDERR: interface NotGeneric;
  20. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~
  21. // CHECK:STDERR:
  22. interface NotGeneric(T:! type) {}
  23. interface Generic(T:! type);
  24. // CHECK:STDERR: fail_generic_redeclaration.carbon:[[@LINE+7]]:1: error: redeclaration differs because of missing parameter list [RedeclParamListDiffers]
  25. // CHECK:STDERR: interface Generic {}
  26. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~
  27. // CHECK:STDERR: fail_generic_redeclaration.carbon:[[@LINE-4]]:1: note: previously declared with parameter list [RedeclParamListPrevious]
  28. // CHECK:STDERR: interface Generic(T:! type);
  29. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
  30. // CHECK:STDERR:
  31. interface Generic {}
  32. interface DifferentParams(T:! type);
  33. // CHECK:STDERR: fail_generic_redeclaration.carbon:[[@LINE+7]]:27: error: type `<pattern for ()>` of parameter 1 in redeclaration differs from previous parameter type `<pattern for type>` [RedeclParamDiffersType]
  34. // CHECK:STDERR: interface DifferentParams(T:! ()) {}
  35. // CHECK:STDERR: ^
  36. // CHECK:STDERR: fail_generic_redeclaration.carbon:[[@LINE-4]]:27: note: previous declaration's corresponding parameter here [RedeclParamPrevious]
  37. // CHECK:STDERR: interface DifferentParams(T:! type);
  38. // CHECK:STDERR: ^
  39. // CHECK:STDERR:
  40. interface DifferentParams(T:! ()) {}
  41. // CHECK:STDOUT: --- fail_generic_redeclaration.carbon
  42. // CHECK:STDOUT:
  43. // CHECK:STDOUT: constants {
  44. // CHECK:STDOUT: %NotGeneric.type.10e: type = facet_type <@NotGeneric.1> [concrete]
  45. // CHECK:STDOUT: %T.8b3: type = bind_symbolic_name T, 0 [symbolic]
  46. // CHECK:STDOUT: %pattern_type.98f: type = pattern_type type [concrete]
  47. // CHECK:STDOUT: %NotGeneric.type.93b: type = generic_interface_type @NotGeneric.2 [concrete]
  48. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  49. // CHECK:STDOUT: %NotGeneric.generic: %NotGeneric.type.93b = struct_value () [concrete]
  50. // CHECK:STDOUT: %NotGeneric.type.8cb: type = facet_type <@NotGeneric.2, @NotGeneric.2(%T.8b3)> [symbolic]
  51. // CHECK:STDOUT: %Self.c08: %NotGeneric.type.8cb = bind_symbolic_name Self, 1 [symbolic]
  52. // CHECK:STDOUT: %Generic.type.c21: type = generic_interface_type @Generic.1 [concrete]
  53. // CHECK:STDOUT: %Generic.generic: %Generic.type.c21 = struct_value () [concrete]
  54. // CHECK:STDOUT: %Generic.type.c99: type = facet_type <@Generic.2> [concrete]
  55. // CHECK:STDOUT: %Self.5ae: %Generic.type.c99 = bind_symbolic_name Self, 0 [symbolic]
  56. // CHECK:STDOUT: %DifferentParams.type.d40e5c.1: type = generic_interface_type @DifferentParams.1 [concrete]
  57. // CHECK:STDOUT: %DifferentParams.generic.d33670.1: %DifferentParams.type.d40e5c.1 = struct_value () [concrete]
  58. // CHECK:STDOUT: %T.7a6: %empty_tuple.type = bind_symbolic_name T, 0 [symbolic]
  59. // CHECK:STDOUT: %pattern_type.cb1: type = pattern_type %empty_tuple.type [concrete]
  60. // CHECK:STDOUT: %DifferentParams.type.d40e5c.2: type = generic_interface_type @DifferentParams.2 [concrete]
  61. // CHECK:STDOUT: %DifferentParams.generic.d33670.2: %DifferentParams.type.d40e5c.2 = struct_value () [concrete]
  62. // CHECK:STDOUT: %DifferentParams.type.12c: type = facet_type <@DifferentParams.2, @DifferentParams.2(%T.7a6)> [symbolic]
  63. // CHECK:STDOUT: %Self.8d7: %DifferentParams.type.12c = bind_symbolic_name Self, 1 [symbolic]
  64. // CHECK:STDOUT: }
  65. // CHECK:STDOUT:
  66. // CHECK:STDOUT: file {
  67. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  68. // CHECK:STDOUT: .NotGeneric = %NotGeneric.decl.loc15
  69. // CHECK:STDOUT: .Generic = %Generic.decl.loc25
  70. // CHECK:STDOUT: .DifferentParams = %DifferentParams.decl.loc35
  71. // CHECK:STDOUT: }
  72. // CHECK:STDOUT: %NotGeneric.decl.loc15: type = interface_decl @NotGeneric.1 [concrete = constants.%NotGeneric.type.10e] {} {}
  73. // CHECK:STDOUT: %NotGeneric.decl.loc23: %NotGeneric.type.93b = interface_decl @NotGeneric.2 [concrete = constants.%NotGeneric.generic] {
  74. // CHECK:STDOUT: %T.patt: %pattern_type.98f = symbolic_binding_pattern T, 0 [concrete]
  75. // CHECK:STDOUT: } {
  76. // CHECK:STDOUT: %T.loc23_22.1: type = bind_symbolic_name T, 0 [symbolic = %T.loc23_22.2 (constants.%T.8b3)]
  77. // CHECK:STDOUT: }
  78. // CHECK:STDOUT: %Generic.decl.loc25: %Generic.type.c21 = interface_decl @Generic.1 [concrete = constants.%Generic.generic] {
  79. // CHECK:STDOUT: %T.patt: %pattern_type.98f = symbolic_binding_pattern T, 0 [concrete]
  80. // CHECK:STDOUT: } {
  81. // CHECK:STDOUT: %T.loc25_19.1: type = bind_symbolic_name T, 0 [symbolic = %T.loc25_19.2 (constants.%T.8b3)]
  82. // CHECK:STDOUT: }
  83. // CHECK:STDOUT: %Generic.decl.loc33: type = interface_decl @Generic.2 [concrete = constants.%Generic.type.c99] {} {}
  84. // CHECK:STDOUT: %DifferentParams.decl.loc35: %DifferentParams.type.d40e5c.1 = interface_decl @DifferentParams.1 [concrete = constants.%DifferentParams.generic.d33670.1] {
  85. // CHECK:STDOUT: %T.patt: %pattern_type.98f = symbolic_binding_pattern T, 0 [concrete]
  86. // CHECK:STDOUT: } {
  87. // CHECK:STDOUT: %T.loc35_27.1: type = bind_symbolic_name T, 0 [symbolic = %T.loc35_27.2 (constants.%T.8b3)]
  88. // CHECK:STDOUT: }
  89. // CHECK:STDOUT: %DifferentParams.decl.loc43: %DifferentParams.type.d40e5c.2 = interface_decl @DifferentParams.2 [concrete = constants.%DifferentParams.generic.d33670.2] {
  90. // CHECK:STDOUT: %T.patt: %pattern_type.cb1 = symbolic_binding_pattern T, 0 [concrete]
  91. // CHECK:STDOUT: } {
  92. // CHECK:STDOUT: %.loc43_32.1: type = splice_block %.loc43_32.3 [concrete = constants.%empty_tuple.type] {
  93. // CHECK:STDOUT: %.loc43_32.2: %empty_tuple.type = tuple_literal ()
  94. // CHECK:STDOUT: %.loc43_32.3: type = converted %.loc43_32.2, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  95. // CHECK:STDOUT: }
  96. // CHECK:STDOUT: %T.loc43_27.1: %empty_tuple.type = bind_symbolic_name T, 0 [symbolic = %T.loc43_27.2 (constants.%T.7a6)]
  97. // CHECK:STDOUT: }
  98. // CHECK:STDOUT: }
  99. // CHECK:STDOUT:
  100. // CHECK:STDOUT: interface @NotGeneric.1;
  101. // CHECK:STDOUT:
  102. // CHECK:STDOUT: generic interface @NotGeneric.2(%T.loc23_22.1: type) {
  103. // CHECK:STDOUT: %T.loc23_22.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc23_22.2 (constants.%T.8b3)]
  104. // CHECK:STDOUT:
  105. // CHECK:STDOUT: !definition:
  106. // CHECK:STDOUT: %NotGeneric.type: type = facet_type <@NotGeneric.2, @NotGeneric.2(%T.loc23_22.2)> [symbolic = %NotGeneric.type (constants.%NotGeneric.type.8cb)]
  107. // CHECK:STDOUT: %Self.2: @NotGeneric.2.%NotGeneric.type (%NotGeneric.type.8cb) = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self.c08)]
  108. // CHECK:STDOUT:
  109. // CHECK:STDOUT: interface {
  110. // CHECK:STDOUT: %Self.1: @NotGeneric.2.%NotGeneric.type (%NotGeneric.type.8cb) = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self.c08)]
  111. // CHECK:STDOUT:
  112. // CHECK:STDOUT: !members:
  113. // CHECK:STDOUT: .Self = %Self.1
  114. // CHECK:STDOUT: witness = ()
  115. // CHECK:STDOUT: }
  116. // CHECK:STDOUT: }
  117. // CHECK:STDOUT:
  118. // CHECK:STDOUT: generic interface @Generic.1(%T.loc25_19.1: type) {
  119. // CHECK:STDOUT: %T.loc25_19.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc25_19.2 (constants.%T.8b3)]
  120. // CHECK:STDOUT:
  121. // CHECK:STDOUT: interface;
  122. // CHECK:STDOUT: }
  123. // CHECK:STDOUT:
  124. // CHECK:STDOUT: interface @Generic.2 {
  125. // CHECK:STDOUT: %Self: %Generic.type.c99 = bind_symbolic_name Self, 0 [symbolic = constants.%Self.5ae]
  126. // CHECK:STDOUT:
  127. // CHECK:STDOUT: !members:
  128. // CHECK:STDOUT: .Self = %Self
  129. // CHECK:STDOUT: witness = ()
  130. // CHECK:STDOUT: }
  131. // CHECK:STDOUT:
  132. // CHECK:STDOUT: generic interface @DifferentParams.1(%T.loc35_27.1: type) {
  133. // CHECK:STDOUT: %T.loc35_27.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc35_27.2 (constants.%T.8b3)]
  134. // CHECK:STDOUT:
  135. // CHECK:STDOUT: interface;
  136. // CHECK:STDOUT: }
  137. // CHECK:STDOUT:
  138. // CHECK:STDOUT: generic interface @DifferentParams.2(%T.loc43_27.1: %empty_tuple.type) {
  139. // CHECK:STDOUT: %T.loc43_27.2: %empty_tuple.type = bind_symbolic_name T, 0 [symbolic = %T.loc43_27.2 (constants.%T.7a6)]
  140. // CHECK:STDOUT:
  141. // CHECK:STDOUT: !definition:
  142. // CHECK:STDOUT: %DifferentParams.type: type = facet_type <@DifferentParams.2, @DifferentParams.2(%T.loc43_27.2)> [symbolic = %DifferentParams.type (constants.%DifferentParams.type.12c)]
  143. // CHECK:STDOUT: %Self.2: @DifferentParams.2.%DifferentParams.type (%DifferentParams.type.12c) = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self.8d7)]
  144. // CHECK:STDOUT:
  145. // CHECK:STDOUT: interface {
  146. // CHECK:STDOUT: %Self.1: @DifferentParams.2.%DifferentParams.type (%DifferentParams.type.12c) = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self.8d7)]
  147. // CHECK:STDOUT:
  148. // CHECK:STDOUT: !members:
  149. // CHECK:STDOUT: .Self = %Self.1
  150. // CHECK:STDOUT: witness = ()
  151. // CHECK:STDOUT: }
  152. // CHECK:STDOUT: }
  153. // CHECK:STDOUT:
  154. // CHECK:STDOUT: specific @NotGeneric.2(constants.%T.8b3) {
  155. // CHECK:STDOUT: %T.loc23_22.2 => constants.%T.8b3
  156. // CHECK:STDOUT: }
  157. // CHECK:STDOUT:
  158. // CHECK:STDOUT: specific @Generic.1(constants.%T.8b3) {
  159. // CHECK:STDOUT: %T.loc25_19.2 => constants.%T.8b3
  160. // CHECK:STDOUT: }
  161. // CHECK:STDOUT:
  162. // CHECK:STDOUT: specific @DifferentParams.1(constants.%T.8b3) {
  163. // CHECK:STDOUT: %T.loc35_27.2 => constants.%T.8b3
  164. // CHECK:STDOUT: }
  165. // CHECK:STDOUT:
  166. // CHECK:STDOUT: specific @DifferentParams.2(constants.%T.7a6) {
  167. // CHECK:STDOUT: %T.loc43_27.2 => constants.%T.7a6
  168. // CHECK:STDOUT: }
  169. // CHECK:STDOUT: