non_generic.carbon 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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/no_prelude/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/no_prelude/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 = {}) {}
  13. // CHECK:STDOUT: --- non_generic.carbon
  14. // CHECK:STDOUT:
  15. // CHECK:STDOUT: constants {
  16. // CHECK:STDOUT: %.1: type = interface_type @I [template]
  17. // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic]
  18. // CHECK:STDOUT: %.2: type = assoc_entity_type %.1, type [template]
  19. // CHECK:STDOUT: %.3: %.2 = assoc_entity element0, @I.%T [template]
  20. // CHECK:STDOUT: %.Self: %.1 = bind_symbolic_name .Self 0 [symbolic]
  21. // CHECK:STDOUT: %.4: type = tuple_type () [template]
  22. // CHECK:STDOUT: %.5: type = struct_type {} [template]
  23. // CHECK:STDOUT: %NotGenericF.type: type = fn_type @NotGenericF [template]
  24. // CHECK:STDOUT: %NotGenericF: %NotGenericF.type = struct_value () [template]
  25. // CHECK:STDOUT: }
  26. // CHECK:STDOUT:
  27. // CHECK:STDOUT: file {
  28. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  29. // CHECK:STDOUT: .I = %I.decl
  30. // CHECK:STDOUT: .NotGenericF = %NotGenericF.decl
  31. // CHECK:STDOUT: }
  32. // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%.1] {} {}
  33. // CHECK:STDOUT: %NotGenericF.decl: %NotGenericF.type = fn_decl @NotGenericF [template = constants.%NotGenericF] {
  34. // CHECK:STDOUT: %U.patt: %.1 = binding_pattern U
  35. // CHECK:STDOUT: } {
  36. // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [template = constants.%.1]
  37. // CHECK:STDOUT: %.Self: %.1 = bind_symbolic_name .Self 0 [symbolic = constants.%.Self]
  38. // CHECK:STDOUT: %.Self.ref: %.1 = name_ref .Self, %.Self [symbolic = constants.%.Self]
  39. // CHECK:STDOUT: %T.ref: %.2 = name_ref T, @I.%.loc11 [template = constants.%.3]
  40. // CHECK:STDOUT: %.loc14_33: %.5 = struct_literal ()
  41. // CHECK:STDOUT: %.loc14_21: type = where_expr %.Self [template = constants.%.1] {
  42. // CHECK:STDOUT: requirement_rewrite %T.ref, %.loc14_33
  43. // CHECK:STDOUT: }
  44. // CHECK:STDOUT: %U.param: %.1 = param U, runtime_param0
  45. // CHECK:STDOUT: %U: %.1 = bind_name U, %U.param
  46. // CHECK:STDOUT: }
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT:
  49. // CHECK:STDOUT: interface @I {
  50. // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic = constants.%Self]
  51. // CHECK:STDOUT: %T: type = assoc_const_decl T [template]
  52. // CHECK:STDOUT: %.loc11: %.2 = assoc_entity element0, %T [template = constants.%.3]
  53. // CHECK:STDOUT:
  54. // CHECK:STDOUT: !members:
  55. // CHECK:STDOUT: .Self = %Self
  56. // CHECK:STDOUT: .T = %.loc11
  57. // CHECK:STDOUT: witness = (%T)
  58. // CHECK:STDOUT: }
  59. // CHECK:STDOUT:
  60. // CHECK:STDOUT: fn @NotGenericF(%U: %.1) {
  61. // CHECK:STDOUT: !entry:
  62. // CHECK:STDOUT: return
  63. // CHECK:STDOUT: }
  64. // CHECK:STDOUT: