non_generic.carbon 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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/where_expr/non_generic.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/where_expr/non_generic.carbon
  10. interface I { let T:! type; }
  11. // Ensure that we don't crash when checking this `where` in a non-generic context.
  12. fn NotGenericF(U: I where .T == i32) {}
  13. // CHECK:STDOUT: --- non_generic.carbon
  14. // CHECK:STDOUT:
  15. // CHECK:STDOUT: constants {
  16. // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
  17. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic]
  18. // CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type @I [concrete]
  19. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.%T [concrete]
  20. // CHECK:STDOUT: %.Self: %I.type = bind_symbolic_name .Self [symbolic_self]
  21. // CHECK:STDOUT: %.Self.as_type: type = facet_access_type %.Self [symbolic_self]
  22. // CHECK:STDOUT: %.Self.as_wit.iface0: <witness> = facet_access_witness %.Self, element0 [symbolic_self]
  23. // CHECK:STDOUT: %I.facet: %I.type = facet_value %.Self.as_type, (%.Self.as_wit.iface0) [symbolic_self]
  24. // CHECK:STDOUT: %impl.elem0: type = impl_witness_access %.Self.as_wit.iface0, element0 [symbolic_self]
  25. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  26. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  27. // CHECK:STDOUT: %I_where.type: type = facet_type <@I where TODO> [concrete]
  28. // CHECK:STDOUT: %NotGenericF.type: type = fn_type @NotGenericF [concrete]
  29. // CHECK:STDOUT: %NotGenericF: %NotGenericF.type = struct_value () [concrete]
  30. // CHECK:STDOUT: }
  31. // CHECK:STDOUT:
  32. // CHECK:STDOUT: imports {
  33. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  34. // CHECK:STDOUT: .Int = %Core.Int
  35. // CHECK:STDOUT: import Core//prelude
  36. // CHECK:STDOUT: import Core//prelude/...
  37. // CHECK:STDOUT: }
  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: .NotGenericF = %NotGenericF.decl
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT: %Core.import = import Core
  47. // CHECK:STDOUT: %I.decl: type = interface_decl @I [concrete = constants.%I.type] {} {}
  48. // CHECK:STDOUT: %NotGenericF.decl: %NotGenericF.type = fn_decl @NotGenericF [concrete = constants.%NotGenericF] {
  49. // CHECK:STDOUT: %U.patt: %I_where.type = binding_pattern U
  50. // CHECK:STDOUT: %U.param_patt: %I_where.type = value_param_pattern %U.patt, call_param0
  51. // CHECK:STDOUT: } {
  52. // CHECK:STDOUT: %U.param: %I_where.type = value_param call_param0
  53. // CHECK:STDOUT: %.loc14_21.1: type = splice_block %.loc14_21.2 [concrete = constants.%I_where.type] {
  54. // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [concrete = constants.%I.type]
  55. // CHECK:STDOUT: %.Self: %I.type = bind_symbolic_name .Self [symbolic_self = constants.%.Self]
  56. // CHECK:STDOUT: %.Self.ref: %I.type = name_ref .Self, %.Self [symbolic_self = constants.%.Self]
  57. // CHECK:STDOUT: %T.ref: %I.assoc_type = name_ref T, @T.%assoc0 [concrete = constants.%assoc0]
  58. // CHECK:STDOUT: %.Self.as_type: type = facet_access_type %.Self.ref [symbolic_self = constants.%.Self.as_type]
  59. // CHECK:STDOUT: %.loc14_27: type = converted %.Self.ref, %.Self.as_type [symbolic_self = constants.%.Self.as_type]
  60. // CHECK:STDOUT: %.Self.as_wit.iface0: <witness> = facet_access_witness %.Self.ref, element0 [symbolic_self = constants.%.Self.as_wit.iface0]
  61. // CHECK:STDOUT: %impl.elem0: type = impl_witness_access %.Self.as_wit.iface0, element0 [symbolic_self = constants.%impl.elem0]
  62. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  63. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  64. // CHECK:STDOUT: %.loc14_21.2: type = where_expr %.Self [concrete = constants.%I_where.type] {
  65. // CHECK:STDOUT: requirement_equivalent %impl.elem0, %i32
  66. // CHECK:STDOUT: }
  67. // CHECK:STDOUT: }
  68. // CHECK:STDOUT: %U: %I_where.type = bind_name U, %U.param
  69. // CHECK:STDOUT: }
  70. // CHECK:STDOUT: }
  71. // CHECK:STDOUT:
  72. // CHECK:STDOUT: interface @I {
  73. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
  74. // CHECK:STDOUT: %T: type = assoc_const_decl @T [concrete] {
  75. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.%T [concrete = constants.%assoc0]
  76. // CHECK:STDOUT: }
  77. // CHECK:STDOUT:
  78. // CHECK:STDOUT: !members:
  79. // CHECK:STDOUT: .Self = %Self
  80. // CHECK:STDOUT: .T = @T.%assoc0
  81. // CHECK:STDOUT: witness = (%T)
  82. // CHECK:STDOUT: }
  83. // CHECK:STDOUT:
  84. // CHECK:STDOUT: generic assoc_const @T(@I.%Self: %I.type) {
  85. // CHECK:STDOUT: assoc_const T:! type;
  86. // CHECK:STDOUT: }
  87. // CHECK:STDOUT:
  88. // CHECK:STDOUT: fn @NotGenericF(%U.param_patt: %I_where.type) {
  89. // CHECK:STDOUT: !entry:
  90. // CHECK:STDOUT: return
  91. // CHECK:STDOUT: }
  92. // CHECK:STDOUT:
  93. // CHECK:STDOUT: specific @T(constants.%Self) {}
  94. // CHECK:STDOUT:
  95. // CHECK:STDOUT: specific @T(constants.%I.facet) {}
  96. // CHECK:STDOUT: