assoc_const.carbon 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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: %.1: type = interface_type @I [template]
  18. // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic]
  19. // CHECK:STDOUT: %.2: type = assoc_entity_type @I, type [template]
  20. // CHECK:STDOUT: %.3: %.2 = assoc_entity element0, @I.%T [template]
  21. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  22. // CHECK:STDOUT: %.4: type = tuple_type () [template]
  23. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  24. // CHECK:STDOUT: %.5: type = assoc_entity_type @I, i32 [template]
  25. // CHECK:STDOUT: %.6: %.5 = assoc_entity element1, @I.%N [template]
  26. // CHECK:STDOUT: }
  27. // CHECK:STDOUT:
  28. // CHECK:STDOUT: file {
  29. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  30. // CHECK:STDOUT: .Core = %Core
  31. // CHECK:STDOUT: .I = %I.decl
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  34. // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%.1] {}
  35. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT:
  38. // CHECK:STDOUT: interface @I {
  39. // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic = constants.%Self]
  40. // CHECK:STDOUT: %T: type = assoc_const_decl T [template]
  41. // CHECK:STDOUT: %.loc12: %.2 = assoc_entity element0, %T [template = constants.%.3]
  42. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  43. // CHECK:STDOUT: %.loc13_11.1: type = value_of_initializer %int.make_type_32 [template = i32]
  44. // CHECK:STDOUT: %.loc13_11.2: type = converted %int.make_type_32, %.loc13_11.1 [template = i32]
  45. // CHECK:STDOUT: %N: i32 = assoc_const_decl N [template]
  46. // CHECK:STDOUT: %.loc13_14: %.5 = assoc_entity element1, %N [template = constants.%.6]
  47. // CHECK:STDOUT:
  48. // CHECK:STDOUT: !members:
  49. // CHECK:STDOUT: .Self = %Self
  50. // CHECK:STDOUT: .T = %.loc12
  51. // CHECK:STDOUT: .N = %.loc13_14
  52. // CHECK:STDOUT: witness = (%T, %N)
  53. // CHECK:STDOUT: }
  54. // CHECK:STDOUT:
  55. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  56. // CHECK:STDOUT: