generic_binding_after_assoc_const.carbon 4.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  6. // EXTRA-ARGS: --no-prelude-import --dump-sem-ir-ranges=if-present
  7. //
  8. // AUTOUPDATE
  9. // TIP: To test this file alone, run:
  10. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/interface/generic_binding_after_assoc_const.carbon
  11. // TIP: To dump output, run:
  12. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interface/generic_binding_after_assoc_const.carbon
  13. interface I {
  14. fn F(T:! type);
  15. let U:! type;
  16. // This `T` should have index 1, just like the `T` above.
  17. // The intervening `U:! type` should not cause this to have index 2.
  18. fn G(T:! type);
  19. }
  20. // CHECK:STDOUT: --- generic_binding_after_assoc_const.carbon
  21. // CHECK:STDOUT:
  22. // CHECK:STDOUT: constants {
  23. // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
  24. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic]
  25. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 1 [symbolic]
  26. // CHECK:STDOUT: %pattern_type: type = pattern_type type [concrete]
  27. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  28. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  29. // CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type @I [concrete]
  30. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.%F.decl [concrete]
  31. // CHECK:STDOUT: %assoc1: %I.assoc_type = assoc_entity element1, @I.%U [concrete]
  32. // CHECK:STDOUT: %G.type: type = fn_type @G [concrete]
  33. // CHECK:STDOUT: %G: %G.type = struct_value () [concrete]
  34. // CHECK:STDOUT: %assoc2: %I.assoc_type = assoc_entity element2, @I.%G.decl [concrete]
  35. // CHECK:STDOUT: }
  36. // CHECK:STDOUT:
  37. // CHECK:STDOUT: file {
  38. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  39. // CHECK:STDOUT: .I = %I.decl
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT: %I.decl: type = interface_decl @I [concrete = constants.%I.type] {} {}
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT:
  44. // CHECK:STDOUT: interface @I {
  45. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
  46. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  47. // CHECK:STDOUT: %T.patt: %pattern_type = symbolic_binding_pattern T, 1 [concrete]
  48. // CHECK:STDOUT: } {
  49. // CHECK:STDOUT: %T.loc15_8.2: type = bind_symbolic_name T, 1 [symbolic = %T.loc15_8.1 (constants.%T)]
  50. // CHECK:STDOUT: }
  51. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, %F.decl [concrete = constants.%assoc0]
  52. // CHECK:STDOUT: %U: type = assoc_const_decl @U [concrete] {
  53. // CHECK:STDOUT: %assoc1: %I.assoc_type = assoc_entity element1, @I.%U [concrete = constants.%assoc1]
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [concrete = constants.%G] {
  56. // CHECK:STDOUT: %T.patt: %pattern_type = symbolic_binding_pattern T, 1 [concrete]
  57. // CHECK:STDOUT: } {
  58. // CHECK:STDOUT: %T.loc19_8.2: type = bind_symbolic_name T, 1 [symbolic = %T.loc19_8.1 (constants.%T)]
  59. // CHECK:STDOUT: }
  60. // CHECK:STDOUT: %assoc2: %I.assoc_type = assoc_entity element2, %G.decl [concrete = constants.%assoc2]
  61. // CHECK:STDOUT:
  62. // CHECK:STDOUT: !members:
  63. // CHECK:STDOUT: .Self = %Self
  64. // CHECK:STDOUT: .F = %assoc0
  65. // CHECK:STDOUT: .U = @U.%assoc1
  66. // CHECK:STDOUT: .G = %assoc2
  67. // CHECK:STDOUT: witness = (%F.decl, %U, %G.decl)
  68. // CHECK:STDOUT: }
  69. // CHECK:STDOUT:
  70. // CHECK:STDOUT: generic assoc_const @U(@I.%Self: %I.type) {
  71. // CHECK:STDOUT: assoc_const U:! type;
  72. // CHECK:STDOUT: }
  73. // CHECK:STDOUT:
  74. // CHECK:STDOUT: generic fn @F(@I.%Self: %I.type, %T.loc15_8.2: type) {
  75. // CHECK:STDOUT: %T.loc15_8.1: type = bind_symbolic_name T, 1 [symbolic = %T.loc15_8.1 (constants.%T)]
  76. // CHECK:STDOUT:
  77. // CHECK:STDOUT: fn();
  78. // CHECK:STDOUT: }
  79. // CHECK:STDOUT:
  80. // CHECK:STDOUT: generic fn @G(@I.%Self: %I.type, %T.loc19_8.2: type) {
  81. // CHECK:STDOUT: %T.loc19_8.1: type = bind_symbolic_name T, 1 [symbolic = %T.loc19_8.1 (constants.%T)]
  82. // CHECK:STDOUT:
  83. // CHECK:STDOUT: fn();
  84. // CHECK:STDOUT: }
  85. // CHECK:STDOUT:
  86. // CHECK:STDOUT: specific @F(constants.%Self, constants.%T) {
  87. // CHECK:STDOUT: %T.loc15_8.1 => constants.%T
  88. // CHECK:STDOUT: }
  89. // CHECK:STDOUT:
  90. // CHECK:STDOUT: specific @U(constants.%Self) {}
  91. // CHECK:STDOUT:
  92. // CHECK:STDOUT: specific @G(constants.%Self, constants.%T) {
  93. // CHECK:STDOUT: %T.loc19_8.1 => constants.%T
  94. // CHECK:STDOUT: }
  95. // CHECK:STDOUT: