assoc_const.carbon 2.9 KB

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