generic.carbon 4.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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/uint.carbon
  6. //
  7. // AUTOUPDATE
  8. // TIP: To test this file alone, run:
  9. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/choice/generic.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/choice/generic.carbon
  12. //@dump-sem-ir-begin
  13. choice Always(T:! type) {
  14. Sunny
  15. }
  16. //@dump-sem-ir-end
  17. // CHECK:STDOUT: --- generic.carbon
  18. // CHECK:STDOUT:
  19. // CHECK:STDOUT: constants {
  20. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  21. // CHECK:STDOUT: %pattern_type: type = pattern_type type [concrete]
  22. // CHECK:STDOUT: %Always.type: type = generic_class_type @Always [concrete]
  23. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  24. // CHECK:STDOUT: %Always.generic: %Always.type = struct_value () [concrete]
  25. // CHECK:STDOUT: %Always: type = class_type @Always, @Always(%T) [symbolic]
  26. // CHECK:STDOUT: %struct_type.discriminant: type = struct_type {.discriminant: %empty_tuple.type} [concrete]
  27. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.discriminant [concrete]
  28. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete]
  29. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type %Always [symbolic]
  30. // CHECK:STDOUT: %Always.val: %Always = struct_value (%empty_tuple) [symbolic]
  31. // CHECK:STDOUT: }
  32. // CHECK:STDOUT:
  33. // CHECK:STDOUT: imports {
  34. // CHECK:STDOUT: }
  35. // CHECK:STDOUT:
  36. // CHECK:STDOUT: file {
  37. // CHECK:STDOUT: %Always.decl: %Always.type = class_decl @Always [concrete = constants.%Always.generic] {
  38. // CHECK:STDOUT: %T.patt: %pattern_type = symbolic_binding_pattern T, 0 [concrete]
  39. // CHECK:STDOUT: } {
  40. // CHECK:STDOUT: %T.loc14_15.1: type = bind_symbolic_name T, 0 [symbolic = %T.loc14_15.2 (constants.%T)]
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT:
  44. // CHECK:STDOUT: generic class @Always(%T.loc14_15.1: type) {
  45. // CHECK:STDOUT: %T.loc14_15.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc14_15.2 (constants.%T)]
  46. // CHECK:STDOUT:
  47. // CHECK:STDOUT: !definition:
  48. // CHECK:STDOUT: %Always: type = class_type @Always, @Always(%T.loc14_15.2) [symbolic = %Always (constants.%Always)]
  49. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type %Always [symbolic = %require_complete (constants.%require_complete)]
  50. // CHECK:STDOUT: %Always.val: @Always.%Always (%Always) = struct_value (constants.%empty_tuple) [symbolic = %Always.val (constants.%Always.val)]
  51. // CHECK:STDOUT:
  52. // CHECK:STDOUT: class {
  53. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%struct_type.discriminant [concrete = constants.%complete_type]
  54. // CHECK:STDOUT: %.loc16_1.1: %empty_tuple.type = tuple_literal ()
  55. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete = constants.%empty_tuple]
  56. // CHECK:STDOUT: %.loc16_1.2: %empty_tuple.type = converted %.loc16_1.1, %empty_tuple [concrete = constants.%empty_tuple]
  57. // CHECK:STDOUT: %.loc16_1.3: %struct_type.discriminant = struct_literal (%.loc16_1.2)
  58. // CHECK:STDOUT: %.loc16_1.4: ref @Always.%Always (%Always) = temporary_storage
  59. // CHECK:STDOUT: %.loc16_1.5: ref %empty_tuple.type = class_element_access %.loc16_1.4, element0
  60. // CHECK:STDOUT: %.loc16_1.6: init %empty_tuple.type = tuple_init () to %.loc16_1.5 [concrete = constants.%empty_tuple]
  61. // CHECK:STDOUT: %.loc16_1.7: init %empty_tuple.type = converted %.loc16_1.2, %.loc16_1.6 [concrete = constants.%empty_tuple]
  62. // CHECK:STDOUT: %.loc16_1.8: init @Always.%Always (%Always) = class_init (%.loc16_1.7), %.loc16_1.4 [symbolic = %Always.val (constants.%Always.val)]
  63. // CHECK:STDOUT: %.loc16_1.9: ref @Always.%Always (%Always) = temporary %.loc16_1.4, %.loc16_1.8
  64. // CHECK:STDOUT: %.loc16_1.10: ref @Always.%Always (%Always) = converted %.loc16_1.3, %.loc16_1.9
  65. // CHECK:STDOUT: %.loc16_1.11: @Always.%Always (%Always) = bind_value %.loc16_1.10
  66. // CHECK:STDOUT: %Sunny: @Always.%Always (%Always) = bind_name Sunny, %.loc16_1.11
  67. // CHECK:STDOUT: complete_type_witness = %complete_type
  68. // CHECK:STDOUT:
  69. // CHECK:STDOUT: !members:
  70. // CHECK:STDOUT: .Self = constants.%Always
  71. // CHECK:STDOUT: .Sunny = %Sunny
  72. // CHECK:STDOUT: }
  73. // CHECK:STDOUT: }
  74. // CHECK:STDOUT:
  75. // CHECK:STDOUT: specific @Always(constants.%T) {
  76. // CHECK:STDOUT: %T.loc14_15.2 => constants.%T
  77. // CHECK:STDOUT: }
  78. // CHECK:STDOUT: