basic.carbon 4.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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/basic.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interface/basic.carbon
  14. interface Empty {
  15. }
  16. interface ForwardDeclared;
  17. interface ForwardDeclared {
  18. fn F();
  19. }
  20. // CHECK:STDOUT: --- basic.carbon
  21. // CHECK:STDOUT:
  22. // CHECK:STDOUT: constants {
  23. // CHECK:STDOUT: %Empty.type: type = facet_type <@Empty> [concrete]
  24. // CHECK:STDOUT: %Self.61e: %Empty.type = symbolic_binding Self, 0 [symbolic]
  25. // CHECK:STDOUT: %ForwardDeclared.type: type = facet_type <@ForwardDeclared> [concrete]
  26. // CHECK:STDOUT: %Self.8e7: %ForwardDeclared.type = symbolic_binding Self, 0 [symbolic]
  27. // CHECK:STDOUT: %ForwardDeclared.WithSelf.F.type: type = fn_type @ForwardDeclared.WithSelf.F, @ForwardDeclared.WithSelf(%Self.8e7) [symbolic]
  28. // CHECK:STDOUT: %ForwardDeclared.WithSelf.F: %ForwardDeclared.WithSelf.F.type = struct_value () [symbolic]
  29. // CHECK:STDOUT: %ForwardDeclared.assoc_type: type = assoc_entity_type @ForwardDeclared [concrete]
  30. // CHECK:STDOUT: %assoc0: %ForwardDeclared.assoc_type = assoc_entity element0, @ForwardDeclared.WithSelf.%ForwardDeclared.WithSelf.F.decl [concrete]
  31. // CHECK:STDOUT: }
  32. // CHECK:STDOUT:
  33. // CHECK:STDOUT: file {
  34. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  35. // CHECK:STDOUT: .Empty = %Empty.decl
  36. // CHECK:STDOUT: .ForwardDeclared = %ForwardDeclared.decl.loc18
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT: %Empty.decl: type = interface_decl @Empty [concrete = constants.%Empty.type] {} {}
  39. // CHECK:STDOUT: %ForwardDeclared.decl.loc18: type = interface_decl @ForwardDeclared [concrete = constants.%ForwardDeclared.type] {} {}
  40. // CHECK:STDOUT: %ForwardDeclared.decl.loc20: type = interface_decl @ForwardDeclared [concrete = constants.%ForwardDeclared.type] {} {}
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT:
  43. // CHECK:STDOUT: interface @Empty {
  44. // CHECK:STDOUT: %Self: %Empty.type = symbolic_binding Self, 0 [symbolic = constants.%Self.61e]
  45. // CHECK:STDOUT: %Empty.WithSelf.decl = interface_with_self_decl @Empty [concrete]
  46. // CHECK:STDOUT:
  47. // CHECK:STDOUT: !members:
  48. // CHECK:STDOUT: .Self = %Self
  49. // CHECK:STDOUT: witness = ()
  50. // CHECK:STDOUT:
  51. // CHECK:STDOUT: !requires:
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT:
  54. // CHECK:STDOUT: interface @ForwardDeclared {
  55. // CHECK:STDOUT: %Self: %ForwardDeclared.type = symbolic_binding Self, 0 [symbolic = constants.%Self.8e7]
  56. // CHECK:STDOUT: %ForwardDeclared.WithSelf.decl = interface_with_self_decl @ForwardDeclared [concrete]
  57. // CHECK:STDOUT:
  58. // CHECK:STDOUT: !with Self:
  59. // CHECK:STDOUT: %ForwardDeclared.WithSelf.F.decl: @ForwardDeclared.WithSelf.%ForwardDeclared.WithSelf.F.type (%ForwardDeclared.WithSelf.F.type) = fn_decl @ForwardDeclared.WithSelf.F [symbolic = @ForwardDeclared.WithSelf.%ForwardDeclared.WithSelf.F (constants.%ForwardDeclared.WithSelf.F)] {} {}
  60. // CHECK:STDOUT: %assoc0: %ForwardDeclared.assoc_type = assoc_entity element0, %ForwardDeclared.WithSelf.F.decl [concrete = constants.%assoc0]
  61. // CHECK:STDOUT:
  62. // CHECK:STDOUT: !members:
  63. // CHECK:STDOUT: .Self = %Self
  64. // CHECK:STDOUT: .F = @ForwardDeclared.WithSelf.%assoc0
  65. // CHECK:STDOUT: witness = (@ForwardDeclared.WithSelf.%ForwardDeclared.WithSelf.F.decl)
  66. // CHECK:STDOUT:
  67. // CHECK:STDOUT: !requires:
  68. // CHECK:STDOUT: }
  69. // CHECK:STDOUT:
  70. // CHECK:STDOUT: generic fn @ForwardDeclared.WithSelf.F(@ForwardDeclared.%Self: %ForwardDeclared.type) {
  71. // CHECK:STDOUT: fn();
  72. // CHECK:STDOUT: }
  73. // CHECK:STDOUT:
  74. // CHECK:STDOUT: specific @Empty.WithSelf(constants.%Self.61e) {}
  75. // CHECK:STDOUT:
  76. // CHECK:STDOUT: specific @ForwardDeclared.WithSelf(constants.%Self.8e7) {}
  77. // CHECK:STDOUT:
  78. // CHECK:STDOUT: specific @ForwardDeclared.WithSelf.F(constants.%Self.8e7) {}
  79. // CHECK:STDOUT: