basic.carbon 4.3 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/impl/basic.carbon
  11. // TIP: To dump output, run:
  12. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/basic.carbon
  13. interface Simple {
  14. fn F();
  15. }
  16. class C {}
  17. impl C as Simple {
  18. fn F() {}
  19. }
  20. // CHECK:STDOUT: --- basic.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.1 [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: %C: type = class_type @C [concrete]
  30. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  31. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  32. // CHECK:STDOUT: %Simple.impl_witness: <witness> = impl_witness file.%Simple.impl_witness_table [concrete]
  33. // CHECK:STDOUT: %F.type.f9e: type = fn_type @F.2 [concrete]
  34. // CHECK:STDOUT: %F.f50: %F.type.f9e = struct_value () [concrete]
  35. // CHECK:STDOUT: %Simple.facet: %Simple.type = facet_value %C, (%Simple.impl_witness) [concrete]
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT:
  38. // CHECK:STDOUT: file {
  39. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  40. // CHECK:STDOUT: .Simple = %Simple.decl
  41. // CHECK:STDOUT: .C = %C.decl
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT: %Simple.decl: type = interface_decl @Simple [concrete = constants.%Simple.type] {} {}
  44. // CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {}
  45. // CHECK:STDOUT: impl_decl @impl [concrete] {} {
  46. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C]
  47. // CHECK:STDOUT: %Simple.ref: type = name_ref Simple, file.%Simple.decl [concrete = constants.%Simple.type]
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT: %Simple.impl_witness_table = impl_witness_table (@impl.%F.decl), @impl [concrete]
  50. // CHECK:STDOUT: %Simple.impl_witness: <witness> = impl_witness %Simple.impl_witness_table [concrete = 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.1 [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: impl @impl: %C.ref as %Simple.ref {
  65. // CHECK:STDOUT: %F.decl: %F.type.f9e = fn_decl @F.2 [concrete = constants.%F.f50] {} {}
  66. // CHECK:STDOUT:
  67. // CHECK:STDOUT: !members:
  68. // CHECK:STDOUT: .F = %F.decl
  69. // CHECK:STDOUT: witness = file.%Simple.impl_witness
  70. // CHECK:STDOUT: }
  71. // CHECK:STDOUT:
  72. // CHECK:STDOUT: class @C {
  73. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete = constants.%empty_struct_type]
  74. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type]
  75. // CHECK:STDOUT: complete_type_witness = %complete_type
  76. // CHECK:STDOUT:
  77. // CHECK:STDOUT: !members:
  78. // CHECK:STDOUT: .Self = constants.%C
  79. // CHECK:STDOUT: }
  80. // CHECK:STDOUT:
  81. // CHECK:STDOUT: generic fn @F.1(@Simple.%Self: %Simple.type) {
  82. // CHECK:STDOUT: fn();
  83. // CHECK:STDOUT: }
  84. // CHECK:STDOUT:
  85. // CHECK:STDOUT: fn @F.2() {
  86. // CHECK:STDOUT: !entry:
  87. // CHECK:STDOUT: return
  88. // CHECK:STDOUT: }
  89. // CHECK:STDOUT:
  90. // CHECK:STDOUT: specific @F.1(constants.%Self) {}
  91. // CHECK:STDOUT:
  92. // CHECK:STDOUT: specific @F.1(constants.%Simple.facet) {}
  93. // CHECK:STDOUT: