impl_forall.carbon 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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/impl/impl_forall.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/impl_forall.carbon
  10. interface Simple {
  11. fn F();
  12. }
  13. impl forall [T:! type] T as Simple {
  14. fn F() {}
  15. }
  16. // CHECK:STDOUT: --- impl_forall.carbon
  17. // CHECK:STDOUT:
  18. // CHECK:STDOUT: constants {
  19. // CHECK:STDOUT: %.1: type = interface_type @Simple [template]
  20. // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic]
  21. // CHECK:STDOUT: %F.type.1: type = fn_type @F.1 [template]
  22. // CHECK:STDOUT: %.2: type = tuple_type () [template]
  23. // CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [template]
  24. // CHECK:STDOUT: %.3: type = assoc_entity_type @Simple, %F.type.1 [template]
  25. // CHECK:STDOUT: %.4: %.3 = assoc_entity element0, @Simple.%F.decl [template]
  26. // CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic]
  27. // CHECK:STDOUT: %F.type.2: type = fn_type @F.2 [template]
  28. // CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [template]
  29. // CHECK:STDOUT: %.5: <witness> = interface_witness (%F.2) [template]
  30. // CHECK:STDOUT: }
  31. // CHECK:STDOUT:
  32. // CHECK:STDOUT: file {
  33. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  34. // CHECK:STDOUT: .Core = %Core
  35. // CHECK:STDOUT: .Simple = %Simple.decl
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  38. // CHECK:STDOUT: %Simple.decl: type = interface_decl @Simple [template = constants.%.1] {}
  39. // CHECK:STDOUT: impl_decl @impl {
  40. // CHECK:STDOUT: %T.loc15_14.1: type = param T
  41. // CHECK:STDOUT: %T.loc15_14.2: type = bind_symbolic_name T 0, %T.loc15_14.1 [symbolic = constants.%T]
  42. // CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc15_14.2 [symbolic = constants.%T]
  43. // CHECK:STDOUT: %Simple.ref: type = name_ref Simple, %Simple.decl [template = constants.%.1]
  44. // CHECK:STDOUT: }
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT:
  47. // CHECK:STDOUT: interface @Simple {
  48. // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic = constants.%Self]
  49. // CHECK:STDOUT: %F.decl: %F.type.1 = fn_decl @F.1 [template = constants.%F.1] {}
  50. // CHECK:STDOUT: %.loc12: %.3 = assoc_entity element0, %F.decl [template = constants.%.4]
  51. // CHECK:STDOUT:
  52. // CHECK:STDOUT: !members:
  53. // CHECK:STDOUT: .Self = %Self
  54. // CHECK:STDOUT: .F = %.loc12
  55. // CHECK:STDOUT: witness = (%F.decl)
  56. // CHECK:STDOUT: }
  57. // CHECK:STDOUT:
  58. // CHECK:STDOUT: impl @impl: %T as %.1 {
  59. // CHECK:STDOUT: %F.decl: %F.type.2 = fn_decl @F.2 [template = constants.%F.2] {}
  60. // CHECK:STDOUT: %.1: <witness> = interface_witness (%F.decl) [template = constants.%.5]
  61. // CHECK:STDOUT:
  62. // CHECK:STDOUT: !members:
  63. // CHECK:STDOUT: .F = %F.decl
  64. // CHECK:STDOUT: witness = %.1
  65. // CHECK:STDOUT: }
  66. // CHECK:STDOUT:
  67. // CHECK:STDOUT: fn @F.1()
  68. // CHECK:STDOUT: generic [@Simple.%Self: %.1];
  69. // CHECK:STDOUT:
  70. // CHECK:STDOUT: fn @F.2()
  71. // CHECK:STDOUT: generic [file.%T.loc15_14.2: type] {
  72. // CHECK:STDOUT: !entry:
  73. // CHECK:STDOUT: return
  74. // CHECK:STDOUT: }
  75. // CHECK:STDOUT: