generic_binding_after_assoc_const.carbon 4.9 KB

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