local.carbon 4.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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/no_prelude/local.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interface/no_prelude/local.carbon
  10. fn F() {
  11. interface I {
  12. fn G();
  13. }
  14. impl () as I {
  15. fn G() {}
  16. }
  17. ().(I.G)();
  18. }
  19. // CHECK:STDOUT: --- local.carbon
  20. // CHECK:STDOUT:
  21. // CHECK:STDOUT: constants {
  22. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  23. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  24. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  25. // CHECK:STDOUT: %I.type: type = facet_type <@I> [template]
  26. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic]
  27. // CHECK:STDOUT: %G.type.bff: type = fn_type @G.1 [template]
  28. // CHECK:STDOUT: %G.f0a: %G.type.bff = struct_value () [template]
  29. // CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type %I.type [template]
  30. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.%G.decl [template]
  31. // CHECK:STDOUT: %impl_witness: <witness> = impl_witness (@impl.%G.decl) [template]
  32. // CHECK:STDOUT: %G.type.c84: type = fn_type @G.2 [template]
  33. // CHECK:STDOUT: %G.5a2: %G.type.c84 = struct_value () [template]
  34. // CHECK:STDOUT: %I.facet: %I.type = facet_value %empty_tuple.type, %impl_witness [template]
  35. // CHECK:STDOUT: %.fbf: type = fn_type_with_self_type %G.type.bff, %I.facet [template]
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT:
  38. // CHECK:STDOUT: file {
  39. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  40. // CHECK:STDOUT: .F = %F.decl
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} {}
  43. // CHECK:STDOUT: }
  44. // CHECK:STDOUT:
  45. // CHECK:STDOUT: interface @I {
  46. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
  47. // CHECK:STDOUT: %G.decl: %G.type.bff = fn_decl @G.1 [template = constants.%G.f0a] {} {}
  48. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, %G.decl [template = constants.%assoc0]
  49. // CHECK:STDOUT:
  50. // CHECK:STDOUT: !members:
  51. // CHECK:STDOUT: .Self = %Self
  52. // CHECK:STDOUT: .G = %assoc0
  53. // CHECK:STDOUT: witness = (%G.decl)
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT:
  56. // CHECK:STDOUT: impl @impl: %.loc15_9.2 as %I.ref {
  57. // CHECK:STDOUT: %G.decl: %G.type.c84 = fn_decl @G.2 [template = constants.%G.5a2] {} {}
  58. // CHECK:STDOUT:
  59. // CHECK:STDOUT: !members:
  60. // CHECK:STDOUT: .G = %G.decl
  61. // CHECK:STDOUT: witness = @F.%impl_witness
  62. // CHECK:STDOUT: }
  63. // CHECK:STDOUT:
  64. // CHECK:STDOUT: fn @F() {
  65. // CHECK:STDOUT: !entry:
  66. // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%I.type] {} {}
  67. // CHECK:STDOUT: impl_decl @impl [template] {} {
  68. // CHECK:STDOUT: %.loc15_9.1: %empty_tuple.type = tuple_literal ()
  69. // CHECK:STDOUT: %.loc15_9.2: type = converted %.loc15_9.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  70. // CHECK:STDOUT: %I.ref: type = name_ref I, @F.%I.decl [template = constants.%I.type]
  71. // CHECK:STDOUT: }
  72. // CHECK:STDOUT: %impl_witness: <witness> = impl_witness (@impl.%G.decl) [template = constants.%impl_witness]
  73. // CHECK:STDOUT: %.loc18: %empty_tuple.type = tuple_literal ()
  74. // CHECK:STDOUT: %I.ref: type = name_ref I, %I.decl [template = constants.%I.type]
  75. // CHECK:STDOUT: %G.ref: %I.assoc_type = name_ref G, @I.%assoc0 [template = constants.%assoc0]
  76. // CHECK:STDOUT: %impl.elem0: %.fbf = impl_witness_access constants.%impl_witness, element0 [template = constants.%G.5a2]
  77. // CHECK:STDOUT: %G.call: init %empty_tuple.type = call %impl.elem0()
  78. // CHECK:STDOUT: return
  79. // CHECK:STDOUT: }
  80. // CHECK:STDOUT:
  81. // CHECK:STDOUT: generic fn @G.1(@I.%Self: %I.type) {
  82. // CHECK:STDOUT: fn();
  83. // CHECK:STDOUT: }
  84. // CHECK:STDOUT:
  85. // CHECK:STDOUT: fn @G.2() {
  86. // CHECK:STDOUT: !entry:
  87. // CHECK:STDOUT: return
  88. // CHECK:STDOUT: }
  89. // CHECK:STDOUT:
  90. // CHECK:STDOUT: specific @G.1(constants.%Self) {}
  91. // CHECK:STDOUT:
  92. // CHECK:STDOUT: specific @G.1(constants.%I.facet) {}
  93. // CHECK:STDOUT: