fail_generic_redeclaration.carbon 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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
  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
  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
  21. // CHECK:STDERR: interface Generic {}
  22. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~
  23. // CHECK:STDERR: fail_generic_redeclaration.carbon:[[@LINE-4]]:1: note: previously declared with parameter list
  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+6]]:27: error: redeclaration differs at parameter 1
  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
  33. // CHECK:STDERR: interface DifferentParams(T:! type);
  34. // CHECK:STDERR: ^
  35. interface DifferentParams(T:! ()) {}
  36. // CHECK:STDOUT: --- fail_generic_redeclaration.carbon
  37. // CHECK:STDOUT:
  38. // CHECK:STDOUT: constants {
  39. // CHECK:STDOUT: %.1: type = interface_type @NotGeneric [template]
  40. // CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic]
  41. // CHECK:STDOUT: %.type.1: type = generic_interface_type @.1 [template]
  42. // CHECK:STDOUT: %.2: type = tuple_type () [template]
  43. // CHECK:STDOUT: %.3: %.type.1 = struct_value () [template]
  44. // CHECK:STDOUT: %.4: type = interface_type @.1, @.1(%T.1) [symbolic]
  45. // CHECK:STDOUT: %Self.1: %.4 = bind_symbolic_name Self 1 [symbolic]
  46. // CHECK:STDOUT: %Generic.type: type = generic_interface_type @Generic [template]
  47. // CHECK:STDOUT: %Generic: %Generic.type = struct_value () [template]
  48. // CHECK:STDOUT: %.5: type = interface_type @.2 [template]
  49. // CHECK:STDOUT: %Self.2: %.5 = bind_symbolic_name Self 0 [symbolic]
  50. // CHECK:STDOUT: %DifferentParams.type: type = generic_interface_type @DifferentParams [template]
  51. // CHECK:STDOUT: %DifferentParams: %DifferentParams.type = struct_value () [template]
  52. // CHECK:STDOUT: %T.2: %.2 = bind_symbolic_name T 0 [symbolic]
  53. // CHECK:STDOUT: %.type.2: type = generic_interface_type @.3 [template]
  54. // CHECK:STDOUT: %.6: %.type.2 = struct_value () [template]
  55. // CHECK:STDOUT: %.7: type = interface_type @.3, @.3(%T.2) [symbolic]
  56. // CHECK:STDOUT: %Self.3: %.7 = bind_symbolic_name Self 1 [symbolic]
  57. // CHECK:STDOUT: }
  58. // CHECK:STDOUT:
  59. // CHECK:STDOUT: file {
  60. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  61. // CHECK:STDOUT: .NotGeneric = %NotGeneric.decl
  62. // CHECK:STDOUT: .Generic = %Generic.decl
  63. // CHECK:STDOUT: .DifferentParams = %DifferentParams.decl
  64. // CHECK:STDOUT: }
  65. // CHECK:STDOUT: %NotGeneric.decl: type = interface_decl @NotGeneric [template = constants.%.1] {} {}
  66. // CHECK:STDOUT: %.decl.loc19: %.type.1 = interface_decl @.1 [template = constants.%.3] {
  67. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T 0
  68. // CHECK:STDOUT: } {
  69. // CHECK:STDOUT: %T.param: type = param T, runtime_param<invalid>
  70. // CHECK:STDOUT: %T.loc19: type = bind_symbolic_name T 0, %T.param [symbolic = %T.1 (constants.%T.1)]
  71. // CHECK:STDOUT: }
  72. // CHECK:STDOUT: %Generic.decl: %Generic.type = interface_decl @Generic [template = constants.%Generic] {
  73. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T 0
  74. // CHECK:STDOUT: } {
  75. // CHECK:STDOUT: %T.param: type = param T, runtime_param<invalid>
  76. // CHECK:STDOUT: %T.loc21: type = bind_symbolic_name T 0, %T.param [symbolic = %T.1 (constants.%T.1)]
  77. // CHECK:STDOUT: }
  78. // CHECK:STDOUT: %.decl.loc29: type = interface_decl @.2 [template = constants.%.5] {} {}
  79. // CHECK:STDOUT: %DifferentParams.decl: %DifferentParams.type = interface_decl @DifferentParams [template = constants.%DifferentParams] {
  80. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T 0
  81. // CHECK:STDOUT: } {
  82. // CHECK:STDOUT: %T.param: type = param T, runtime_param<invalid>
  83. // CHECK:STDOUT: %T.loc31: type = bind_symbolic_name T 0, %T.param [symbolic = %T.1 (constants.%T.1)]
  84. // CHECK:STDOUT: }
  85. // CHECK:STDOUT: %.decl.loc38: %.type.2 = interface_decl @.3 [template = constants.%.6] {
  86. // CHECK:STDOUT: %T.patt: %.2 = symbolic_binding_pattern T 0
  87. // CHECK:STDOUT: } {
  88. // CHECK:STDOUT: %.loc38_32.1: %.2 = tuple_literal ()
  89. // CHECK:STDOUT: %.loc38_32.2: type = converted %.loc38_32.1, constants.%.2 [template = constants.%.2]
  90. // CHECK:STDOUT: %T.param: %.2 = param T, runtime_param<invalid>
  91. // CHECK:STDOUT: %T.loc38: %.2 = bind_symbolic_name T 0, %T.param [symbolic = %T.1 (constants.%T.2)]
  92. // CHECK:STDOUT: }
  93. // CHECK:STDOUT: }
  94. // CHECK:STDOUT:
  95. // CHECK:STDOUT: interface @NotGeneric;
  96. // CHECK:STDOUT:
  97. // CHECK:STDOUT: generic interface @.1(%T.loc19: type) {
  98. // CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T.1)]
  99. // CHECK:STDOUT:
  100. // CHECK:STDOUT: !definition:
  101. // CHECK:STDOUT: %.1: type = interface_type @.1, @.1(%T.1) [symbolic = %.1 (constants.%.4)]
  102. // CHECK:STDOUT: %Self.2: %.4 = bind_symbolic_name Self 1 [symbolic = %Self.2 (constants.%Self.1)]
  103. // CHECK:STDOUT:
  104. // CHECK:STDOUT: interface {
  105. // CHECK:STDOUT: %Self.1: @.1.%.1 (%.4) = bind_symbolic_name Self 1 [symbolic = %Self.2 (constants.%Self.1)]
  106. // CHECK:STDOUT:
  107. // CHECK:STDOUT: !members:
  108. // CHECK:STDOUT: .Self = %Self.1
  109. // CHECK:STDOUT: witness = ()
  110. // CHECK:STDOUT: }
  111. // CHECK:STDOUT: }
  112. // CHECK:STDOUT:
  113. // CHECK:STDOUT: generic interface @Generic(%T.loc21: type) {
  114. // CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T.1)]
  115. // CHECK:STDOUT:
  116. // CHECK:STDOUT: interface;
  117. // CHECK:STDOUT: }
  118. // CHECK:STDOUT:
  119. // CHECK:STDOUT: interface @.2 {
  120. // CHECK:STDOUT: %Self: %.5 = bind_symbolic_name Self 0 [symbolic = constants.%Self.2]
  121. // CHECK:STDOUT:
  122. // CHECK:STDOUT: !members:
  123. // CHECK:STDOUT: .Self = %Self
  124. // CHECK:STDOUT: witness = ()
  125. // CHECK:STDOUT: }
  126. // CHECK:STDOUT:
  127. // CHECK:STDOUT: generic interface @DifferentParams(%T.loc31: type) {
  128. // CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T.1)]
  129. // CHECK:STDOUT:
  130. // CHECK:STDOUT: interface;
  131. // CHECK:STDOUT: }
  132. // CHECK:STDOUT:
  133. // CHECK:STDOUT: generic interface @.3(%T.loc38: %.2) {
  134. // CHECK:STDOUT: %T.1: %.2 = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T.2)]
  135. // CHECK:STDOUT:
  136. // CHECK:STDOUT: !definition:
  137. // CHECK:STDOUT: %.1: type = interface_type @.3, @.3(%T.1) [symbolic = %.1 (constants.%.7)]
  138. // CHECK:STDOUT: %Self.2: %.7 = bind_symbolic_name Self 1 [symbolic = %Self.2 (constants.%Self.3)]
  139. // CHECK:STDOUT:
  140. // CHECK:STDOUT: interface {
  141. // CHECK:STDOUT: %Self.1: @.3.%.1 (%.7) = bind_symbolic_name Self 1 [symbolic = %Self.2 (constants.%Self.3)]
  142. // CHECK:STDOUT:
  143. // CHECK:STDOUT: !members:
  144. // CHECK:STDOUT: .Self = %Self.1
  145. // CHECK:STDOUT: witness = ()
  146. // CHECK:STDOUT: }
  147. // CHECK:STDOUT: }
  148. // CHECK:STDOUT:
  149. // CHECK:STDOUT: specific @.1(constants.%T.1) {
  150. // CHECK:STDOUT: %T.1 => constants.%T.1
  151. // CHECK:STDOUT: }
  152. // CHECK:STDOUT:
  153. // CHECK:STDOUT: specific @.1(@.1.%T.1) {
  154. // CHECK:STDOUT: %T.1 => constants.%T.1
  155. // CHECK:STDOUT: }
  156. // CHECK:STDOUT:
  157. // CHECK:STDOUT: specific @Generic(constants.%T.1) {
  158. // CHECK:STDOUT: %T.1 => constants.%T.1
  159. // CHECK:STDOUT: }
  160. // CHECK:STDOUT:
  161. // CHECK:STDOUT: specific @DifferentParams(constants.%T.1) {
  162. // CHECK:STDOUT: %T.1 => constants.%T.1
  163. // CHECK:STDOUT: }
  164. // CHECK:STDOUT:
  165. // CHECK:STDOUT: specific @.3(constants.%T.2) {
  166. // CHECK:STDOUT: %T.1 => constants.%T.2
  167. // CHECK:STDOUT: }
  168. // CHECK:STDOUT:
  169. // CHECK:STDOUT: specific @.3(@.3.%T.1) {
  170. // CHECK:STDOUT: %T.1 => constants.%T.2
  171. // CHECK:STDOUT: }
  172. // CHECK:STDOUT: