impl_forall.carbon 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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 = symbolic_binding Self, 0 [symbolic]
  25. // CHECK:STDOUT: %Simple.F.type: type = fn_type @Simple.F [concrete]
  26. // CHECK:STDOUT: %Simple.F: %Simple.F.type = 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.%Simple.F.decl [concrete]
  29. // CHECK:STDOUT: %type: type = facet_type <type> [concrete]
  30. // CHECK:STDOUT: %.Self: %type = symbolic_binding .Self [symbolic_self]
  31. // CHECK:STDOUT: %T: type = symbolic_binding T, 0 [symbolic]
  32. // CHECK:STDOUT: %pattern_type: type = pattern_type type [concrete]
  33. // CHECK:STDOUT: %Simple.impl_witness: <witness> = impl_witness file.%Simple.impl_witness_table, @T.as.Simple.impl(%T) [symbolic]
  34. // CHECK:STDOUT: %T.as.Simple.impl.F.type: type = fn_type @T.as.Simple.impl.F, @T.as.Simple.impl(%T) [symbolic]
  35. // CHECK:STDOUT: %T.as.Simple.impl.F: %T.as.Simple.impl.F.type = struct_value () [symbolic]
  36. // CHECK:STDOUT: %Simple.facet: %Simple.type = facet_value %T, (%Simple.impl_witness) [symbolic]
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT:
  39. // CHECK:STDOUT: file {
  40. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  41. // CHECK:STDOUT: .Simple = %Simple.decl
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT: %Simple.decl: type = interface_decl @Simple [concrete = constants.%Simple.type] {} {}
  44. // CHECK:STDOUT: impl_decl @T.as.Simple.impl [concrete] {
  45. // CHECK:STDOUT: %T.patt: %pattern_type = symbolic_binding_pattern T, 0 [concrete]
  46. // CHECK:STDOUT: } {
  47. // CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc19_14.2 [symbolic = %T.loc19_14.1 (constants.%T)]
  48. // CHECK:STDOUT: %Simple.ref: type = name_ref Simple, file.%Simple.decl [concrete = constants.%Simple.type]
  49. // CHECK:STDOUT: %.Self: %type = symbolic_binding .Self [symbolic_self = constants.%.Self]
  50. // CHECK:STDOUT: %T.loc19_14.2: type = symbolic_binding T, 0 [symbolic = %T.loc19_14.1 (constants.%T)]
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT: %Simple.impl_witness_table = impl_witness_table (@T.as.Simple.impl.%T.as.Simple.impl.F.decl), @T.as.Simple.impl [concrete]
  53. // CHECK:STDOUT: %Simple.impl_witness: <witness> = impl_witness %Simple.impl_witness_table, @T.as.Simple.impl(constants.%T) [symbolic = @T.as.Simple.impl.%Simple.impl_witness (constants.%Simple.impl_witness)]
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT:
  56. // CHECK:STDOUT: interface @Simple {
  57. // CHECK:STDOUT: %Self: %Simple.type = symbolic_binding Self, 0 [symbolic = constants.%Self]
  58. // CHECK:STDOUT: %Simple.F.decl: %Simple.F.type = fn_decl @Simple.F [concrete = constants.%Simple.F] {} {}
  59. // CHECK:STDOUT: %assoc0: %Simple.assoc_type = assoc_entity element0, %Simple.F.decl [concrete = constants.%assoc0]
  60. // CHECK:STDOUT:
  61. // CHECK:STDOUT: !members:
  62. // CHECK:STDOUT: .Self = %Self
  63. // CHECK:STDOUT: .F = %assoc0
  64. // CHECK:STDOUT: witness = (%Simple.F.decl)
  65. // CHECK:STDOUT:
  66. // CHECK:STDOUT: !requires:
  67. // CHECK:STDOUT: }
  68. // CHECK:STDOUT:
  69. // CHECK:STDOUT: generic impl @T.as.Simple.impl(%T.loc19_14.2: type) {
  70. // CHECK:STDOUT: %T.loc19_14.1: type = symbolic_binding T, 0 [symbolic = %T.loc19_14.1 (constants.%T)]
  71. // CHECK:STDOUT: %Simple.impl_witness: <witness> = impl_witness file.%Simple.impl_witness_table, @T.as.Simple.impl(%T.loc19_14.1) [symbolic = %Simple.impl_witness (constants.%Simple.impl_witness)]
  72. // CHECK:STDOUT:
  73. // CHECK:STDOUT: !definition:
  74. // CHECK:STDOUT: %T.as.Simple.impl.F.type: type = fn_type @T.as.Simple.impl.F, @T.as.Simple.impl(%T.loc19_14.1) [symbolic = %T.as.Simple.impl.F.type (constants.%T.as.Simple.impl.F.type)]
  75. // CHECK:STDOUT: %T.as.Simple.impl.F: @T.as.Simple.impl.%T.as.Simple.impl.F.type (%T.as.Simple.impl.F.type) = struct_value () [symbolic = %T.as.Simple.impl.F (constants.%T.as.Simple.impl.F)]
  76. // CHECK:STDOUT:
  77. // CHECK:STDOUT: impl: %T.ref as %Simple.ref {
  78. // CHECK:STDOUT: %T.as.Simple.impl.F.decl: @T.as.Simple.impl.%T.as.Simple.impl.F.type (%T.as.Simple.impl.F.type) = fn_decl @T.as.Simple.impl.F [symbolic = @T.as.Simple.impl.%T.as.Simple.impl.F (constants.%T.as.Simple.impl.F)] {} {}
  79. // CHECK:STDOUT:
  80. // CHECK:STDOUT: !members:
  81. // CHECK:STDOUT: .F = %T.as.Simple.impl.F.decl
  82. // CHECK:STDOUT: witness = file.%Simple.impl_witness
  83. // CHECK:STDOUT: }
  84. // CHECK:STDOUT: }
  85. // CHECK:STDOUT:
  86. // CHECK:STDOUT: generic fn @Simple.F(@Simple.%Self: %Simple.type) {
  87. // CHECK:STDOUT: fn();
  88. // CHECK:STDOUT: }
  89. // CHECK:STDOUT:
  90. // CHECK:STDOUT: generic fn @T.as.Simple.impl.F(@T.as.Simple.impl.%T.loc19_14.2: type) {
  91. // CHECK:STDOUT: !definition:
  92. // CHECK:STDOUT:
  93. // CHECK:STDOUT: fn() {
  94. // CHECK:STDOUT: !entry:
  95. // CHECK:STDOUT: return
  96. // CHECK:STDOUT: }
  97. // CHECK:STDOUT: }
  98. // CHECK:STDOUT:
  99. // CHECK:STDOUT: specific @Simple.F(constants.%Self) {}
  100. // CHECK:STDOUT:
  101. // CHECK:STDOUT: specific @T.as.Simple.impl(constants.%T) {
  102. // CHECK:STDOUT: %T.loc19_14.1 => constants.%T
  103. // CHECK:STDOUT: %Simple.impl_witness => constants.%Simple.impl_witness
  104. // CHECK:STDOUT:
  105. // CHECK:STDOUT: !definition:
  106. // CHECK:STDOUT: %T.as.Simple.impl.F.type => constants.%T.as.Simple.impl.F.type
  107. // CHECK:STDOUT: %T.as.Simple.impl.F => constants.%T.as.Simple.impl.F
  108. // CHECK:STDOUT: }
  109. // CHECK:STDOUT:
  110. // CHECK:STDOUT: specific @T.as.Simple.impl.F(constants.%T) {}
  111. // CHECK:STDOUT:
  112. // CHECK:STDOUT: specific @Simple.F(constants.%Simple.facet) {}
  113. // CHECK:STDOUT: