assoc_const.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. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  6. // EXTRA-ARGS: --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/interface/assoc_const.carbon
  11. // TIP: To dump output, run:
  12. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interface/assoc_const.carbon
  13. interface I {
  14. let T:! type;
  15. let N:! i32;
  16. }
  17. // CHECK:STDOUT: --- assoc_const.carbon
  18. // CHECK:STDOUT:
  19. // CHECK:STDOUT: constants {
  20. // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
  21. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic]
  22. // CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type @I [concrete]
  23. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.%T [concrete]
  24. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  25. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  26. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  27. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  28. // CHECK:STDOUT: %assoc1: %I.assoc_type = assoc_entity element1, @I.%N [concrete]
  29. // CHECK:STDOUT: }
  30. // CHECK:STDOUT:
  31. // CHECK:STDOUT: imports {
  32. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  33. // CHECK:STDOUT: .Int = %Core.Int
  34. // CHECK:STDOUT: import Core//prelude
  35. // CHECK:STDOUT: import Core//prelude/...
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/types/int, Int, loaded [concrete = constants.%Int.generic]
  38. // CHECK:STDOUT: }
  39. // CHECK:STDOUT:
  40. // CHECK:STDOUT: file {
  41. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  42. // CHECK:STDOUT: .Core = imports.%Core
  43. // CHECK:STDOUT: .I = %I.decl
  44. // CHECK:STDOUT: }
  45. // CHECK:STDOUT: %Core.import = import Core
  46. // CHECK:STDOUT: %I.decl: type = interface_decl @I [concrete = constants.%I.type] {} {}
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT:
  49. // CHECK:STDOUT: interface @I {
  50. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
  51. // CHECK:STDOUT: %T: type = assoc_const_decl @T [concrete] {
  52. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.%T [concrete = constants.%assoc0]
  53. // CHECK:STDOUT: }
  54. // CHECK:STDOUT: %N: %i32 = assoc_const_decl @N [concrete] {
  55. // CHECK:STDOUT: %assoc1: %I.assoc_type = assoc_entity element1, @I.%N [concrete = constants.%assoc1]
  56. // CHECK:STDOUT: }
  57. // CHECK:STDOUT:
  58. // CHECK:STDOUT: !members:
  59. // CHECK:STDOUT: .Self = %Self
  60. // CHECK:STDOUT: .T = @T.%assoc0
  61. // CHECK:STDOUT: .N = @N.%assoc1
  62. // CHECK:STDOUT: witness = (%T, %N)
  63. // CHECK:STDOUT: }
  64. // CHECK:STDOUT:
  65. // CHECK:STDOUT: generic assoc_const @T(@I.%Self: %I.type) {
  66. // CHECK:STDOUT: assoc_const T:! type;
  67. // CHECK:STDOUT: }
  68. // CHECK:STDOUT:
  69. // CHECK:STDOUT: generic assoc_const @N(@I.%Self: %I.type) {
  70. // CHECK:STDOUT: assoc_const N:! %i32;
  71. // CHECK:STDOUT: }
  72. // CHECK:STDOUT:
  73. // CHECK:STDOUT: specific @T(constants.%Self) {}
  74. // CHECK:STDOUT:
  75. // CHECK:STDOUT: specific @N(constants.%Self) {}
  76. // CHECK:STDOUT: