fail_generic_redeclaration.carbon 11 KB

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