impl_forall.carbon 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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/impl/impl_forall.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/impl_forall.carbon
  14. interface Simple {
  15. fn F();
  16. }
  17. impl forall [T:! type] T as Simple {
  18. fn F() {}
  19. }
  20. // CHECK:STDOUT: --- impl_forall.carbon
  21. // CHECK:STDOUT:
  22. // CHECK:STDOUT: constants {
  23. // CHECK:STDOUT: %Simple.type: type = facet_type <@Simple> [concrete]
  24. // CHECK:STDOUT: %Self: %Simple.type = bind_symbolic_name Self, 0 [symbolic]
  25. // CHECK:STDOUT: %F.type.e2e: type = fn_type @F.loc16 [concrete]
  26. // CHECK:STDOUT: %F.df8: %F.type.e2e = struct_value () [concrete]
  27. // CHECK:STDOUT: %Simple.assoc_type: type = assoc_entity_type @Simple [concrete]
  28. // CHECK:STDOUT: %assoc0: %Simple.assoc_type = assoc_entity element0, @Simple.%F.decl [concrete]
  29. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  30. // CHECK:STDOUT: %pattern_type: type = pattern_type type [concrete]
  31. // CHECK:STDOUT: %Simple.impl_witness: <witness> = impl_witness file.%Simple.impl_witness_table, @Simple.impl(%T) [symbolic]
  32. // CHECK:STDOUT: %F.type.1e1: type = fn_type @F.loc20, @Simple.impl(%T) [symbolic]
  33. // CHECK:STDOUT: %F.4c3: %F.type.1e1 = struct_value () [symbolic]
  34. // CHECK:STDOUT: %Simple.facet: %Simple.type = facet_value %T, (%Simple.impl_witness) [symbolic]
  35. // CHECK:STDOUT: }
  36. // CHECK:STDOUT:
  37. // CHECK:STDOUT: file {
  38. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  39. // CHECK:STDOUT: .Simple = %Simple.decl
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT: %Simple.decl: type = interface_decl @Simple [concrete = constants.%Simple.type] {} {}
  42. // CHECK:STDOUT: impl_decl @Simple.impl [concrete] {
  43. // CHECK:STDOUT: %T.patt: %pattern_type = symbolic_binding_pattern T, 0 [concrete]
  44. // CHECK:STDOUT: } {
  45. // CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc19_14.1 [symbolic = %T.loc19_14.2 (constants.%T)]
  46. // CHECK:STDOUT: %Simple.ref: type = name_ref Simple, file.%Simple.decl [concrete = constants.%Simple.type]
  47. // CHECK:STDOUT: %T.loc19_14.1: type = bind_symbolic_name T, 0 [symbolic = %T.loc19_14.2 (constants.%T)]
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT: %Simple.impl_witness_table = impl_witness_table (@Simple.impl.%F.decl), @Simple.impl [concrete]
  50. // CHECK:STDOUT: %Simple.impl_witness: <witness> = impl_witness %Simple.impl_witness_table, @Simple.impl(constants.%T) [symbolic = @Simple.impl.%Simple.impl_witness (constants.%Simple.impl_witness)]
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT:
  53. // CHECK:STDOUT: interface @Simple {
  54. // CHECK:STDOUT: %Self: %Simple.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
  55. // CHECK:STDOUT: %F.decl: %F.type.e2e = fn_decl @F.loc16 [concrete = constants.%F.df8] {} {}
  56. // CHECK:STDOUT: %assoc0: %Simple.assoc_type = assoc_entity element0, %F.decl [concrete = constants.%assoc0]
  57. // CHECK:STDOUT:
  58. // CHECK:STDOUT: !members:
  59. // CHECK:STDOUT: .Self = %Self
  60. // CHECK:STDOUT: .F = %assoc0
  61. // CHECK:STDOUT: witness = (%F.decl)
  62. // CHECK:STDOUT: }
  63. // CHECK:STDOUT:
  64. // CHECK:STDOUT: generic impl @Simple.impl(%T.loc19_14.1: type) {
  65. // CHECK:STDOUT: %T.loc19_14.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc19_14.2 (constants.%T)]
  66. // CHECK:STDOUT: %Simple.impl_witness: <witness> = impl_witness file.%Simple.impl_witness_table, @Simple.impl(%T.loc19_14.2) [symbolic = %Simple.impl_witness (constants.%Simple.impl_witness)]
  67. // CHECK:STDOUT:
  68. // CHECK:STDOUT: !definition:
  69. // CHECK:STDOUT: %F.type: type = fn_type @F.loc20, @Simple.impl(%T.loc19_14.2) [symbolic = %F.type (constants.%F.type.1e1)]
  70. // CHECK:STDOUT: %F: @Simple.impl.%F.type (%F.type.1e1) = struct_value () [symbolic = %F (constants.%F.4c3)]
  71. // CHECK:STDOUT:
  72. // CHECK:STDOUT: impl: %T.ref as %Simple.ref {
  73. // CHECK:STDOUT: %F.decl: @Simple.impl.%F.type (%F.type.1e1) = fn_decl @F.loc20 [symbolic = @Simple.impl.%F (constants.%F.4c3)] {} {}
  74. // CHECK:STDOUT:
  75. // CHECK:STDOUT: !members:
  76. // CHECK:STDOUT: .F = %F.decl
  77. // CHECK:STDOUT: witness = file.%Simple.impl_witness
  78. // CHECK:STDOUT: }
  79. // CHECK:STDOUT: }
  80. // CHECK:STDOUT:
  81. // CHECK:STDOUT: generic fn @F.loc16(@Simple.%Self: %Simple.type) {
  82. // CHECK:STDOUT: fn();
  83. // CHECK:STDOUT: }
  84. // CHECK:STDOUT:
  85. // CHECK:STDOUT: generic fn @F.loc20(@Simple.impl.%T.loc19_14.1: type) {
  86. // CHECK:STDOUT: !definition:
  87. // CHECK:STDOUT:
  88. // CHECK:STDOUT: fn() {
  89. // CHECK:STDOUT: !entry:
  90. // CHECK:STDOUT: return
  91. // CHECK:STDOUT: }
  92. // CHECK:STDOUT: }
  93. // CHECK:STDOUT:
  94. // CHECK:STDOUT: specific @F.loc16(constants.%Self) {}
  95. // CHECK:STDOUT:
  96. // CHECK:STDOUT: specific @Simple.impl(constants.%T) {
  97. // CHECK:STDOUT: %T.loc19_14.2 => constants.%T
  98. // CHECK:STDOUT: %Simple.impl_witness => constants.%Simple.impl_witness
  99. // CHECK:STDOUT:
  100. // CHECK:STDOUT: !definition:
  101. // CHECK:STDOUT: %F.type => constants.%F.type.1e1
  102. // CHECK:STDOUT: %F => constants.%F.4c3
  103. // CHECK:STDOUT: }
  104. // CHECK:STDOUT:
  105. // CHECK:STDOUT: specific @F.loc20(constants.%T) {}
  106. // CHECK:STDOUT:
  107. // CHECK:STDOUT: specific @F.loc16(constants.%Simple.facet) {}
  108. // CHECK:STDOUT: